aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-19 17:43:47 +0200
committerEugene Sandulenko2019-10-19 17:43:47 +0200
commit2d1dc5d1c4a2de31e925ecff45e177ff1c6a7f7c (patch)
treef8088e311416bd32b1c9c29ea4895646aa1b632b /graphics/macgui
parent50822e708bf21b0e955186675467c025deaba1d5 (diff)
downloadscummvm-rg350-2d1dc5d1c4a2de31e925ecff45e177ff1c6a7f7c.tar.gz
scummvm-rg350-2d1dc5d1c4a2de31e925ecff45e177ff1c6a7f7c.tar.bz2
scummvm-rg350-2d1dc5d1c4a2de31e925ecff45e177ff1c6a7f7c.zip
GRAPHICS: MACGUI: Added default font for MacText
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macfontmanager.cpp17
-rw-r--r--graphics/macgui/macfontmanager.h4
-rw-r--r--graphics/macgui/mactext.cpp6
3 files changed, 24 insertions, 3 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 259fd157eb..ac58b80ae1 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -99,6 +99,11 @@ MacFontManager::MacFontManager(uint32 mode) : _mode(mode) {
}
}
+MacFontManager::~MacFontManager() {
+ for(Common::HashMap<int, const Graphics::Font *>::iterator it = _uniFonts.begin(); it != _uniFonts.end(); it++)
+ delete it->_value;
+}
+
void MacFontManager::loadFontsBDF() {
Common::Archive *dat;
@@ -287,7 +292,17 @@ const Font *MacFontManager::getFont(MacFont macFont) {
#ifdef USE_FREETYPE2
if (!font) {
if (_mode & kWMModeUnicode) {
- font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", 16, Graphics::kTTFSizeModeCell, 0, Graphics::kTTFRenderModeMonochrome);
+ if (macFont.getSize() <= 0) {
+ debug(1, "MacFontManager::getFont() - Font size <= 0!");
+ }
+ 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;
+ }
}
}
#endif
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index d274657bbf..a8a3e3a77a 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -103,6 +103,7 @@ private:
class MacFontManager {
public:
MacFontManager(uint32 mode);
+ ~MacFontManager();
/**
* Accessor method to check the presence of built-in fonts.
@@ -154,6 +155,9 @@ private:
Common::HashMap<Common::String, int> _extraFontIds;
int parseFontSlant(Common::String slant);
+
+ /* Unicode font */
+ Common::HashMap<int, const Graphics::Font *> _uniFonts;
};
} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index fa2b92f2fc..6dfdee39f1 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -66,6 +66,7 @@ MacText::MacText(Common::U32String s, MacWindowManager *wm, const MacFont *macFo
_interLinear = interlinear;
if (macFont) {
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
@@ -97,6 +98,7 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
_interLinear = interlinear;
if (macFont) {
+ _defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
} else {
_defaultFormatting.font = NULL;
@@ -310,7 +312,7 @@ void MacText::render(int from, int to) {
// TODO: _textMaxWidth, when -1, was not rendering ANY text.
for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
- debug(5, "line %d[%d]/%d at %d,%d (%s)", i, j, xOffset, _textLines[i].chunks[j].fontId, _textLines[i].y, _textLines[i].chunks[j].text.c_str());
+ debug(5, "line %d[%d]/%d at %d,%d (%s)", i, j, xOffset, _textLines[i].chunks[j].fontId, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str());
if (_textLines[i].chunks[j].text.empty())
continue;
@@ -324,7 +326,7 @@ void MacText::render(int from, int to) {
debugN(4, "%2d ", i);
for (uint j = 0; j < _textLines[i].chunks.size(); j++)
- debugN(4, "[%d (%d)] \"%s\" ", _textLines[i].chunks[j].fontId, _textLines[i].chunks[j].textSlant, _textLines[i].chunks[j].text.c_str());
+ debugN(4, "[%d (%d)] \"%s\" ", _textLines[i].chunks[j].fontId, _textLines[i].chunks[j].textSlant, _textLines[i].chunks[j].text.encode().c_str());
debug(4, "%s", "");
}