7#ifndef MYGUI_RESOURCE_TRUE_TYPE_FONT_H_
8#define MYGUI_RESOURCE_TRUE_TYPE_FONT_H_
14#ifdef MYGUI_USE_FREETYPE
16# include FT_FREETYPE_H
18#ifdef MYGUI_MSDF_FONTS
28#include <unordered_map>
49 ITexture* getTextureFont()
const override;
52 int getDefaultHeight()
const override;
55 void textureInvalidate(
ITexture* _texture)
override;
59 std::vector<std::pair<Char, Char> > getCodePointRanges()
const;
63 Char getSubstituteCodePoint()
const;
68 void setSource(
const std::string& _value);
69 void setShader(
const std::string& _value);
70 void setSize(
float _value);
71 void setResolution(
unsigned int _value);
72 void setHinting(
const std::string& _value);
73 void setAntialias(
bool _value);
74 void setTabWidth(
float _value);
75 void setOffsetHeight(
int _value);
76 void setSubstituteCode(
int _value);
77 void setDistance(
int _value);
78 void setMsdfMode(
bool _value);
79 void setMsdfRange(
int _value);
81 void addCodePointRange(
Char _first,
Char _second);
82 void removeCodePointRange(
Char _first,
Char _second);
84#ifdef MYGUI_USE_FREETYPE
94 void addCodePoint(
Char _codePoint);
95 void removeCodePoint(
Char _codePoint);
97 void clearCodePoints();
103 unsigned int mResolution;
110 Char mSubstituteCodePoint;
120 static const int mDefaultGlyphSpacing;
121 static const float mDefaultTabWidth;
122 static const float mSelectedWidth;
123 static const float mCursorWidth;
127 typedef std::map<Char, FT_UInt> CharMap;
130 typedef std::unordered_map<Char, GlyphInfo> GlyphMap;
133 typedef std::map<int, std::map<FT_UInt, GlyphInfo*> > GlyphHeightMap;
135 template<
bool LAMode,
bool Antialias>
136 void initialiseFreeType();
143 FT_Face loadFace(
const FT_Library& _ftLibrary,
uint8*& _fontBuffer);
147 void autoWrapGlyphPos(
int _glyphWidth,
int _texWidth,
int _lineHeight,
int& _texX,
int& _texY)
const;
150 GlyphInfo createFaceGlyphInfo(
Char _codePoint,
int _fontAscent, FT_GlyphSlot _glyph)
const;
154 int createGlyph(FT_UInt _glyphIndex,
const GlyphInfo& _glyphInfo, GlyphHeightMap& _glyphHeightMap);
158 int createFaceGlyph(FT_UInt _glyphIndex,
Char _codePoint,
int _fontAscent,
const FT_Face& _ftFace, FT_Int32 _ftLoadFlags, GlyphHeightMap& _glyphHeightMap);
161 template<
bool LAMode,
bool Antialias>
162 void renderGlyphs(
const GlyphHeightMap& _glyphHeightMap,
const FT_Library& _ftLibrary,
const FT_Face& _ftFace, FT_Int32 _ftLoadFlags,
uint8* _texBuffer,
int _texWidth,
int _texHeight);
167 template<
bool LAMode,
bool UseBuffer,
bool Antialias>
168 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);
173#ifdef MYGUI_MSDF_FONTS
174 GlyphInfo createMsdfFaceGlyphInfo(
Char _codePoint,
const msdfgen::Shape& _shape,
double _advance,
int _fontAscent);
175 int createMsdfGlyph(
const GlyphInfo& _glyphInfo, GlyphHeightMap& _glyphHeightMap);
176 int createMsdfFaceGlyph(
Char _codePoint,
int _fontAscent, msdfgen::FontHandle* _fontHandle, GlyphHeightMap& _glyphHeightMap);
178 void renderMsdfGlyphs(
const GlyphHeightMap& _glyphHeightMap, msdfgen::FontHandle* _fontHandle,
uint8* _texBuffer,
int _texWidth,
int _texHeight);
#define MYGUI_RTTI_DERIVED(DerivedType)