[Scummvm-git-logs] scummvm master -> 2b4ce79ea501c57e3562dc0a075c23de3472580c
orgads
noreply at scummvm.org
Sun May 18 06:06:42 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
2b4ce79ea5 GRIM: Fix failed assertion on font rendering with TinyGL
Commit: 2b4ce79ea501c57e3562dc0a075c23de3472580c
https://github.com/scummvm/scummvm/commit/2b4ce79ea501c57e3562dc0a075c23de3472580c
Author: Orgad Shaneh (orgads at gmail.com)
Date: 2025-05-18T09:06:37+03:00
Commit Message:
GRIM: Fix failed assertion on font rendering with TinyGL
Opening the menu (F1) in a debug build triggers a crash due to an
assertion failure in surface.h:
assert(x >= 0 && x < w && y >= 0 && y < h).
This problem occurs because setPixel is called with x equal to w.
It's especially noticeable when rendering a single "Q" character,
where the kerned width is 12, but the bitmap width is 14 pixels.
getBitmapStringLength returns the sum of character advance widths
Kerning applies to spacing between glyphs not bitmap widths.
Since no subsequent glyph follows the final character, kerning is
unused. Therefore the final character's bitmap width must be used
This prevents setPixel from receiving x coordinates equal to w.
Changed paths:
engines/grim/font.cpp
diff --git a/engines/grim/font.cpp b/engines/grim/font.cpp
index ce81ced03a2..cfd1a875f57 100644
--- a/engines/grim/font.cpp
+++ b/engines/grim/font.cpp
@@ -300,9 +300,11 @@ int BitmapFont::getKernedStringLength(const Common::String &text) const {
int BitmapFont::getBitmapStringLength(const Common::String &text) const {
int result = 0;
- for (uint32 i = 0; i < text.size(); ) {
- uint32 ch = getNextChar(text, i);
- result += getCharKernedWidth(ch) + getCharStartingCol(ch);
+ const uint size = text.size();
+ for (uint32 i = 0; i < size; ) {
+ const uint32 ch = getNextChar(text, i);
+ result += getCharStartingCol(ch);
+ result += (i >= size) ? getCharBitmapWidth(ch) : getCharKernedWidth(ch);
}
return result;
}
More information about the Scummvm-git-logs
mailing list