[Scummvm-git-logs] scummvm master -> 1c7b6fbb8c9add8593c407fa5e278206efc2f862
mgerhardy
noreply at scummvm.org
Sat Oct 10 06:46:35 UTC 2026
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
3823846082 MACS2: use findGlyph for lookup
2fd988d767 MACS2: tried to unify measureString
1c7b6fbb8c MACS2: added swedish fallback glyphs
Commit: 38238460823b77dfa93a0fb203dd4ae2f0867f54
https://github.com/scummvm/scummvm/commit/38238460823b77dfa93a0fb203dd4ae2f0867f54
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-10-10T08:45:01+02:00
Commit Message:
MACS2: use findGlyph for lookup
Changed paths:
engines/macs2/view1.cpp
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index b18f174b0d0..e64bc06a682 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -830,16 +830,11 @@ void View1::renderStringWithFontTo(uint16 x, uint16 y, const Common::String &s,
widestGlyph = MAX(widestGlyph, glyphs[i]._width);
}
for (auto iter = s.begin(); iter != s.end(); iter++) {
- bool found = false;
- for (uint i = 0; i < numGlyphs; i++) {
- if (glyphs[i]._ascii == *iter) {
- drawSprite(currentX, y, glyphs[i], surf, false);
- currentX += glyphs[i]._width + 1;
- found = true;
- break;
- }
- }
- if (!found) {
+ GlyphData glyph;
+ if (g_engine->_text.findGlyph(*iter, glyph, glyphs, numGlyphs)) {
+ drawSprite(currentX, y, glyph, surf, false);
+ currentX += glyph._width + 1;
+ } else {
currentX += widestGlyph;
}
}
Commit: 2fd988d76745eb903b5244f47ee53cf3d8942d76
https://github.com/scummvm/scummvm/commit/2fd988d76745eb903b5244f47ee53cf3d8942d76
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-10-10T08:45:01+02:00
Commit Message:
MACS2: tried to unify measureString
Changed paths:
engines/macs2/text.cpp
diff --git a/engines/macs2/text.cpp b/engines/macs2/text.cpp
index 24fae48ba48..aa2e3ce7d87 100644
--- a/engines/macs2/text.cpp
+++ b/engines/macs2/text.cpp
@@ -55,7 +55,7 @@ bool Text::findGlyph(char c, GlyphData &out) const {
}
int Text::measureString(const Common::String &s) const {
- int sum = 0;
+ int width = 0;
GlyphData currentGlyph;
uint16 widestGlyph = 0;
for (auto current = s.begin(); current != s.end(); current++) {
@@ -65,13 +65,13 @@ int Text::measureString(const Common::String &s) const {
}
for (auto current = s.begin(); current != s.end(); current++) {
- if (!findGlyph(*current, currentGlyph)) {
- sum += widestGlyph;
+ if (findGlyph(*current, currentGlyph)) {
+ width += currentGlyph._width + 1;
} else {
- sum += currentGlyph._width + 1;
+ width += widestGlyph;
}
}
- return sum;
+ return width;
}
int Text::measureString(const Common::String &s, const GlyphData *glyphs, uint16 numGlyphs) const {
@@ -80,10 +80,10 @@ int Text::measureString(const Common::String &s, const GlyphData *glyphs, uint16
for (uint i = 0; i < numGlyphs; i++) {
widestGlyph = MAX(widestGlyph, glyphs[i]._width);
}
- for (auto iter = s.begin(); iter != s.end(); iter++) {
- GlyphData glyph;
- if (findGlyph(*iter, glyph, glyphs, numGlyphs)) {
- width += glyph._width + 1;
+ for (auto current = s.begin(); current != s.end(); current++) {
+ GlyphData currentGlyph;
+ if (findGlyph(*current, currentGlyph, glyphs, numGlyphs)) {
+ width += currentGlyph._width + 1;
} else {
width += widestGlyph;
}
Commit: 1c7b6fbb8c9add8593c407fa5e278206efc2f862
https://github.com/scummvm/scummvm/commit/1c7b6fbb8c9add8593c407fa5e278206efc2f862
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-10-10T08:46:10+02:00
Commit Message:
MACS2: added swedish fallback glyphs
there is a new swedish translation and this should hopefully support all the missing glphys
Changed paths:
engines/macs2/macs2.cpp
engines/macs2/text.cpp
engines/macs2/text.h
diff --git a/engines/macs2/macs2.cpp b/engines/macs2/macs2.cpp
index 00b054019a1..e91fcdcfad7 100644
--- a/engines/macs2/macs2.cpp
+++ b/engines/macs2/macs2.cpp
@@ -230,6 +230,7 @@ void Macs2Engine::loadResourceFileV1() {
_text._maxGlyphHeight = MAX(_text._glyphs[i]._height, _text._maxGlyphHeight);
}
_text._numGlyphs = font1GlyphCount;
+ _text.addDialogueFontFallbacks();
// Font 2: clean sans-serif font used by save/load panel (scene data offset 0x1044)
uint32 font2SizeField = _fileStream->readUint32LE();
@@ -1970,6 +1971,8 @@ bool Macs2Engine::loadOverlayFont(uint8 resourceIndex, uint16 executingObjectID)
_text._overlayGlyphs[i].readFromMemory(_fileStream);
_text.maxOverlayGlyphHeight = MAX(_text.maxOverlayGlyphHeight, _text._overlayGlyphs[i]._height);
}
+ if (isV1())
+ _text.addIntroFontFallbacks();
_fileStream->seek(oldPos, SEEK_SET);
return true;
}
diff --git a/engines/macs2/text.cpp b/engines/macs2/text.cpp
index aa2e3ce7d87..5d44376083f 100644
--- a/engines/macs2/text.cpp
+++ b/engines/macs2/text.cpp
@@ -47,9 +47,139 @@ bool Text::findGlyph(char c, GlyphData &out, const GlyphData *glyphs, uint16 num
return true;
}
}
+
return false;
}
+void Text::addDialogueFontFallbacks() {
+ // Swedish CP850 characters missing from the original DOS dialogue font.
+ // Match its transparent/outline/foreground palette entries and cell
+ // dimensions to preserve text alignment and line spacing.
+ static const struct {
+ byte character;
+ char baseCharacter;
+ uint16 height;
+ const char *pixels;
+ } svFallbackGlyphs[] = {
+ { 0x86, 'a', 14, // a with ring above
+ "..####.."
+ ".#X##X#."
+ "..#XX#.."
+ "...##..."
+ "...###.."
+ "..#XXX#."
+ ".#XX#XX#"
+ "#XX##XX#"
+ "#XX##XX#"
+ "#XX##XX#"
+ "#XX#XXX#"
+ "##XXX#X#"
+ ".#######"
+ "..###.#." },
+ { 0x8f, 'A', 13, // A with ring above
+ "..####.."
+ ".#X##X#."
+ "..#XX#.."
+ "..#XXXX#"
+ ".#XX#XX#"
+ "##X##XX#"
+ "#XXXXXX#"
+ "#XXXXXX#"
+ "#XX##XX#"
+ "#XX##XX#"
+ "#XX##XX#"
+ "########"
+ ".##..##." }
+ };
+ for (const auto &fallback : svFallbackGlyphs) {
+ GlyphData existing;
+ if (_numGlyphs >= kMaxGlyphs || findGlyph((char)fallback.character, existing))
+ continue;
+ // Only supplement the matching DOS font style.
+ GlyphData base;
+ if (!findGlyph(fallback.baseCharacter, base) || base._width != 8 || base._height != fallback.height)
+ continue;
+ GlyphData &glyph = _glyphs[_numGlyphs++];
+ glyph._ascii = fallback.character;
+ glyph._width = 8;
+ glyph._height = fallback.height;
+ glyph._data.resize(8 * fallback.height);
+ for (uint j = 0; j < glyph._data.size(); j++) {
+ const char pixel = fallback.pixels[j];
+ glyph._data[j] = pixel == 'X' ? 255 : pixel == '#' ? 224 : 0;
+ }
+ _maxGlyphHeight = MAX(_maxGlyphHeight, glyph._height);
+ }
+}
+
+void Text::addIntroFontFallbacks() {
+ // Identify the DOS credits font once at load time. Resource indices are
+ // local to a scene/object; the other overlay font has 79 dialogue glyphs.
+ if (numOverlayGlyphs != 26)
+ return;
+
+ // only for the intro font - hacky - but does the job
+ // maybe it would be better to check the resource id - but i am not sure if this is the same for all supported versions
+ for (uint i = 0; i < 26; i++) {
+ const GlyphData &glyph = _overlayGlyphs[i];
+ if (glyph._ascii != (char)('A' + i) || glyph._width != 15 || glyph._height != 18)
+ return;
+ }
+
+ static const struct {
+ byte character;
+ char baseCharacter;
+ uint16 accentX;
+ const char *accent;
+ } svIntroFallbackGlyphs[] = {
+ { 0x8f, 'A', 1, ".###." "#L.R#" "#L.R#" ".###." }, // ring
+ { 0x8e, 'A', 0, "###.###" "#L#.#R#" "###.###" "......." },
+ { 0x99, 'O', 4, "###.###" "#L#.#R#" "###.###" "......." }
+ };
+ for (const auto &fallback : svIntroFallbackGlyphs) {
+ const GlyphData &base = _overlayGlyphs[fallback.baseCharacter - 'A'];
+ GlyphData &glyph = _overlayGlyphs[numOverlayGlyphs++];
+ glyph = base;
+ glyph._ascii = fallback.character;
+ Common::fill(glyph._data.begin(), glyph._data.end(), 0);
+ // Reserve four rows for the accent, keeping the original cell size
+ // and bottom row so overlay alignment and line spacing do not change.
+ for (uint y = 0; y < 14; y++) {
+ const uint sourceY = y * 17 / 13;
+ for (uint x = 0; x < 15; x++)
+ glyph._data[(y + 4) * 15 + x] = base._data[sourceY * 15 + x];
+ }
+ const uint accentWidth = fallback.character == 0x8f ? 5 : 7;
+ for (uint y = 0; y < 4; y++) {
+ for (uint x = 0; x < accentWidth; x++) {
+ const char pixel = fallback.accent[y * accentWidth + x];
+ glyph._data[y * 15 + fallback.accentX + x] =
+ pixel == '#' ? 224 : pixel == 'L' ? 196 : pixel == 'R' ? 198 : 0;
+ }
+ }
+ }
+
+ // Translated credits can use lowercase letters. This title font has
+ // only capitals, so provide aliases for A-Z and the three Swedish letters.
+ const uint16 capitalCount = numOverlayGlyphs;
+ for (uint16 i = 0; i < capitalCount; i++) {
+ const GlyphData &capital = _overlayGlyphs[i];
+ byte character = (byte)capital._ascii;
+ if (character >= 'A' && character <= 'Z')
+ character += 'a' - 'A';
+ else if (character == 0x8f)
+ character = 0x86;
+ else if (character == 0x8e)
+ character = 0x84;
+ else if (character == 0x99)
+ character = 0x94;
+ GlyphData &glyph = _overlayGlyphs[numOverlayGlyphs++];
+ assert(numOverlayGlyphs <= kMaxGlyphs);
+ glyph = capital;
+ glyph._ascii = character;
+ }
+}
+
bool Text::findGlyph(char c, GlyphData &out) const {
return findGlyph(c, out, _glyphs, _numGlyphs);
}
diff --git a/engines/macs2/text.h b/engines/macs2/text.h
index ffa76d64c90..81507850a6f 100644
--- a/engines/macs2/text.h
+++ b/engines/macs2/text.h
@@ -52,6 +52,9 @@ public:
uint16 maxPanelGlyphHeight = 0;
uint16 amigaTextLinePitch = 0;
+ void addDialogueFontFallbacks();
+ void addIntroFontFallbacks();
+
bool findGlyph(char c, GlyphData &out) const;
bool findGlyph(char c, GlyphData &out, const GlyphData *glyphs, uint16 numGlyphs) const;
More information about the Scummvm-git-logs
mailing list