From be07b004e000cdafc59a43eaefc4fc85ab19f431 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 17 Jan 2017 18:14:02 +0100 Subject: GRAPHICS: Split out MacFontFamily class out of MacFont --- graphics/fonts/macfont.cpp | 13 +++++++--- graphics/fonts/macfont.h | 64 ++++++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 32 deletions(-) (limited to 'graphics/fonts') diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp index d3638fc749..0df5fa7aa0 100644 --- a/graphics/fonts/macfont.cpp +++ b/graphics/fonts/macfont.cpp @@ -77,7 +77,13 @@ MacFont::MacFont() { _leading = 0; _rowWords = 0; _bitImage = nullptr; +} +MacFont::~MacFont() { + free(_bitImage); +} + +MacFontFamily::MacFontFamily() { _ffFlags = 0; _ffFamID = 0; _ffFirstChar = 0; @@ -103,12 +109,11 @@ MacFont::MacFont() { _ffNumBBoxes = 0; } -MacFont::~MacFont() { - free(_bitImage); +MacFontFamily::~MacFontFamily() { free(_ffOffsets); } -bool MacFont::loadFOND(Common::SeekableReadStream &stream) { +bool MacFontFamily::load(Common::SeekableReadStream &stream) { _ffFlags = stream.readUint16BE(); // flags for family _ffFamID = stream.readUint16BE(); // family ID number _ffFirstChar = stream.readUint16BE(); // ASCII code of first character @@ -201,7 +206,7 @@ bool MacFont::loadFOND(Common::SeekableReadStream &stream) { _ffKernEntries[i]._entryLength = stream.readUint16BE(); _ffKernEntries[i]._kernPairs.resize(_ffKernEntries[i]._entryLength); - debug(10, " style: %d kernpairs: %d", _ffKernEntries[i]._style, _ffKernEntries[i]._entryLength); + debug(10, " style: %x kernpairs: %d", _ffKernEntries[i]._style, _ffKernEntries[i]._entryLength); for (uint j = 0; j < _ffKernEntries[i]._entryLength; j++) { _ffKernEntries[i]._kernPairs[j]._firstChar = stream.readByte(); diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h index c357346c29..935fbb2e98 100644 --- a/graphics/fonts/macfont.h +++ b/graphics/fonts/macfont.h @@ -28,38 +28,14 @@ namespace Graphics { -/** - * Processing of Mac FONT/NFNT rResources - */ -class MacFont : public Font { +class MacFontFamily { public: - MacFont(); - virtual ~MacFont(); + MacFontFamily(); + ~MacFontFamily(); - virtual int getFontHeight() const; - virtual int getMaxCharWidth() const; - virtual int getCharWidth(uint32 chr) const; - virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const; - - bool loadFont(Common::SeekableReadStream &stream); - bool loadFOND(Common::SeekableReadStream &stream); + bool load(Common::SeekableReadStream &stream); private: - // FONT/NFNT - uint16 _fontType; - uint16 _firstChar; - uint16 _lastChar; - uint16 _maxWidth; - int16 _kernMax; - int16 _nDescent; - uint16 _fRectWidth; - uint16 _fRectHeight; - uint32 _owTLoc; - uint16 _ascent; - uint16 _descent; - uint16 _leading; - uint16 _rowWords; - // FOND uint16 _ffFlags; uint16 _ffFamID; @@ -113,6 +89,38 @@ private: uint16 _ffNumKerns; Common::Array _ffKernEntries; +}; + +/** + * Processing of Mac FONT/NFNT rResources + */ +class MacFont : public Font { +public: + MacFont(); + virtual ~MacFont(); + + virtual int getFontHeight() const; + virtual int getMaxCharWidth() const; + virtual int getCharWidth(uint32 chr) const; + virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const; + + bool loadFont(Common::SeekableReadStream &stream); + +private: + // FONT/NFNT + uint16 _fontType; + uint16 _firstChar; + uint16 _lastChar; + uint16 _maxWidth; + int16 _kernMax; + int16 _nDescent; + uint16 _fRectWidth; + uint16 _fRectHeight; + uint32 _owTLoc; + uint16 _ascent; + uint16 _descent; + uint16 _leading; + uint16 _rowWords; byte *_bitImage; -- cgit v1.2.3