7 #ifndef MYGUI_RESOURCE_TRUE_TYPE_FONT_H_
8 #define MYGUI_RESOURCE_TRUE_TYPE_FONT_H_
14 #ifdef MYGUI_USE_FREETYPE
15 # include <ft2build.h>
16 # include FT_FREETYPE_H
17 #endif // MYGUI_USE_FREETYPE
19 #include <unordered_map>
43 int getDefaultHeight()
override;
46 void textureInvalidate(
ITexture* _texture)
override;
50 std::vector<std::pair<Char, Char> > getCodePointRanges()
const;
54 Char getSubstituteCodePoint()
const;
59 void setSource(
const std::string& _value);
60 void setSize(
float _value);
61 void setResolution(
unsigned int _value);
62 void setHinting(
const std::string& _value);
63 void setAntialias(
bool _value);
64 void setTabWidth(
float _value);
65 void setOffsetHeight(
int _value);
66 void setSubstituteCode(
int _value);
67 void setDistance(
int _value);
69 void addCodePointRange(
Char _first,
Char _second);
70 void removeCodePointRange(
Char _first,
Char _second);
72 #ifdef MYGUI_USE_FREETYPE
82 void addCodePoint(
Char _codePoint);
83 void removeCodePoint(
Char _codePoint);
85 void clearCodePoints();
90 unsigned int mResolution;
97 Char mSubstituteCodePoint;
105 static const int mDefaultGlyphSpacing;
106 static const float mDefaultTabWidth;
107 static const float mSelectedWidth;
108 static const float mCursorWidth;
112 typedef std::map<Char, FT_UInt> CharMap;
115 typedef std::unordered_map<Char, GlyphInfo> GlyphMap;
118 typedef std::map<FT_Pos, std::map<FT_UInt, GlyphInfo*> > GlyphHeightMap;
120 template<
bool LAMode,
bool Antialias>
121 void initialiseFreeType();
128 FT_Face loadFace(
const FT_Library& _ftLibrary,
uint8*& _fontBuffer);
132 void autoWrapGlyphPos(
int _glyphWidth,
int _texWidth,
int _lineHeight,
int& _texX,
int& _texY);
135 GlyphInfo createFaceGlyphInfo(
Char _codePoint,
int _fontAscent, FT_GlyphSlot _glyph);
139 int createGlyph(FT_UInt _glyphIndex,
const GlyphInfo& _glyphInfo, GlyphHeightMap& _glyphHeightMap);
143 int createFaceGlyph(FT_UInt _glyphIndex,
Char _codePoint,
int _fontAscent,
const FT_Face& _ftFace, FT_Int32 _ftLoadFlags, GlyphHeightMap& _glyphHeightMap);
146 template<
bool LAMode,
bool Antialias>
147 void renderGlyphs(
const GlyphHeightMap& _glyphHeightMap,
const FT_Library& _ftLibrary,
const FT_Face& _ftFace, FT_Int32 _ftLoadFlags,
uint8* _texBuffer,
int _texWidth,
int _texHeight);
152 template<
bool LAMode,
bool UseBuffer,
bool Antialias>
153 void renderGlyph(
GlyphInfo& _info,
uint8 _luminance0,
uint8 _luminance1,
uint8 _alpha,
int _lineHeight,
uint8* _texBuffer,
int _texWidth,
int _texHeight,
int& _texX,
int& _texY,
uint8* _glyphBuffer =
nullptr);
158 #endif // MYGUI_USE_FREETYPE
164 #endif // MYGUI_RESOURCE_TRUE_TYPE_FONT_H_