GRAPHICS: MACGUI: Implemented non-binary version of inline text formatting
This commit is contained in:
parent
5251a67032
commit
a35259dc0d
2 changed files with 45 additions and 18 deletions
|
@ -83,13 +83,7 @@ Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
|
||||||
|
|
||||||
debugCN(4, kDebugText, "*");
|
debugCN(4, kDebugText, "*");
|
||||||
|
|
||||||
_ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c",
|
_ftext += Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _fontId, _textSlant, _fontSize, _palinfo1, _palinfo2, _palinfo3);
|
||||||
(_fontId >> 8) & 0xff, _fontId & 0xff,
|
|
||||||
_textSlant & 0xff,
|
|
||||||
(_fontSize >> 8) & 0xff, _fontSize & 0xff,
|
|
||||||
(_palinfo1 >> 8) & 0xff, _palinfo1 & 0xff,
|
|
||||||
(_palinfo2 >> 8) & 0xff, _palinfo2 & 0xff,
|
|
||||||
(_palinfo3 >> 8) & 0xff, _palinfo3 & 0xff);
|
|
||||||
|
|
||||||
formattingCount--;
|
formattingCount--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,7 @@ const Font *MacFontRun::getFont() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::String MacFontRun::toString() {
|
const Common::String MacFontRun::toString() {
|
||||||
return Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c",
|
return Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
|
||||||
(fontId >> 8) & 0xff, fontId & 0xff,
|
|
||||||
textSlant & 0xff,
|
|
||||||
(fontSize >> 8) & 0xff, fontSize & 0xff,
|
|
||||||
(palinfo1 >> 8) & 0xff, palinfo1 & 0xff,
|
|
||||||
(palinfo2 >> 8) & 0xff, palinfo2 & 0xff,
|
|
||||||
(palinfo3 >> 8) & 0xff, palinfo3 & 0xff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MacText::~MacText() {
|
MacText::~MacText() {
|
||||||
|
@ -129,6 +123,22 @@ void MacText::setMaxWidth(int maxWidth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const Common::U32String::value_type *readHex(uint16 *res, const Common::U32String::value_type *s, int len) {
|
||||||
|
*res = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char b = (char)*s++;
|
||||||
|
|
||||||
|
*res <<= 8;
|
||||||
|
if (tolower(b) > 'a')
|
||||||
|
*res |= tolower(b) - 'a';
|
||||||
|
else
|
||||||
|
*res |= tolower(b) - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
void MacText::splitString(Common::U32String &str) {
|
void MacText::splitString(Common::U32String &str) {
|
||||||
const Common::U32String::value_type *s = str.c_str();
|
const Common::U32String::value_type *s = str.c_str();
|
||||||
|
|
||||||
|
@ -161,9 +171,8 @@ void MacText::splitString(Common::U32String &str) {
|
||||||
s++;
|
s++;
|
||||||
if (*s == '\001') {
|
if (*s == '\001') {
|
||||||
// Copy it verbatim
|
// Copy it verbatim
|
||||||
} else {
|
} else if (*s == '\015') {
|
||||||
if (*s++ != '\015')
|
s++;
|
||||||
error("MacText: formatting error");
|
|
||||||
|
|
||||||
uint16 fontId = *s++; fontId = (fontId << 8) | *s++;
|
uint16 fontId = *s++; fontId = (fontId << 8) | *s++;
|
||||||
byte textSlant = *s++;
|
byte textSlant = *s++;
|
||||||
|
@ -182,8 +191,32 @@ void MacText::splitString(Common::U32String &str) {
|
||||||
previousFormatting = _currentFormatting;
|
previousFormatting = _currentFormatting;
|
||||||
|
|
||||||
nextChunk = true;
|
nextChunk = true;
|
||||||
|
} else if (*s == '\016') {
|
||||||
|
s++;
|
||||||
|
|
||||||
|
uint16 fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3;
|
||||||
|
|
||||||
|
s = readHex(&fontId, s, 4);
|
||||||
|
s = readHex(&textSlant, s, 2);
|
||||||
|
s = readHex(&fontSize, s, 4);
|
||||||
|
s = readHex(&palinfo1, s, 4);
|
||||||
|
s = readHex(&palinfo2, s, 4);
|
||||||
|
s = readHex(&palinfo3, s, 4);
|
||||||
|
|
||||||
|
debug(8, "******** splitString: fontId: %d, textSlant: %d, fontSize: %d, p0: %x p1: %x p2: %x",
|
||||||
|
fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
|
||||||
|
|
||||||
|
previousFormatting = _currentFormatting;
|
||||||
|
_currentFormatting.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
|
||||||
|
|
||||||
|
if (curLine == 0 && curChunk == 0 && tmp.empty())
|
||||||
|
previousFormatting = _currentFormatting;
|
||||||
|
|
||||||
|
nextChunk = true;
|
||||||
|
} else {
|
||||||
|
error("MacText: formatting error, got %02x", *s);
|
||||||
}
|
}
|
||||||
} else if (*s == '\n' && prevCR) { // trean \r\n as one
|
} else if (*s == '\n' && prevCR) { // treat \r\n as one
|
||||||
prevCR = false;
|
prevCR = false;
|
||||||
|
|
||||||
s++;
|
s++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue