From b84ab35363ac2fd40031b7f313fe49ebfc09d967 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 24 Jan 2017 23:33:59 +0100 Subject: GRAPHICS: Plug MacFont scaler in --- graphics/fonts/macfont.cpp | 6 ++++-- graphics/fonts/macfont.h | 2 +- graphics/macgui/macfontmanager.cpp | 4 ++-- graphics/macgui/macfontmanager.h | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp index b8b808f9ea..d15f0d1704 100644 --- a/graphics/fonts/macfont.cpp +++ b/graphics/fonts/macfont.cpp @@ -427,6 +427,8 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) { data._size = src->_data._size; data._style = src->_data._style; + data._glyphs.resize(src->_data._glyphs.size()); + // Dtermine width of the bit image table int newBitmapWidth = 0; for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) { @@ -443,7 +445,7 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) { data._rowWords = newBitmapWidth; - uint16 bitImageSize = data._rowWords * _data._fRectHeight; + uint16 bitImageSize = data._rowWords * data._fRectHeight; data._bitImage = new byte[bitImageSize]; int srcPitch = src->_data._rowWords; @@ -454,7 +456,7 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) { MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i]; byte *ptr = &data._bitImage[glyph->bitmapOffset]; - for (int y = 0; y < _data._fRectHeight; y++) { + for (int y = 0; y < data._fRectHeight; y++) { const byte *srcd = (const byte *)&src->_data._bitImage[((int)((float)y / scale)) * srcPitch + srcglyph->bitmapOffset]; byte *dst = ptr; byte b = 0; diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h index ab285ed905..5baa6438bb 100644 --- a/graphics/fonts/macfont.h +++ b/graphics/fonts/macfont.h @@ -156,7 +156,7 @@ public: int getFontSize() const { return _data._size; } - MacFONTFont *scaleFont(MacFONTFont *src, int newSize); + static MacFONTFont *scaleFont(MacFONTFont *src, int newSize); private: MacFONTdata _data; diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index a717253fcb..20417979ce 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -129,7 +129,7 @@ void MacFontManager::loadFontsBDF() { } FontMan.assignFontToName(fontName, font); - macfont->setFont(font); + //macfont->setFont(font); _fontRegistry.setVal(fontName, macfont); debug(2, " %s", fontName.c_str()); @@ -340,7 +340,7 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) { debugN("Found font substitute for font '%s' ", getFontName(toFont)); debug("as '%s'", getFontName(fromFont)); - Font *font = fromFont.getFont(); // = Graphics::BdfFont::scaleFont(fromFont.getFont(), toFont.getSize()); + MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize()); if (!font) { warning("Failed to generate font '%s'", getFontName(toFont)); diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h index bfec6b7645..8c1ed5025c 100644 --- a/graphics/macgui/macfontmanager.h +++ b/graphics/macgui/macfontmanager.h @@ -27,6 +27,8 @@ namespace Graphics { +class MacFONTFont; + enum { kMacFontNonStandard = -1, kMacFontChicago = 0, @@ -79,8 +81,8 @@ public: FontManager::FontUsage getFallback() { return _fallback; } bool isGenerated() { return _generated; } void setGenerated(bool gen) { _generated = gen; } - Font *getFont() { return _font; } - void setFont(Font *font) { _font = font; } + MacFONTFont *getFont() { return _font; } + void setFont(MacFONTFont *font) { _font = font; } private: int _id; @@ -90,7 +92,7 @@ private: FontManager::FontUsage _fallback; bool _generated; - Font *_font; + MacFONTFont *_font; }; class MacFontManager { -- cgit v1.2.3