12 #include "utils/ColorUtils.h" 13 #include "utils/Geometry.h" 21 #include FT_FREETYPE_H 22 #include <harfbuzz/hb.h> 25 #include <DirectXMath.h> 26 #include <DirectXPackedVector.h> 37 struct FT_LibraryRec_;
38 struct FT_GlyphSlotRec_;
39 struct FT_BitmapGlyphRec_;
40 struct FT_StrokerRec_;
42 typedef struct FT_FaceRec_* FT_Face;
43 typedef struct FT_LibraryRec_* FT_Library;
44 typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
45 typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
46 typedef struct FT_StrokerRec_* FT_Stroker;
48 typedef uint32_t character_t;
49 typedef std::vector<character_t> vecText;
68 unsigned char r, g, b, a;
80 static constexpr
int MAX_GLYPH_IDX = 4096;
81 static constexpr
size_t LOOKUPTABLE_SIZE = MAX_GLYPH_IDX * FONT_STYLES_COUNT;
88 static CGUIFontTTF* CreateGUIFontTTF(
const std::string& fontIdent);
92 bool Load(
const std::string& strFilename,
95 float lineSpacing = 1.0f,
101 virtual CVertexBuffer CreateVertexBuffer(
const std::vector<SVertex>& vertices)
const 106 virtual void DestroyVertexBuffer(
CVertexBuffer& bufferHandle)
const {}
108 const std::string& GetFontIdent()
const {
return m_fontIdent; }
111 explicit CGUIFontTTF(
const std::string& fontIdent);
115 hb_glyph_info_t m_glyphInfo{};
116 hb_glyph_position_t m_glyphPosition{};
118 Glyph(
const hb_glyph_info_t& glyphInfo,
const hb_glyph_position_t& glyphPosition)
119 : m_glyphInfo(glyphInfo), m_glyphPosition(glyphPosition)
133 FT_UInt m_glyphIndex;
134 character_t m_glyphAndStyle;
139 unsigned int m_startOffset;
140 unsigned int m_endOffset;
141 hb_buffer_t* m_buffer;
142 hb_script_t m_script;
143 hb_glyph_info_t* m_glyphInfos;
144 hb_glyph_position_t* m_glyphPositions;
148 void RemoveReference();
150 std::vector<Glyph> GetHarfBuzzShapedGlyphs(
const vecText& text);
152 float GetTextWidthInternal(
const vecText& text);
153 float GetTextWidthInternal(
const vecText& text,
const std::vector<Glyph>& glyph);
154 float GetCharWidthInternal(character_t ch);
155 float GetTextHeight(
float lineSpacing,
int numLines)
const;
156 float GetTextBaseLine()
const {
return static_cast<float>(m_cellBaseLine); }
157 float GetLineHeight(
float lineSpacing)
const;
158 float GetFontHeight()
const {
return m_height; }
163 const std::vector<UTILS::COLOR::Color>& colors,
171 float m_height{0.0f};
174 Character* GetCharacter(character_t letter, FT_UInt glyphIndex);
175 bool CacheCharacter(FT_UInt glyphIndex, uint32_t style,
Character* ch);
180 UTILS::COLOR::Color color,
182 std::vector<SVertex>& vertices);
183 void ClearCharacterCache();
185 virtual std::unique_ptr<CTexture> ReallocTexture(
unsigned int& newHeight) = 0;
186 virtual bool CopyCharToTexture(FT_BitmapGlyph bitGlyph,
190 unsigned int y2) = 0;
191 virtual void DeleteHardwareTexture() = 0;
194 void SetGlyphStrength(FT_GlyphSlot slot,
int glyphStrength);
195 static void ObliqueGlyph(FT_GlyphSlot slot);
197 std::unique_ptr<CTexture>
200 unsigned int m_textureWidth{0};
201 unsigned int m_textureHeight{0};
208 unsigned int GetTextureLineHeight()
const;
209 unsigned int GetMaxFontHeight()
const;
211 UTILS::COLOR::Color m_color{UTILS::COLOR::NONE};
213 std::vector<Character> m_char;
216 Character* m_charquick[LOOKUPTABLE_SIZE]{
nullptr};
218 bool m_ellipseCached{
false};
219 float m_ellipsesWidth{0.0f};
221 unsigned int m_cellBaseLine{0};
222 unsigned int m_cellHeight{0};
223 unsigned int m_maxFontHeight{0};
225 unsigned int m_nestedBeginCount{0};
228 FT_Face m_face{
nullptr};
229 FT_Stroker m_stroker{
nullptr};
231 hb_font_t* m_hbFont{
nullptr};
233 float m_originX{0.0f};
234 float m_originY{0.0f};
236 unsigned int m_nTexture{0};
252 float offsetX = 0.0f,
253 float offsetY = 0.0f)
254 : m_translateX(translateX),
255 m_translateY(translateY),
256 m_translateZ(translateZ),
259 m_vertexBuffer(vertexBuffer),
264 std::vector<CTranslatedVertices> m_vertexTrans;
265 std::vector<SVertex> m_vertex;
267 float m_textureScaleX{0.0f};
268 float m_textureScaleY{0.0f};
270 const std::string m_fontIdent;
280 float GetTabSpaceLength();
282 virtual bool FirstBegin() = 0;
283 virtual void LastEnd() = 0;
286 int m_referenceCount{0};
Definition: GUIFontTTF.h:65
Definition: GUIFontTTF.h:113
Definition: GUIFontTTF.h:238
Definition: GUIFontTTF.h:76
Definition: RenderSystem.h:27
Definition: GUIFontTTF.h:137
Base texture class, subclasses of which depend on the render spec (DX, GL etc.)
Definition: Texture.h:34
Definition: GUIFontCache.h:220
Definition: GUIFontTTF.h:124
Definition: GUIFont.h:110
Definition: GraphicContext.h:60