[Scummvm-git-logs] scummvm master -> 5c17fe70b8f45e7ebc76170c52d17bcd0628dd22
sev-
noreply at scummvm.org
Sun Jul 17 11:04:18 UTC 2022
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:
94848be816 GRAPHICS: Set MacText->_defaultFormatting values after generating font
8cb2e1bb07 GRAPHICS: Add rectifyId to check for changed font IDs
c4f6aa89b9 GRAPHICS: Implement assigning of windows font, check for wrong fontId while loading stxt, read name from FON files DIREC
5c17fe70b8 JANITORIAL: Fix conventions and reimplement MacFontManager::rectifyId()
Commit: 94848be816512c42d51112b74a6e5698bd644502
https://github.com/scummvm/scummvm/commit/94848be816512c42d51112b74a6e5698bd644502
Author: Pragyansh Chaturvedi (pragyanshchaturvedi18 at gmail.com)
Date: 2022-07-17T13:04:14+02:00
Commit Message:
GRAPHICS: Set MacText->_defaultFormatting values after generating font
Changed paths:
graphics/macgui/macfontmanager.cpp
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 0eb6e01713e..b6447a13624 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -633,7 +633,7 @@ int MacFontManager::getFontAliasForId(uint16 id) {
Common::String MacFontManager::getFontName(uint16 id) {
if (!_fontInfo.contains(id)) {
- warning("MacFontManager::getFontAliasForId: No _fontInfo entry for font %d", id);
+ warning("MacFontManager::getFontName: No _fontInfo entry for font %d", id);
return "";
}
if (_fontInfo[id]->aliasForId > -1) {
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 99aa56ad5a0..2d4572d74aa 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -124,8 +124,9 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_macFontMode = true;
if (macFont) {
- _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
+ _defaultFormatting = MacFontRun(_wm);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
+ _defaultFormatting.setValues(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
} else {
_defaultFormatting.font = NULL;
}
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index dc8b7cd0c96..992cb6327b8 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -63,6 +63,15 @@ struct MacFontRun {
wordContinuation = false;
}
+ MacFontRun(MacWindowManager* wm_) {
+ wm = wm_;
+ fontId = textSlant = fontSize = 0;
+ palinfo1 = palinfo2 = palinfo3 = 0;
+ fgcolor = 0;
+ font = nullptr;
+ wordContinuation = false;
+ }
+
MacFontRun(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
setValues(wm_, fontId_, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
Commit: 8cb2e1bb077c25fbba6bbde9854877c1b5576776
https://github.com/scummvm/scummvm/commit/8cb2e1bb077c25fbba6bbde9854877c1b5576776
Author: Pragyansh Chaturvedi (pragyanshchaturvedi18 at gmail.com)
Date: 2022-07-17T13:04:14+02:00
Commit Message:
GRAPHICS: Add rectifyId to check for changed font IDs
Changed paths:
engines/director/castmember.cpp
graphics/fonts/winfont.cpp
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index cb099a6f4ce..46b32d8eb9f 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -1344,6 +1344,10 @@ void TextCastMember::importStxt(const Stxt *stxt) {
_fgpalinfo3 = stxt->_style.b;
_ftext = stxt->_ftext;
_ptext = stxt->_ptext;
+
+ //Creating a widget to seee if we actually have that font or not
+ Graphics::MacFont *macFont = new Graphics::MacFont(_fontId, _fontSize, _textSlant);
+ _fontId = g_director->_wm->_fontMan->rectifyId(macFont, g_director->_wm->_fontMan->getFont(*macFont));
}
Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) {
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index 60b3315abec..b6a7b2dcdeb 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -68,7 +68,7 @@ static WinFontDirEntry readDirEntry(Common::SeekableReadStream &stream) {
stream.skip(68); // Useless
entry.points = stream.readUint16LE();
- stream.skip(43); // Useless (for now, maybe not in the future)
+ stream.skip(38); // Useless (for now, maybe not in the future)
readString(stream);
entry.faceName = readString(stream);
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index b6447a13624..ce07cc53463 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -492,9 +492,20 @@ const Font *MacFontManager::getFont(MacFont macFont) {
if (!font)
font = FontMan.getFontByUsage(macFont.getFallback());
+
return font;
}
+int MacFontManager::rectifyId(const MacFont *macFont, const Font *font) {
+ for (auto it = _fontInfo.begin(); it != _fontInfo.end(); it++) {
+ if (((BdfFont *)font)->getFamilyName() == it->_value->name) {
+ return it->_key;
+ }
+ }
+
+ return macFont->getId();
+}
+
int MacFontManager::parseFontSlant(Common::String slant) {
slant.toUppercase();
int slantVal = 0;
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index ace33c833a5..6e8adb63dc8 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -143,6 +143,7 @@ public:
*/
const Common::String getFontName(uint16 id, int size, int slant = kMacFontRegular, bool tryGen = false);
const Common::String getFontName(MacFont &font);
+ int rectifyId(const MacFont *macFont, const Font *font);
int getFontIdByName(Common::String name);
Common::Language getFontLanguage(uint16 id);
Commit: c4f6aa89b98e62a3e8bd0a56c9cd369a9f89b57d
https://github.com/scummvm/scummvm/commit/c4f6aa89b98e62a3e8bd0a56c9cd369a9f89b57d
Author: Pragyansh Chaturvedi (pragyanshchaturvedi18 at gmail.com)
Date: 2022-07-17T13:04:14+02:00
Commit Message:
GRAPHICS: Implement assigning of windows font, check for wrong fontId while loading stxt, read name from FON files DIRECTOR
Changed paths:
engines/director/director.cpp
engines/director/game-quirks.cpp
graphics/fonts/winfont.cpp
graphics/fonts/winfont.h
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index fb1af3ad2ae..a16460e277a 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -180,9 +180,10 @@ Common::Error DirectorEngine::run() {
if (debugChannelSet(-1, kDebug32bpp))
_wmMode |= Graphics::kWMMode32bpp;
-
- _wm = new Graphics::MacWindowManager(_wmMode, &_director3QuickDrawPatterns, getLanguage());
- _wm->setEngine(this);
+ if (!_wm) {
+ _wm = new Graphics::MacWindowManager(_wmMode, &_director3QuickDrawPatterns, getLanguage());
+ _wm->setEngine(this);
+ }
_pixelformat = _wm->_pixelformat;
diff --git a/engines/director/game-quirks.cpp b/engines/director/game-quirks.cpp
index f5c411eafae..d217958103f 100644
--- a/engines/director/game-quirks.cpp
+++ b/engines/director/game-quirks.cpp
@@ -42,6 +42,12 @@ static void quirkLzone() {
static void quirkMcLuhan() {
// TODO. Read fonts from MCLUHAN/SYSTEM directory
g_director->_extraSearchPath.push_back("mcluhan\\");
+ g_director->_extraSearchPath.push_back("mcluhan-win\\");
+ g_director->_wm = new Graphics::MacWindowManager();
+ g_director->_wm->setEngine(g_director);
+ g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCBOLD13.FON"));
+ g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCLURG__.FON"));
+ g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCL1N___.FON"));
}
struct Quirk {
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index b6a7b2dcdeb..85fc728e2e3 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -32,11 +32,13 @@ namespace Graphics {
WinFont::WinFont() {
_glyphs = 0;
+ _name = Common::String();
close();
}
WinFont::~WinFont() {
close();
+ _name.clear();
}
void WinFont::close() {
@@ -139,8 +141,10 @@ uint32 WinFont::getFontIndex(Common::SeekableReadStream &stream, const WinFontDi
uint16 id = stream.readUint16LE();
// Use the first name when empty
- if (dirEntry.faceName.empty())
+ if (dirEntry.faceName.empty()) {
+ _name = getFONFontName(stream);
return id;
+ }
WinFontDirEntry entry = readDirEntry(stream);
@@ -151,6 +155,15 @@ uint32 WinFont::getFontIndex(Common::SeekableReadStream &stream, const WinFontDi
return 0xffffffff;
}
+Common::String WinFont::getFONFontName(Common::SeekableReadStream& stream) {
+ //Currently only works when dirEntry.faceName in getFontIndex is empty
+ //But this can be used for each FONTDIR entry
+ stream.seek(117);
+ /* Device Name = */ stream.readString();
+ Common::String fontName = stream.readString();
+ return fontName;
+}
+
bool WinFont::loadFromFNT(const Common::String &fileName) {
Common::File file;
diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h
index 8f7db33463a..22cc7422208 100644
--- a/graphics/fonts/winfont.h
+++ b/graphics/fonts/winfont.h
@@ -65,6 +65,7 @@ public:
int getFontHeight() const { return _pixHeight; }
int getFontAscent() const { return _ascent; }
int getMaxCharWidth() const { return _maxWidth; }
+ Common::String getName() const { return _name; }
int getCharWidth(uint32 chr) const;
void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
@@ -72,6 +73,7 @@ private:
bool loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry);
uint32 getFontIndex(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry);
+ Common::String getFONFontName(Common::SeekableReadStream &stream);
bool loadFromFNT(Common::SeekableReadStream &stream);
char indexToCharacter(uint16 index) const;
uint16 characterToIndex(uint32 character) const;
@@ -82,6 +84,7 @@ private:
byte _firstChar;
byte _lastChar;
byte _defaultChar;
+ Common::String _name;
uint16 _glyphCount;
struct GlyphEntry {
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index ce07cc53463..fa764d643ad 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -24,6 +24,7 @@
#include "common/macresman.h"
#include "graphics/fonts/bdf.h"
#include "graphics/fonts/macfont.h"
+#include "graphics/fonts/winfont.h"
#include "graphics/fonts/ttf.h"
#include "graphics/macgui/macwindowmanager.h"
@@ -182,6 +183,8 @@ MacFontManager::~MacFontManager() {
delete it->_value;
for (Common::HashMap<Common::String, MacFont *>::iterator it = _fontRegistry.begin(); it != _fontRegistry.end(); it++)
delete it->_value;
+ for (Common::HashMap<Common::String, Graphics::Font *>::iterator it = _winFontRegistry.begin(); it != _winFontRegistry.end(); it++)
+ delete it->_value;
for (Common::HashMap<Common::String, MacFontFamily *>::iterator it = _fontFamilies.begin(); it != _fontFamilies.end(); it++)
delete it->_value;
}
@@ -431,6 +434,20 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
}
}
+void MacFontManager::loadWindowsFont(const Common::String &fileName) {
+ Graphics::WinFont *winFont = new Graphics::WinFont();
+ winFont->loadFromFON(fileName);
+ Common::String fontName = winFont->getName();
+
+
+ _winFontRegistry.setVal(fontName, winFont);
+ MacFont *font = new MacFont();
+ Common::String fullName = Common::String::format("%s-%d-%d", fontName.c_str(), 0, 12);
+ font->setName(fullName);
+ font->setFont(winFont, false);
+ _fontRegistry.setVal(font->getName(), font);
+}
+
const Font *MacFontManager::getFont(MacFont macFont) {
Common::String name;
const Font *font = 0;
@@ -489,6 +506,12 @@ const Font *MacFontManager::getFont(MacFont macFont) {
}
#endif
+ if (!font) {
+ if (_fontInfo.contains(macFont.getId()) && _winFontRegistry.contains(_fontInfo.getVal(macFont.getId())->name)) {
+ font = _winFontRegistry.getVal(_fontInfo.getVal(macFont.getId())->name);
+ }
+ }
+
if (!font)
font = FontMan.getFontByUsage(macFont.getFallback());
@@ -497,11 +520,12 @@ const Font *MacFontManager::getFont(MacFont macFont) {
}
int MacFontManager::rectifyId(const MacFont *macFont, const Font *font) {
- for (auto it = _fontInfo.begin(); it != _fontInfo.end(); it++) {
- if (((BdfFont *)font)->getFamilyName() == it->_value->name) {
- return it->_key;
+
+ for (auto it = _fontInfo.begin(); it != _fontInfo.end(); it++) {
+ if (((BdfFont *)font)->getFamilyName() == it->_value->name.c_str()) {
+ return it->_key;
+ }
}
- }
return macFont->getId();
}
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 6e8adb63dc8..e36ea0ea501 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -154,6 +154,7 @@ public:
void loadFonts(Common::SeekableReadStream *stream);
void loadFonts(const Common::String &fileName);
void loadFonts(Common::MacResManager *fontFile);
+ void loadWindowsFont(const Common::String &fileName);
/**
* Register a font name if it doesn't already exist.
@@ -182,6 +183,7 @@ private:
bool _japaneseFontsLoaded;
uint32 _mode;
Common::Language _language;
+ Common::HashMap<Common::String, Graphics::Font *> _winFontRegistry;
Common::HashMap<Common::String, MacFont *> _fontRegistry;
Common::HashMap<Common::String, MacFontFamily *> _fontFamilies;
Commit: 5c17fe70b8f45e7ebc76170c52d17bcd0628dd22
https://github.com/scummvm/scummvm/commit/5c17fe70b8f45e7ebc76170c52d17bcd0628dd22
Author: Pragyansh Chaturvedi (pragyanshchaturvedi18 at gmail.com)
Date: 2022-07-17T13:04:14+02:00
Commit Message:
JANITORIAL: Fix conventions and reimplement MacFontManager::rectifyId()
Changed paths:
engines/director/castmember.cpp
engines/director/director.cpp
engines/director/game-quirks.cpp
engines/mtropolis/elements.cpp
engines/wage/world.cpp
graphics/fonts/winfont.cpp
graphics/fonts/winfont.h
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
graphics/macgui/mactext.h
graphics/macgui/macwindowmanager.cpp
graphics/macgui/macwindowmanager.h
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 46b32d8eb9f..2b594dce917 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -1345,9 +1345,10 @@ void TextCastMember::importStxt(const Stxt *stxt) {
_ftext = stxt->_ftext;
_ptext = stxt->_ptext;
- //Creating a widget to seee if we actually have that font or not
+ // Rectifying _fontId in case of a fallback font
Graphics::MacFont *macFont = new Graphics::MacFont(_fontId, _fontSize, _textSlant);
- _fontId = g_director->_wm->_fontMan->rectifyId(macFont, g_director->_wm->_fontMan->getFont(*macFont));
+ g_director->_wm->_fontMan->getFont(macFont);
+ _fontId = macFont->getId();
}
Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) {
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index a16460e277a..05f4118dcc6 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -86,10 +86,10 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
_fixStageSize = false;
_fixStageRect = Common::Rect();
_wmMode = debugChannelSet(-1, kDebugDesktop) ? wmModeDesktop : wmModeFullscreen;
+
_wmWidth = 1024;
_wmHeight = 768;
-
- _wm = nullptr;
+ _wm = new Graphics::MacWindowManager(_wmMode, &_director3QuickDrawPatterns, getLanguage());
_gameDataDir = Common::FSNode(ConfMan.get("path"));
@@ -180,10 +180,9 @@ Common::Error DirectorEngine::run() {
if (debugChannelSet(-1, kDebug32bpp))
_wmMode |= Graphics::kWMMode32bpp;
- if (!_wm) {
- _wm = new Graphics::MacWindowManager(_wmMode, &_director3QuickDrawPatterns, getLanguage());
- _wm->setEngine(this);
- }
+
+ _wm->setDesktopMode(_wmMode);
+ _wm->setEngine(this);
_pixelformat = _wm->_pixelformat;
diff --git a/engines/director/game-quirks.cpp b/engines/director/game-quirks.cpp
index d217958103f..d6cfacab4d4 100644
--- a/engines/director/game-quirks.cpp
+++ b/engines/director/game-quirks.cpp
@@ -20,6 +20,7 @@
*/
#include "director/director.h"
+#include "graphics/macgui/macfontmanager.h"
namespace Director {
@@ -42,12 +43,10 @@ static void quirkLzone() {
static void quirkMcLuhan() {
// TODO. Read fonts from MCLUHAN/SYSTEM directory
g_director->_extraSearchPath.push_back("mcluhan\\");
- g_director->_extraSearchPath.push_back("mcluhan-win\\");
- g_director->_wm = new Graphics::MacWindowManager();
- g_director->_wm->setEngine(g_director);
- g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCBOLD13.FON"));
- g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCLURG__.FON"));
- g_director->_wm->_fontMan->loadWindowsFont(Common::String("MCLUHAN/SYSTEM/MCL1N___.FON"));
+ Graphics::MacFontManager *fontMan = g_director->_wm->_fontMan;
+ fontMan->loadWindowsFont("MCLUHAN/SYSTEM/MCBOLD13.FON");
+ fontMan->loadWindowsFont("MCLUHAN/SYSTEM/MCLURG__.FON");
+ fontMan->loadWindowsFont("MCLUHAN/SYSTEM/MCL1N___.FON");
}
struct Quirk {
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index ec11bbccee1..772cd30ec3f 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1790,8 +1790,12 @@ void TextLabelElement::render(Window *window) {
slant |= 64;
const Graphics::FontManager::FontUsage defaultUsage = getDefaultUsageForMacFont(_macFontID, _size);
+ const Graphics::Font *fallback = FontMan.getFontByUsage(defaultUsage);
- font = _runtime->getMacFontManager()->getFont(Graphics::MacFont(_macFontID, _size, slant, defaultUsage));
+ Graphics::MacFont macFont(_macFontID, _size, slant);
+ macFont.setFallback(fallback);
+
+ font = _runtime->getMacFontManager()->getFont(macFont);
}
// Some weird cases (like the Immediate Action entryway in Obsidian) have no font info at all
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index f2e075c6c48..24705e763a1 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -48,6 +48,7 @@
#include "graphics/macgui/macwindowmanager.h"
#include "graphics/macgui/macfontmanager.h"
#include "graphics/macgui/macmenu.h"
+#include "graphics/fontman.h"
#include "wage/wage.h"
#include "wage/entities.h"
@@ -215,7 +216,9 @@ bool World::loadWorld(Common::MacResManager *resMan) {
scene->_textBounds = readRect(res);
int fontType = res->readUint16BE();
int fontSize = res->readUint16BE();
- scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::kMacFontRegular, Graphics::FontManager::kConsoleFont);
+ scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::kMacFontRegular);
+ const Graphics::Font *fallback = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
+ scene->_font->setFallback(fallback);
Common::String text;
while (res->pos() < res->size()) {
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index 85fc728e2e3..2bd5bc1d620 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -32,13 +32,11 @@ namespace Graphics {
WinFont::WinFont() {
_glyphs = 0;
- _name = Common::String();
close();
}
WinFont::~WinFont() {
close();
- _name.clear();
}
void WinFont::close() {
@@ -71,7 +69,7 @@ static WinFontDirEntry readDirEntry(Common::SeekableReadStream &stream) {
stream.skip(68); // Useless
entry.points = stream.readUint16LE();
stream.skip(38); // Useless (for now, maybe not in the future)
- readString(stream);
+ readString(stream); // Skip Device Name
entry.faceName = readString(stream);
return entry;
@@ -156,8 +154,8 @@ uint32 WinFont::getFontIndex(Common::SeekableReadStream &stream, const WinFontDi
}
Common::String WinFont::getFONFontName(Common::SeekableReadStream& stream) {
- //Currently only works when dirEntry.faceName in getFontIndex is empty
- //But this can be used for each FONTDIR entry
+ // Currently only works when dirEntry.faceName in getFontIndex is empty
+ // But this can be used for each FONTDIR entry
stream.seek(117);
/* Device Name = */ stream.readString();
Common::String fontName = stream.readString();
@@ -208,10 +206,10 @@ bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
_ascent = stream.readUint16LE();
/* uint16 internalLeading = */ stream.readUint16LE();
/* uint16 externalLeading = */ stream.readUint16LE();
- /* byte italic = */ stream.readByte();
- /* byte underline = */ stream.readByte();
- /* byte strikeOut = */ stream.readByte();
- /* uint16 weight = */ stream.readUint16LE();
+ _italic = stream.readByte();
+ _underline = stream.readByte();
+ _strikethrough = stream.readByte();
+ _weight = stream.readUint16LE();
/* byte charSet = */ stream.readByte();
uint16 pixWidth = stream.readUint16LE();
_pixHeight = stream.readUint16LE();
@@ -323,4 +321,20 @@ void WinFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) con
}
}
+int WinFont::getStyle() {
+ int style = kFontStyleRegular;
+
+ // This has been taken from Wine Source
+ // https://github.com/wine-mirror/wine/blob/b9a61cde89e5dc6264b4c152f4dc24ecf064f8f6/include/wingdi.h#L728
+
+ if (_weight >= 700)
+ style |= kFontStyleBold;
+ if (_italic)
+ style |= kFontStyleItalic;
+ if (_underline)
+ style |= kFontStyleUnderline;
+
+ return style;
+}
+
} // End of namespace Graphics
diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h
index 22cc7422208..aebefdc9a8d 100644
--- a/graphics/fonts/winfont.h
+++ b/graphics/fonts/winfont.h
@@ -68,6 +68,7 @@ public:
Common::String getName() const { return _name; }
int getCharWidth(uint32 chr) const;
void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
+ int getStyle();
private:
bool loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry);
@@ -84,8 +85,19 @@ private:
byte _firstChar;
byte _lastChar;
byte _defaultChar;
+ bool _italic;
+ bool _strikethrough;
+ bool _underline;
+ uint16 _weight;
Common::String _name;
+ enum {
+ kFontStyleRegular,
+ kFontStyleBold = 1,
+ kFontStyleItalic = 2,
+ kFontStyleUnderline = 4,
+ };
+
uint16 _glyphCount;
struct GlyphEntry {
GlyphEntry() { bitmap = 0; charWidth = 0; offset = 0; }
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index fa764d643ad..37ede514f21 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -175,18 +175,18 @@ MacFontManager::MacFontManager(uint32 mode, Common::Language language) : _mode(m
}
MacFontManager::~MacFontManager() {
- for (Common::HashMap<int, FontInfo *>::iterator it = _fontInfo.begin(); it != _fontInfo.end(); it++)
- delete it->_value;
- for (Common::HashMap<int, const Graphics::Font *>::iterator it = _uniFonts.begin(); it != _uniFonts.end(); it++)
- delete it->_value;
- for (Common::HashMap<Common::String, Common::SeekableReadStream *>::iterator it = _ttfData.begin(); it != _ttfData.end(); it++)
- delete it->_value;
- for (Common::HashMap<Common::String, MacFont *>::iterator it = _fontRegistry.begin(); it != _fontRegistry.end(); it++)
- delete it->_value;
- for (Common::HashMap<Common::String, Graphics::Font *>::iterator it = _winFontRegistry.begin(); it != _winFontRegistry.end(); it++)
- delete it->_value;
- for (Common::HashMap<Common::String, MacFontFamily *>::iterator it = _fontFamilies.begin(); it != _fontFamilies.end(); it++)
- delete it->_value;
+ for (auto &it: _fontInfo)
+ delete it._value;
+ for (auto &it: _uniFonts)
+ delete it._value;
+ for (auto &it: _ttfData)
+ delete it._value;
+ for (auto &it: _fontRegistry)
+ delete it._value;
+ for (auto &it: _winFontRegistry)
+ delete it._value;
+ for (auto &it: _fontFamilies)
+ delete it._value;
}
void MacFontManager::setLocalizedFonts() {
@@ -434,55 +434,59 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
}
}
-void MacFontManager::loadWindowsFont(const Common::String &fileName) {
+void MacFontManager::loadWindowsFont(const Common::String fileName) {
Graphics::WinFont *winFont = new Graphics::WinFont();
- winFont->loadFromFON(fileName);
- Common::String fontName = winFont->getName();
+ bool isLoaded = winFont->loadFromFON(fileName);
+ if (!isLoaded) {
+ warning("MacFontManager::loadWindowsFont(): Windows Font data from file %s not loaded", fileName.c_str());
+ return;
+ }
+ Common::String fontName = winFont->getName();
_winFontRegistry.setVal(fontName, winFont);
MacFont *font = new MacFont();
- Common::String fullName = Common::String::format("%s-%d-%d", fontName.c_str(), 0, 12);
+ Common::String fullName = Common::String::format("%s-%d-%d", fontName.c_str(), winFont->getStyle(), winFont->getFontHeight());
font->setName(fullName);
font->setFont(winFont, false);
_fontRegistry.setVal(font->getName(), font);
}
-const Font *MacFontManager::getFont(MacFont macFont) {
+const Font *MacFontManager::getFont(MacFont *macFont) {
Common::String name;
const Font *font = 0;
- int aliasForId = getFontAliasForId(macFont.getId());
+ int aliasForId = getFontAliasForId(macFont->getId());
if (aliasForId > -1) {
- macFont.setId(aliasForId);
+ macFont->setId(aliasForId);
}
if (!_builtInFonts) {
- Common::Language lang = getFontLanguage(macFont.getId());
+ Common::Language lang = getFontLanguage(macFont->getId());
if (lang == Common::JA_JPN && !_japaneseFontsLoaded) {
loadJapaneseFonts();
}
- if (macFont.getName().empty()) {
- name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant());
- macFont.setName(name);
+ if (macFont->getName().empty()) {
+ name = getFontName(macFont->getId(), macFont->getSize(), macFont->getSlant());
+ macFont->setName(name);
}
- if (!_fontRegistry.contains(macFont.getName())) {
+ if (!_fontRegistry.contains(macFont->getName())) {
// Let's try to generate name
- if (macFont.getSlant() != kMacFontRegular) {
- name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true);
- macFont.setName(name);
+ if (macFont->getSlant() != kMacFontRegular) {
+ name = getFontName(macFont->getId(), macFont->getSize(), macFont->getSlant(), true);
+ macFont->setName(name);
}
- if (!_fontRegistry.contains(macFont.getName()))
- generateFontSubstitute(macFont);
+ if (!_fontRegistry.contains(macFont->getName()))
+ generateFontSubstitute(*macFont);
}
- font = FontMan.getFontByName(macFont.getName());
+ font = FontMan.getFontByName(macFont->getName());
if (!font) {
- debug(1, "Cannot load font '%s'", macFont.getName().c_str());
+ debug(1, "Cannot load font '%s'", macFont->getName().c_str());
font = FontMan.getFontByName(MacFont(kMacFontChicago, 12).getName());
}
@@ -491,43 +495,44 @@ const Font *MacFontManager::getFont(MacFont macFont) {
#ifdef USE_FREETYPE2
if (!font) {
if (_mode & kWMModeUnicode) {
- if (macFont.getSize() <= 0) {
+ if (macFont->getSize() <= 0) {
debug(1, "MacFontManager::getFont() - Font size <= 0!");
}
- Common::HashMap<int, const Graphics::Font *>::iterator pFont = _uniFonts.find(macFont.getSize());
+ 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", macFont.getSize(), Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
- _uniFonts[macFont.getSize()] = font;
+ font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", macFont->getSize(), Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
+ _uniFonts[macFont->getSize()] = font;
}
}
}
#endif
if (!font) {
- if (_fontInfo.contains(macFont.getId()) && _winFontRegistry.contains(_fontInfo.getVal(macFont.getId())->name)) {
- font = _winFontRegistry.getVal(_fontInfo.getVal(macFont.getId())->name);
+ int id = macFont->getId();
+
+ if (_fontInfo.contains(id) && _winFontRegistry.contains(_fontInfo.getVal(id)->name)) {
+ font = _winFontRegistry.getVal(_fontInfo.getVal(id)->name);
}
}
- if (!font)
- font = FontMan.getFontByUsage(macFont.getFallback());
+ if (!font) {
+ font = macFont->getFallback();
+ for (auto &it : _fontInfo) {
+ if (it._value->name == macFont->getFallbackName()) {
+ macFont->setId(it._key);
+ }
+ }
+ }
return font;
}
-int MacFontManager::rectifyId(const MacFont *macFont, const Font *font) {
-
- for (auto it = _fontInfo.begin(); it != _fontInfo.end(); it++) {
- if (((BdfFont *)font)->getFamilyName() == it->_value->name.c_str()) {
- return it->_key;
- }
- }
-
- return macFont->getId();
+const Font *MacFontManager::getFont(MacFont macFont) {
+ return getFont(&macFont);
}
int MacFontManager::parseFontSlant(Common::String slant) {
@@ -821,4 +826,9 @@ void MacFontManager::generateFONTFont(MacFont &toFont, MacFont &fromFont) {
debug("Generated font '%s'", getFontName(toFont).c_str());
}
+void MacFont::setFallback(const Font *font, Common::String name) {
+ _fallback = font;
+ _fallbackName = name;
+}
+
} // End of namespace Graphics
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index e36ea0ea501..f8942eeddcd 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -23,7 +23,7 @@
#define GRAPHICS_MACGUI_MACFONTMANAGER_H
#include "common/language.h"
-
+#include "graphics/fonts/bdf.h"
#include "graphics/fontman.h"
namespace Common {
@@ -79,11 +79,12 @@ struct FontInfo {
class MacFont {
public:
- MacFont(int id = kMacFontChicago, int size = 12, int slant = kMacFontRegular, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
+ MacFont(int id = kMacFontChicago, int size = 12, int slant = kMacFontRegular) {
_id = id;
_size = size ? size : 12;
_slant = slant;
- _fallback = fallback;
+ _fallback = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ _fallbackName = Common::String(((BdfFont *)_fallback)->getFamilyName());
_generated = false;
_truetype = false;
_font = NULL;
@@ -96,12 +97,14 @@ public:
Common::String getName() { return _name; }
void setName(Common::String &name) { setName(name.c_str()); }
void setName(const char *name);
- FontManager::FontUsage getFallback() { return _fallback; }
+ const Graphics::Font *getFallback() { return _fallback; }
bool isGenerated() { return _generated; }
void setGenerated(bool gen) { _generated = gen; }
bool isTrueType() { return _truetype; }
Font *getFont() { return _font; }
void setFont(Font *font, bool truetype) { _font = font; _truetype = truetype; }
+ void setFallback(const Font *font, Common::String name = "");
+ Common::String getFallbackName() { return _fallbackName; }
private:
int _id;
@@ -109,7 +112,8 @@ private:
int _slant;
bool _truetype;
Common::String _name;
- FontManager::FontUsage _fallback;
+ const Graphics::Font *_fallback;
+ Common::String _fallbackName;
bool _generated;
Font *_font;
@@ -133,6 +137,7 @@ public:
* @param fallback Fallback policy in case the desired font isn't there.
* @return The requested font or the fallback.
*/
+ const Font *getFont(MacFont *macFont);
const Font *getFont(MacFont macFont);
/**
@@ -143,7 +148,6 @@ public:
*/
const Common::String getFontName(uint16 id, int size, int slant = kMacFontRegular, bool tryGen = false);
const Common::String getFontName(MacFont &font);
- int rectifyId(const MacFont *macFont, const Font *font);
int getFontIdByName(Common::String name);
Common::Language getFontLanguage(uint16 id);
@@ -154,7 +158,7 @@ public:
void loadFonts(Common::SeekableReadStream *stream);
void loadFonts(const Common::String &fileName);
void loadFonts(Common::MacResManager *fontFile);
- void loadWindowsFont(const Common::String &fileName);
+ void loadWindowsFont(const Common::String fileName);
/**
* Register a font name if it doesn't already exist.
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 992cb6327b8..915ed3b48ad 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -63,7 +63,7 @@ struct MacFontRun {
wordContinuation = false;
}
- MacFontRun(MacWindowManager* wm_) {
+ MacFontRun(MacWindowManager *wm_) {
wm = wm_;
fontId = textSlant = fontSize = 0;
palinfo1 = palinfo2 = palinfo3 = 0;
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 7d80f1cbb04..48abf528a08 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -225,9 +225,7 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::L
CursorMan.showMouse(true);
loadDataBundle();
- if (!(_mode & Graphics::kWMNoScummVMWallpaper)) {
- loadDesktop();
- }
+ setDesktopMode(_mode);
}
MacWindowManager::~MacWindowManager() {
@@ -251,6 +249,14 @@ MacWindowManager::~MacWindowManager() {
g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
}
+void MacWindowManager::setDesktopMode(uint32 mode) {
+ if (!(mode & Graphics::kWMNoScummVMWallpaper)) {
+ loadDesktop();
+ } else if (_desktopBmp) {
+ _desktopBmp->free();
+ }
+}
+
void MacWindowManager::setScreen(ManagedSurface *screen) {
_screen = screen;
delete _screenCopy;
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 37c989f2543..8f5e8c81d20 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -210,6 +210,7 @@ public:
void disableScreenCopy();
bool isMenuActive();
+ void setDesktopMode(uint32 mode);
/**
* Set hot zone where menu appears (works only with autohide menu)
More information about the Scummvm-git-logs
mailing list