[Scummvm-git-logs] scummvm master -> 5d2d393c4beba4df47fae39ae42dc9ab2ec67473
sev-
noreply at scummvm.org
Tue Dec 26 00:41:33 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5d2d393c4b DIRECTOR: Fix textcast dimensions when initial text is empty and AdjustToFit is set
Commit: 5d2d393c4beba4df47fae39ae42dc9ab2ec67473
https://github.com/scummvm/scummvm/commit/5d2d393c4beba4df47fae39ae42dc9ab2ec67473
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-26T01:41:05+01:00
Commit Message:
DIRECTOR: Fix textcast dimensions when initial text is empty and AdjustToFit is set
In this case, we need to ignore the font formatting as there could be
a leftovver from the previous edits.
We also recalculate the dimensions to the minimal height as that is used
as basis for textbox extension during edits or text inserts.
Fixes 'number of chars' in 'Lingo Workshop'
Changed paths:
engines/director/castmember/text.cpp
engines/director/stxt.cpp
diff --git a/engines/director/castmember/text.cpp b/engines/director/castmember/text.cpp
index d75037a0849..080636a0f91 100644
--- a/engines/director/castmember/text.cpp
+++ b/engines/director/castmember/text.cpp
@@ -233,6 +233,13 @@ void TextCastMember::importStxt(const Stxt *stxt) {
Graphics::MacFont macFont(_fontId, _fontSize, _textSlant);
g_director->_wm->_fontMan->getFont(&macFont);
_fontId = macFont.getId();
+
+ // If the text is empty, that means we ignored the font and now
+ // set the text height to a minimal one.
+ //
+ // This fixes `number of chars` in Lingo Workshop
+ if (_textType == kTextTypeAdjustToFit && _ftext.empty())
+ _initialRect.setHeight(macFont.getSize() + (2 * _borderSize) + _gutterSize + _boxShadow);
}
bool textWindowCallback(Graphics::WindowClick click, Common::Event &event, void *ptr) {
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index bdf57c9f005..ef62ff63815 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -94,9 +94,12 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
_ftext += u32TextPart;
logText += Common::toPrintable(u32TextPart);
- Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
- _ftext += format;
- logText += Common::toPrintable(format);
+ // Do not add formatting of empty blocks
+ if (textPart.size()) {
+ Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
+ _ftext += format;
+ logText += Common::toPrintable(format);
+ }
formattingCount--;
}
@@ -108,6 +111,12 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
_ftext += u32Text;
logText += Common::toPrintable(u32Text);
+ // Reset style if there is no text
+ if (_ftext.empty()) {
+ debugC(4, kDebugText, "Stxt init: the font formatting was reset due to empty string");
+ _style = FontStyle();
+ }
+
debugC(4, kDebugText, "#### text:\n%s\n####", logText.encode(Common::kUtf8).c_str());
}
More information about the Scummvm-git-logs
mailing list