DIRECTOR: LINGO: Implement MacText::enforceTextFont() and use it to implement STUB kTheTextFont in TextCastMember::setField()

This commit is contained in:
Pragyansh Chaturvedi (r41k0u) 2022-06-05 06:32:01 +05:30 committed by Eugene Sandulenko
parent a982da07d7
commit 334bbd11a3
4 changed files with 17 additions and 3 deletions

View File

@ -1036,7 +1036,7 @@ void TextCastMember::importRTE(byte *text) {
}
void TextCastMember::setText(const Common::U32String &text) {
//Do nothing if text did not change
// Do nothing if text did not change
if (_ptext.equals(text))
return;

View File

@ -1041,8 +1041,9 @@ bool TextCastMember::setField(int field, const Datum &d) {
}
return true;
case kTheTextFont:
_fontId = g_director->_wm->_fontMan->getFontIdByName(d.asString());
setText(this->_ptext);
((Graphics::MacText *)toEdit->_widget)->enforceTextFont((uint16) g_director->_wm->_fontMan->getFontIdByName(d.asString()));
_ptext = ((Graphics::MacText *)toEdit->_widget)->getPlainText();
_ftext = ((Graphics::MacText *)toEdit->_widget)->getTextChunk(0, 0, -1, -1, true);
_modified = true;
return false;
case kTheTextHeight:

View File

@ -337,6 +337,18 @@ void MacText::setColors(uint32 fg, uint32 bg) {
_contentIsDirty = true;
}
void MacText::enforceTextFont(uint16 fontId) {
for (uint i = 0; i < _textLines.size(); i++) {
for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
_textLines[i].chunks[j].fontId = fontId;
}
}
_fullRefresh = true;
render();
_contentIsDirty = true;
}
void MacText::setTextSize(int textSize) {
for (uint i = 0; i < _textLines.size(); i++) {
for (uint j = 0; j < _textLines[i].chunks.size(); j++) {

View File

@ -194,6 +194,7 @@ public:
void appendText(const Common::U32String &str, const Font *font, uint16 r = 0, uint16 g = 0, uint16 b = 0, bool skipAdd = false);
int getTextFont() { return _defaultFormatting.fontId; }
void enforceTextFont(uint16 fontId);
// because currently, we are counting linespacing as font height
int getTextSize() { return _defaultFormatting.fontSize; }