From 1fea15ac7bb4533bc2e6a90b5a9661ce56430bb0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 17 Jan 2017 18:44:27 +0100 Subject: GRAPHICS: Implementing kerning calculation for MacFonts --- graphics/fonts/macfont.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'graphics/fonts/macfont.h') diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h index 935fbb2e98..ca1eb72abf 100644 --- a/graphics/fonts/macfont.h +++ b/graphics/fonts/macfont.h @@ -24,6 +24,7 @@ #define GRAPHICS_FONTS_MACFONT_H #include "common/array.h" +#include "common/hashmap.h" #include "graphics/font.h" namespace Graphics { @@ -34,6 +35,15 @@ public: ~MacFontFamily(); bool load(Common::SeekableReadStream &stream); + int getKerningOffset(uint style, int32 left, uint32 right) const; + + struct AsscEntry { + uint16 _fontSize; + uint16 _fontStyle; + uint16 _fontID; + }; + + Common::Array *getAssocTable() { return &_ffAssocEntries; } private: // FOND @@ -52,12 +62,6 @@ private: uint16 _ffIntl[2]; uint16 _ffVersion; - struct AsscEntry { - uint16 _fontSize; - uint16 _fontStyle; - uint16 _fontID; - }; - uint16 _ffNumAssoc; Common::Array _ffAssocEntries; @@ -85,6 +89,8 @@ private: uint16 _style; uint16 _entryLength; Common::Array _kernPairs; + + Common::HashMap _kernTable; }; uint16 _ffNumKerns; @@ -104,10 +110,11 @@ public: 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 loadFont(Common::SeekableReadStream &stream, MacFontFamily *family = nullptr, int size = 12, int style = 0); + + virtual int getKerningOffset(uint32 left, uint32 right) const; private: - // FONT/NFNT uint16 _fontType; uint16 _firstChar; uint16 _lastChar; @@ -141,6 +148,10 @@ private: Common::Array _glyphs; Glyph _defaultChar; const Glyph *findGlyph(uint32 c) const; + + MacFontFamily *_family; + int _size; + int _style; }; } // End of namespace Graphics -- cgit v1.2.3