From 334bbd11a3dbff83c9066152fc8eb612b431fc08 Mon Sep 17 00:00:00 2001 From: "Pragyansh Chaturvedi (r41k0u)" Date: Sun, 5 Jun 2022 06:32:01 +0530 Subject: [PATCH] DIRECTOR: LINGO: Implement MacText::enforceTextFont() and use it to implement STUB kTheTextFont in TextCastMember::setField() --- engines/director/castmember.cpp | 2 +- engines/director/lingo/lingo-object.cpp | 5 +++-- graphics/macgui/mactext.cpp | 12 ++++++++++++ graphics/macgui/mactext.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp index bbe0d24f3e4..bc7b8479287 100644 --- a/engines/director/castmember.cpp +++ b/engines/director/castmember.cpp @@ -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; diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp index 0bec808149d..80892440460 100644 --- a/engines/director/lingo/lingo-object.cpp +++ b/engines/director/lingo/lingo-object.cpp @@ -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: diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index e9fe32c3fb7..a3f63f90d88 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -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++) { diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index a014ed8bca1..f41a2c67f06 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -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; }