[Scummvm-git-logs] scummvm master -> 9e2bb1ae3fe6fe60c830f1c93a49bef6287f9307
djsrv
dservilla at gmail.com
Tue Jul 6 20:47:16 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e9d9b9f569 DIRECTOR: Revert FXmp handling
a2848f5dba DIRECTOR: Handle FXmp mappings in loadFontMapV4
f64e941eef DIRECTOR: Add comment about ignored char mapings
9e2bb1ae3f DIRECTOR: Remove mapFont
Commit: e9d9b9f5697e41e164546468664a72323f5474e9
https://github.com/scummvm/scummvm/commit/e9d9b9f5697e41e164546468664a72323f5474e9
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-06T16:47:20-04:00
Commit Message:
DIRECTOR: Revert FXmp handling
This reverts commit 4dabee7e8b26a6fd170e27ff6dd4bfdf67faec67.
This reverts commit 3fda461d5f961f6d9ae347a39767dbfa70c54e82.
This reverts commit 831c014f9eb4205b47c815c5598d30c94de551d0.
This reverts commit b3b55e59e9ce4caab668b58e4173a8dd102b9c54.
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/castmember.cpp
engines/director/fonts.cpp
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 25e7fb5ed6..bb53e8008f 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -102,7 +102,10 @@ Cast::~Cast() {
for (Common::HashMap<uint16, CastMemberInfo *>::iterator it = _castsInfo.begin(); it != _castsInfo.end(); ++it)
delete it->_value;
- for (Graphics::FontXPlatformMap::iterator it = _fontXPlatformMap.begin(); it != _fontXPlatformMap.end(); ++it)
+ for (FontXPlatformMap::iterator it = _macFontsToWin.begin(); it != _macFontsToWin.end(); ++it)
+ delete it->_value;
+
+ for (FontXPlatformMap::iterator it = _winFontsToMac.begin(); it != _winFontsToMac.end(); ++it)
delete it->_value;
delete _loadedStxts;
diff --git a/engines/director/cast.h b/engines/director/cast.h
index d692558f9f..32236bbf90 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -31,12 +31,6 @@ namespace Common {
class SeekableReadStreamEndian;
}
-namespace Graphics {
- struct FontXPlatformInfo;
- typedef Common::HashMap<byte, byte> CharMap;
- typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
-}
-
namespace Director {
class Archive;
@@ -52,6 +46,15 @@ class ScriptCastMember;
class ShapeCastMember;
class TextCastMember;
+typedef Common::HashMap<byte, byte> CharMap;
+typedef Common::HashMap<uint16, uint16> FontSizeMap;
+struct FontXPlatformInfo {
+ Common::String toFont;
+ bool remapChars;
+ FontSizeMap sizeMap;
+};
+typedef Common::HashMap<Common::String, FontXPlatformInfo *> FontXPlatformMap;
+
class Cast {
public:
Cast(Movie *movie, uint16 castLibID, bool shared = false);
@@ -101,8 +104,10 @@ public:
uint16 _castLibID;
Common::HashMap<uint16, uint16> _fontMap;
- Graphics::CharMap _charMap;
- Graphics::FontXPlatformMap _fontXPlatformMap;
+ CharMap _macCharsToWin;
+ CharMap _winCharsToMac;
+ FontXPlatformMap _macFontsToWin;
+ FontXPlatformMap _winFontsToMac;
Common::HashMap<int, CastMember *> *_loadedCast;
Common::HashMap<int, const Stxt *> *_loadedStxts;
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 2deba1142b..68ec6ec93c 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -701,7 +701,7 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
dims.right = MIN<int>(dims.right, dims.left + _initialRect.width());
dims.bottom = MIN<int>(dims.bottom, dims.top + _initialRect.height());
}
- widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed, &_cast->_charMap, &_cast->_fontXPlatformMap);
+ widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed);
((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
((Graphics::MacText *)widget)->setEditable(_editable);
((Graphics::MacText *)widget)->draw();
diff --git a/engines/director/fonts.cpp b/engines/director/fonts.cpp
index f18c4dbee4..8b43de1363 100644
--- a/engines/director/fonts.cpp
+++ b/engines/director/fonts.cpp
@@ -276,11 +276,9 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
Common::String fromFont;
- uint16 fromFontId;
tok = readFXmpToken(stream);
if (tok.type == FXMP_TOKEN_WORD || tok.type == FXMP_TOKEN_STRING) {
fromFont = tok.str;
- fromFontId = _vm->_wm->_fontMan->registerFontName(fromFont);
tok = readFXmpToken(stream);
}
@@ -334,10 +332,11 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
byte toChar = atoi(tok.str.c_str());
- // TODO: We should fill _charMap with mappings matching the current platform.
- // We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
- if (fromPlatform == Common::kPlatformWindows) {
- _charMap[fromChar] = toChar;
+ if (fromPlatform == Common::kPlatformMacintosh) {
+ _macCharsToWin[fromChar] = toChar;
+ debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac char %d to Win char %d", fromChar, toChar);
+ } else {
+ _winCharsToMac[fromChar] = toChar;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win char %d to Mac char %d", fromChar, toChar);
}
@@ -345,7 +344,7 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
} else {
// font mapping
- Graphics::FontXPlatformInfo *info = new Graphics::FontXPlatformInfo;
+ FontXPlatformInfo *info = new FontXPlatformInfo;
// to font
tok = readFXmpToken(stream);
@@ -354,9 +353,7 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
delete info;
return false;
}
- Common::String toFont = tok.str;
- uint16 toFontId = _vm->_wm->_fontMan->registerFontName(toFont);
- info->toFont = toFontId;
+ info->toFont = tok.str;
tok = readFXmpToken(stream);
@@ -412,17 +409,16 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
tok = readFXmpToken(stream);
}
- // TODO: We should fill _fontXPlatformMap with mappings matching the current platform.
- // We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
- if (fromPlatform == Common::kPlatformWindows) {
- _fontXPlatformMap[fromFontId] = info;
- debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' (%d) to Mac font '%s' (%d)", fromFont.c_str(), fromFontId, toFont.c_str(), toFontId);
- debugC(4, kDebugLoading, " Remap characters: %d", info->remapChars);
- for (Graphics::FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
- debugC(4, kDebugLoading, " Mapping size %d to %d", it->_key, it->_value);
- }
+ if (fromPlatform == Common::kPlatformMacintosh) {
+ _macFontsToWin[fromFont] = info;
+ debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac font '%s' to Win font '%s'", fromFont.c_str(), info->toFont.c_str());
} else {
- delete info;
+ _winFontsToMac[fromFont] = info;
+ debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' to Mac font '%s'", fromFont.c_str(), info->toFont.c_str());
+ }
+ debugC(4, kDebugLoading, " Remap characters: %d", info->remapChars);
+ for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
+ debugC(4, kDebugLoading, " Mapping size %d to %d", it->_key, it->_value);
}
}
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 504a5cd248..f8a827aa3b 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -313,30 +313,20 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
}
}
-const Font *MacFontManager::getFont(MacFont macFont, FontXPlatformMap *fontXPlatformMap) {
- int id = macFont.getId();
- int size = macFont.getSize();
- if (fontXPlatformMap && fontXPlatformMap->contains(id)) {
- FontXPlatformInfo *info = (*fontXPlatformMap)[id];
- id = info->toFont;
- if (info->sizeMap.contains(size)) {
- size = info->sizeMap[size];
- }
- }
-
+const Font *MacFontManager::getFont(MacFont macFont) {
Common::String name;
const Font *font = 0;
if (!_builtInFonts) {
if (macFont.getName().empty()) {
- name = getFontName(id, size, macFont.getSlant());
+ name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant());
macFont.setName(name);
}
if (!_fontRegistry.contains(macFont.getName())) {
// Let's try to generate name
if (macFont.getSlant() != kMacFontRegular) {
- name = getFontName(id, size, macFont.getSlant(), true);
+ name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true);
macFont.setName(name);
}
@@ -356,16 +346,16 @@ const Font *MacFontManager::getFont(MacFont macFont, FontXPlatformMap *fontXPlat
#ifdef USE_FREETYPE2
if (!font) {
if (_mode & kWMModeUnicode) {
- if (size <= 0) {
+ if (macFont.getSize() <= 0) {
debug(1, "MacFontManager::getFont() - Font size <= 0!");
}
- Common::HashMap<int, const Graphics::Font *>::iterator pFont = _uniFonts.find(size);
+ Common::HashMap<int, const Graphics::Font *>::iterator pFont = _uniFonts.find(macFont.getSize());
if (pFont != _uniFonts.end()) {
font = pFont->_value;
} else {
- font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", size, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
- _uniFonts[size] = font;
+ font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", macFont.getSize(), Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
+ _uniFonts[macFont.getSize()] = font;
}
}
}
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 21976175ec..0eac4ee4f0 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -66,15 +66,6 @@ enum {
class Font;
-typedef Common::HashMap<byte, byte> CharMap;
-typedef Common::HashMap<uint16, uint16> FontSizeMap;
-struct FontXPlatformInfo {
- uint16 toFont;
- bool remapChars;
- FontSizeMap sizeMap;
-};
-typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
-
class MacFont {
public:
MacFont(int id = kMacFontChicago, int size = 12, int slant = kMacFontRegular, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
@@ -126,10 +117,9 @@ public:
* Retrieve a font from the available ones.
* @param name Name of the desired font.
* @param fallback Fallback policy in case the desired font isn't there.
- * @param fontXPlatformMap an optional map from Windows fonts to Mac fonts or vice versa
* @return The requested font or the fallback.
*/
- const Font *getFont(MacFont macFont, FontXPlatformMap *fontXPlatformMap = nullptr);
+ const Font *getFont(MacFont macFont);
/**
* Return font name from standard ID
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 84bce45a83..98e382cdab 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -56,7 +56,7 @@ const Font *MacFontRun::getFont() {
MacFont macFont = MacFont(fontId, fontSize, textSlant);
- font = wm->_fontMan->getFont(macFont, parent->_fontXPlatformMap);
+ font = wm->_fontMan->getFont(macFont);
return font;
}
@@ -94,7 +94,7 @@ uint MacTextLine::getChunkNum(int *col) {
}
-MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, bool fixedDims, CharMap *charMap, FontXPlatformMap *fontXPlatformMap) :
+MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, bool fixedDims) :
MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
@@ -110,12 +110,9 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_encodeType = Common::kUtf8;
_plainByteMode = false;
- _charMap = charMap;
- _fontXPlatformMap = fontXPlatformMap;
-
if (macFont) {
- _defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
- _defaultFormatting.font = wm->_fontMan->getFont(*macFont, _fontXPlatformMap);
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
+ _defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
}
@@ -123,7 +120,7 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
init();
}
-MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType, bool fixedDims, CharMap *charMap, FontXPlatformMap *fontXPlatformMap) :
+MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType, bool fixedDims) :
MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
@@ -138,12 +135,9 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_encodeType = encodeType;
_plainByteMode = true;
- _charMap = charMap;
- _fontXPlatformMap = fontXPlatformMap;
-
if (macFont) {
- _defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
- _defaultFormatting.font = wm->_fontMan->getFont(*macFont, _fontXPlatformMap);
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
+ _defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
}
@@ -167,12 +161,9 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
_encodeType = Common::kUtf8;
_plainByteMode = false;
- _charMap = nullptr;
- _fontXPlatformMap = nullptr;
-
if (macFont) {
- _defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
- _defaultFormatting.font = wm->_fontMan->getFont(*macFont, _fontXPlatformMap);
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
+ _defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
}
@@ -195,12 +186,9 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
_encodeType = encodeType;
_plainByteMode = true;
- _charMap = nullptr;
- _fontXPlatformMap = nullptr;
-
if (macFont) {
- _defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
- _defaultFormatting.font = wm->_fontMan->getFont(*macFont, _fontXPlatformMap);
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
+ _defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
}
@@ -224,11 +212,8 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const Font *f
_encodeType = Common::kUtf8;
_plainByteMode = false;
- _charMap = nullptr;
- _fontXPlatformMap = nullptr;
-
if (font) {
- _defaultFormatting = MacFontRun(this, _wm, font, 0, font->getFontHeight(), 0, 0, 0);
+ _defaultFormatting = MacFontRun(_wm, font, 0, font->getFontHeight(), 0, 0, 0);
_defaultFormatting.font = font;
} else {
_defaultFormatting.font = NULL;
@@ -458,11 +443,11 @@ void MacText::setTextColor(uint32 color, uint32 start, uint32 end) {
void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSize,
uint16 palinfo1, uint16 palinfo2, uint16 palinfo3) {
- _defaultFormatting.setValues(this, _defaultFormatting.wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+ _defaultFormatting.setValues(_defaultFormatting.wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
MacFont macFont = MacFont(fontId, fontSize, textSlant);
- _defaultFormatting.font = _wm->_fontMan->getFont(macFont, _fontXPlatformMap);
+ _defaultFormatting.font = _wm->_fontMan->getFont(macFont);
}
static const Common::U32String::value_type *readHex(uint16 *res, const Common::U32String::value_type *s, int len) {
@@ -627,7 +612,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
D(9, "** splitString: fontId: %d, textSlant: %d, fontSize: %d, p0: %x p1: %x p2: %x",
fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
- current_format.setValues(this, _wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+ current_format.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
if (!_macFontMode)
current_format.font = _defaultFormatting.font;
@@ -646,7 +631,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
D(9, "** splitString: fontId: %d, textSlant: %d, fontSize: %d, p0: %x p1: %x p2: %x",
fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
- current_format.setValues(this, _wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+ current_format.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
// So far, we enforce single font here, though in the future, font size could be altered
if (!_macFontMode)
@@ -1083,7 +1068,7 @@ void MacText::appendText(const Common::U32String &str, int fontId, int fontSize,
void MacText::appendText(const Common::U32String &str, int fontId, int fontSize, int fontSlant, uint16 r, uint16 g, uint16 b, bool skipAdd) {
uint oldLen = _textLines.size();
- MacFontRun fontRun = MacFontRun(this, _wm, fontId, fontSlant, fontSize, r, g, b);
+ MacFontRun fontRun = MacFontRun(_wm, fontId, fontSlant, fontSize, r, g, b);
_currentFormatting = fontRun;
@@ -1109,7 +1094,7 @@ void MacText::appendText(const Common::U32String &str, int fontId, int fontSize,
void MacText::appendText(const Common::U32String &str, const Font *font, uint16 r, uint16 g, uint16 b, bool skipAdd) {
uint oldLen = _textLines.size();
- MacFontRun fontRun = MacFontRun(this, _wm, font, 0, font->getFontHeight(), r, g, b);
+ MacFontRun fontRun = MacFontRun(_wm, font, 0, font->getFontHeight(), r, g, b);
_currentFormatting = fontRun;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index e92c998294..ee5dd133d6 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -39,10 +39,6 @@ class MacText;
class MacWidget;
class MacWindow;
class MacWindowManager;
-struct FontXPlatformInfo;
-
-typedef Common::HashMap<byte, byte> CharMap;
-typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
struct MacFontRun {
Common::U32String text;
@@ -57,11 +53,9 @@ struct MacFontRun {
// to determine whether the next word is part of this one
bool wordContinuation;
const Font *font;
- MacText *parent;
MacWindowManager *wm;
MacFontRun() {
- parent = nullptr;
wm = nullptr;
fontId = textSlant = fontSize = 0;
palinfo1 = palinfo2 = palinfo3 = 0;
@@ -70,22 +64,21 @@ struct MacFontRun {
wordContinuation = false;
}
- MacFontRun(MacText *parent_, MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
+ MacFontRun(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
- setValues(parent_, wm_, fontId_, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
+ setValues(wm_, fontId_, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
wordContinuation = false;
}
- MacFontRun(MacText *parent_, MacWindowManager *wm_, const Font *font_, byte textSlant_, uint16 fontSize_,
+ MacFontRun(MacWindowManager *wm_, const Font *font_, byte textSlant_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
- setValues(parent_, wm_, 0, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
+ setValues(wm_, 0, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
font = font_;
wordContinuation = false;
}
- void setValues(MacText *parent_, MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
+ void setValues(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
- parent = parent_;
wm = wm_;
fontId = fontId_;
textSlant = textSlant_;
@@ -152,8 +145,8 @@ struct SelectedText {
class MacText : public MacWidget {
public:
- MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, bool fixedDims = true, CharMap *charMap = nullptr, FontXPlatformMap *fontXPlatformMap = nullptr);
- MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true, CharMap *charMap = nullptr, FontXPlatformMap *fontXPlatformMap = nullptr);
+ MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, bool fixedDims = true);
+ MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true);
// 0 pixels between the lines by default
MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, bool fixedDims = true);
@@ -304,9 +297,6 @@ public:
bool _fullRefresh;
- CharMap *_charMap;
- FontXPlatformMap *_fontXPlatformMap;
-
protected:
Common::U32String _str;
const MacFont *_macFont;
Commit: a2848f5dba0dad973807a8e3d873e7bbdd10cfaa
https://github.com/scummvm/scummvm/commit/a2848f5dba0dad973807a8e3d873e7bbdd10cfaa
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-06T16:47:20-04:00
Commit Message:
DIRECTOR: Handle FXmp mappings in loadFontMapV4
The previous way I handled the FXmp mappings overcomplicated MacText.
It also resulted in behavior different from the original Director. With
the previous implementation, if a Win movie with Arial text was opened
with the platform set to Mac, the textFont of field 1 would return
Arial, while it would return the mapped font name Helvetica in the
original. This implementation's behavior should match the original.
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/fonts.cpp
engines/director/stxt.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index bb53e8008f..2fbf7e63a8 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -102,10 +102,10 @@ Cast::~Cast() {
for (Common::HashMap<uint16, CastMemberInfo *>::iterator it = _castsInfo.begin(); it != _castsInfo.end(); ++it)
delete it->_value;
- for (FontXPlatformMap::iterator it = _macFontsToWin.begin(); it != _macFontsToWin.end(); ++it)
+ for (FontXPlatformMap::iterator it = _fontXPlatformMap.begin(); it != _fontXPlatformMap.end(); ++it)
delete it->_value;
- for (FontXPlatformMap::iterator it = _winFontsToMac.begin(); it != _winFontsToMac.end(); ++it)
+ for (FontMap::iterator it = _fontMap.begin(); it != _fontMap.end(); ++it)
delete it->_value;
delete _loadedStxts;
@@ -339,18 +339,18 @@ void Cast::loadCast() {
delete r;
}
- // Font Mapping V4
- if (_castArchive->hasResource(MKTAG('F', 'm', 'a', 'p'), -1)) {
- loadFontMapV4(*(r = _castArchive->getFirstResource(MKTAG('F', 'm', 'a', 'p'))));
- delete r;
- }
-
// Cross-Platform Font Mapping
if (_castArchive->hasResource(MKTAG('F', 'X', 'm', 'p'), -1)) {
loadFXmp(*(r = _castArchive->getFirstResource(MKTAG('F', 'X', 'm', 'p'))));
delete r;
}
+ // Font Mapping V4
+ if (_castArchive->hasResource(MKTAG('F', 'm', 'a', 'p'), -1)) {
+ loadFontMapV4(*(r = _castArchive->getFirstResource(MKTAG('F', 'm', 'a', 'p'))));
+ delete r;
+ }
+
// Pattern Tiles
if (_castArchive->hasResource(MKTAG('V', 'W', 'T', 'L'), -1)) {
debug("STUB: Unhandled VWTL resource.");
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 32236bbf90..52c454e31b 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -52,9 +52,20 @@ struct FontXPlatformInfo {
Common::String toFont;
bool remapChars;
FontSizeMap sizeMap;
+
+ FontXPlatformInfo() : remapChars(false) {}
};
typedef Common::HashMap<Common::String, FontXPlatformInfo *> FontXPlatformMap;
+struct FontInfo {
+ uint16 toFont;
+ bool remapChars;
+ FontSizeMap sizeMap;
+
+ FontInfo() : remapChars(false) {}
+};
+typedef Common::HashMap<uint16, FontInfo *> FontMap;
+
class Cast {
public:
Cast(Movie *movie, uint16 castLibID, bool shared = false);
@@ -103,11 +114,9 @@ public:
uint16 _version;
uint16 _castLibID;
- Common::HashMap<uint16, uint16> _fontMap;
- CharMap _macCharsToWin;
- CharMap _winCharsToMac;
- FontXPlatformMap _macFontsToWin;
- FontXPlatformMap _winFontsToMac;
+ CharMap _charMap;
+ FontXPlatformMap _fontXPlatformMap;
+ FontMap _fontMap;
Common::HashMap<int, CastMember *> *_loadedCast;
Common::HashMap<int, const Stxt *> *_loadedStxts;
diff --git a/engines/director/fonts.cpp b/engines/director/fonts.cpp
index 8b43de1363..9f96ad5f03 100644
--- a/engines/director/fonts.cpp
+++ b/engines/director/fonts.cpp
@@ -32,7 +32,7 @@ namespace Director {
uint16 Cast::mapFont(uint16 id) {
if (_fontMap.contains(id)) {
- return _fontMap[id];
+ return _fontMap[id]->toFont;
}
return id;
}
@@ -61,9 +61,11 @@ void Cast::loadFontMap(Common::SeekableReadStreamEndian &stream) {
}
// Map cast font ID to window manager font ID
- _fontMap[id] = _vm->_wm->_fontMan->registerFontName(font);
+ FontInfo *info = new FontInfo;
+ info->toFont = _vm->_wm->_fontMan->registerFontName(font);
+ _fontMap[id] = info;
- debugC(3, kDebugLoading, "Cast::loadFontMap: Mapping font %d (%s) to %d", id, font.c_str(), _fontMap[id]);
+ debugC(3, kDebugLoading, "Cast::loadFontMap: Mapping font %d (%s) to %d", id, font.c_str(), _fontMap[id]->toFont);
currentRawPosition = stream.pos();
stream.seek(positionInfo);
}
@@ -112,9 +114,18 @@ void Cast::loadFontMapV4(Common::SeekableReadStreamEndian &stream) {
}
// Map cast font ID to window manager font ID
- _fontMap[id] = _vm->_wm->_fontMan->registerFontName(name);
+ FontInfo *info = new FontInfo;
+ if (platform == 2 && _fontXPlatformMap.contains(name)) {
+ FontXPlatformInfo *xinfo = _fontXPlatformMap[name];
+ info->toFont = _vm->_wm->_fontMan->registerFontName(xinfo->toFont);
+ info->remapChars = xinfo->remapChars;
+ info->sizeMap = xinfo->sizeMap;
+ } else {
+ info->toFont = _vm->_wm->_fontMan->registerFontName(name);
+ }
+ _fontMap[id] = info;
- debugC(3, kDebugLoading, "Cast::loadFontMapV4: Mapping %s font %d (%s) to %d", platformName.c_str(), id, name.c_str(), _fontMap[id]);
+ debugC(3, kDebugLoading, "Cast::loadFontMapV4: Mapping %s font %d (%s) to %d", platformName.c_str(), id, name.c_str(), _fontMap[id]->toFont);
}
}
@@ -332,11 +343,10 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
byte toChar = atoi(tok.str.c_str());
- if (fromPlatform == Common::kPlatformMacintosh) {
- _macCharsToWin[fromChar] = toChar;
- debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac char %d to Win char %d", fromChar, toChar);
- } else {
- _winCharsToMac[fromChar] = toChar;
+ // TODO: We should fill _charMap with mappings matching the current platform.
+ // We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
+ if (fromPlatform == Common::kPlatformWindows) {
+ _charMap[fromChar] = toChar;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win char %d to Mac char %d", fromChar, toChar);
}
@@ -409,16 +419,17 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
tok = readFXmpToken(stream);
}
- if (fromPlatform == Common::kPlatformMacintosh) {
- _macFontsToWin[fromFont] = info;
- debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac font '%s' to Win font '%s'", fromFont.c_str(), info->toFont.c_str());
- } else {
- _winFontsToMac[fromFont] = info;
+ // TODO: We should fill _fontXPlatformMap with mappings matching the current platform.
+ // We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
+ if (fromPlatform == Common::kPlatformWindows) {
+ _fontXPlatformMap[fromFont] = info;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' to Mac font '%s'", fromFont.c_str(), info->toFont.c_str());
- }
- debugC(4, kDebugLoading, " Remap characters: %d", info->remapChars);
- for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
- debugC(4, kDebugLoading, " Mapping size %d to %d", it->_key, it->_value);
+ debugC(4, kDebugLoading, " Remap characters: %d", info->remapChars);
+ for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
+ debugC(4, kDebugLoading, " Mapping size %d to %d", it->_key, it->_value);
+ }
+ } else {
+ delete info;
}
}
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index 48f9cadca2..1d9e6dfa68 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -113,10 +113,10 @@ FontStyle::FontStyle() {
void FontStyle::read(Common::ReadStreamEndian &stream, Cast *cast) {
formatStartOffset = stream.readUint32();
- height = stream.readUint16();
+ uint16 originalHeight = height = stream.readUint16();
ascent = stream.readUint16();
- fontId = cast->mapFont(stream.readUint16());
+ uint16 originalFontId = fontId = stream.readUint16();
textSlant = stream.readByte();
stream.readByte(); // padding
fontSize = stream.readUint16();
@@ -125,8 +125,16 @@ void FontStyle::read(Common::ReadStreamEndian &stream, Cast *cast) {
g = stream.readUint16();
b = stream.readUint16();
- debugC(3, kDebugLoading, "FontStyle::read(): formatStartOffset: %d, height: %d ascent: %d, fontId: %d, textSlant: %d, fontSize: %d, r: %x g: %x b: %x",
- formatStartOffset, height, ascent, fontId, textSlant, fontSize, r, g, b);
+ if (cast->_fontMap.contains(originalFontId)) {
+ FontInfo *info = cast->_fontMap[originalFontId];
+ fontId = info->toFont;
+ if (info->sizeMap.contains(originalHeight)) {
+ height = info->sizeMap[height];
+ }
+ }
+
+ debugC(3, kDebugLoading, "FontStyle::read(): formatStartOffset: %d, height: %d -> %d ascent: %d, fontId: %d -> %d, textSlant: %d, fontSize: %d, r: %x g: %x b: %x",
+ formatStartOffset, originalHeight, height, ascent, originalFontId, fontId, textSlant, fontSize, r, g, b);
}
} // End of namespace Director
Commit: f64e941eefc8fb7bd8b044a841324f3bc214a585
https://github.com/scummvm/scummvm/commit/f64e941eefc8fb7bd8b044a841324f3bc214a585
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-06T16:47:20-04:00
Commit Message:
DIRECTOR: Add comment about ignored char mapings
Changed paths:
engines/director/stxt.cpp
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index 1d9e6dfa68..bef7e6e1ae 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -74,6 +74,10 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
assert(prevPos <= _style.formatStartOffset); // If this is triggered, we have to implement sorting
while (prevPos != _style.formatStartOffset) {
+ // We should theoretically handle the cross-platform character mappings stored in _cast->_charMap here.
+ // However, Director 4 seems to ignore these mappings despite storing them.
+ // Maybe they're handled in a later version?
+
char f = text.firstChar();
_ftext += text.firstChar();
text.deleteChar(0);
Commit: 9e2bb1ae3fe6fe60c830f1c93a49bef6287f9307
https://github.com/scummvm/scummvm/commit/9e2bb1ae3fe6fe60c830f1c93a49bef6287f9307
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-06T16:47:20-04:00
Commit Message:
DIRECTOR: Remove mapFont
This is no longer used.
Changed paths:
engines/director/cast.h
engines/director/fonts.cpp
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 52c454e31b..37c3e014fb 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -98,8 +98,6 @@ public:
void dumpScript(const char *script, ScriptType type, uint16 id);
- uint16 mapFont(uint16 id);
-
private:
PaletteV4 loadPalette(Common::SeekableReadStreamEndian &stream);
void loadScriptText(Common::SeekableReadStreamEndian &stream, uint16 id);
diff --git a/engines/director/fonts.cpp b/engines/director/fonts.cpp
index 9f96ad5f03..bc92b789ed 100644
--- a/engines/director/fonts.cpp
+++ b/engines/director/fonts.cpp
@@ -30,13 +30,6 @@
namespace Director {
-uint16 Cast::mapFont(uint16 id) {
- if (_fontMap.contains(id)) {
- return _fontMap[id]->toFont;
- }
- return id;
-}
-
void Cast::loadFontMap(Common::SeekableReadStreamEndian &stream) {
if (stream.size() == 0)
return;
More information about the Scummvm-git-logs
mailing list