mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
TITANIC: Implement font loading
This commit is contained in:
@@ -66,4 +66,26 @@ void STFont::writeString(int maxWidth, const CString &text, int *v1, int *v2) {
|
||||
warning("TODO: STFont::writeString");
|
||||
}
|
||||
|
||||
int STFont::stringWidth(const CString &text) const {
|
||||
if (text.empty())
|
||||
return 0;
|
||||
|
||||
const char *srcP = text.c_str();
|
||||
int total = 0;
|
||||
char c;
|
||||
while (c = *srcP++) {
|
||||
if (c == 26) {
|
||||
// Skip over command parameter bytes
|
||||
srcP += 3;
|
||||
} else if (c == 27) {
|
||||
// Skip over command parameter bytes
|
||||
srcP += 4;
|
||||
} else if (c != '\n') {
|
||||
total += _chars[c]._charWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
size_t _dataSize;
|
||||
int _field8;
|
||||
int _maxCharWidth;
|
||||
Common::Array<CharEntry> _chars;
|
||||
CharEntry _chars[256];
|
||||
int _field810;
|
||||
int _field814;
|
||||
int _field818;
|
||||
@@ -52,6 +52,11 @@ public:
|
||||
*/
|
||||
void load(int fontNumber);
|
||||
|
||||
/**
|
||||
* Return the width in pixels of the specified text
|
||||
*/
|
||||
int stringWidth(const CString &text) const;
|
||||
|
||||
/**
|
||||
* Write out a string
|
||||
* TODO: Verify this
|
||||
|
||||
Reference in New Issue
Block a user