26#ifndef TGUI_BACKEND_FONT_FREETYPE_HPP
27#define TGUI_BACKEND_FONT_FREETYPE_HPP
29#include <TGUI/Backend/Font/BackendFont.hpp>
30#include <unordered_map>
34typedef struct FT_LibraryRec_* FT_Library;
35typedef struct FT_FaceRec_* FT_Face;
36typedef struct FT_StrokerRec_* FT_Stroker;
63 virtual bool loadFromMemory(std::unique_ptr<std::uint8_t[]> data, std::size_t sizeInBytes)
override;
74 bool hasGlyph(
char32_t codePoint)
const override;
90 virtual FontGlyph getGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness = 0)
override;
107 virtual float getKerning(
char32_t first,
char32_t second,
unsigned int characterSize,
bool bold)
override;
153 std::shared_ptr<BackendTexture>
getTexture(
unsigned int characterSize)
override;
184 Glyph loadGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness);
190 Glyph getInternalGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness);
196 IntRect findAvailableGlyphRect(
unsigned int width,
unsigned int height);
202 bool setCurrentSize(
unsigned int characterSize);
216 Row(
unsigned int rowTop,
unsigned int rowHeight) :
width(0),
top(rowTop),
height(rowHeight) {}
223 FT_Library m_library =
nullptr;
224 FT_Face m_face =
nullptr;
225 FT_Stroker m_stroker =
nullptr;
227 std::unordered_map<unsigned int, float> m_cachedLineSpacing;
229 std::unordered_map<std::uint64_t, Glyph> m_glyphs;
231 std::vector<Row> m_rows;
233 std::unique_ptr<std::uint8_t[]> m_fileContents;
234 std::unique_ptr<std::uint8_t[]> m_pixels;
235 std::shared_ptr<BackendTexture> m_texture;
236 unsigned int m_textureSize = 0;
237 bool m_textureUpToDate =
false;
Font implementations that uses FreeType directly to load glyphs.
Definition: BackendFontFreeType.hpp:46
virtual FontGlyph getGlyph(char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override
Retrieve a glyph of the font.
virtual float getLineSpacing(unsigned int characterSize) override
Returns the line spacing.
float getUnderlineThickness(unsigned int characterSize) override
Get the thickness of the underline.
virtual float getKerning(char32_t first, char32_t second, unsigned int characterSize, bool bold) override
Returns the kerning offset of two glyphs.
float getUnderlinePosition(unsigned int characterSize) override
Get the position of the underline.
~BackendFontFreetype()
Destructor that cleans up the FreeType resources.
unsigned int m_nextRow
Y position of the next new row in the texture (first 2 rows contain pixels for underlining)
Definition: BackendFontFreeType.hpp:230
std::shared_ptr< BackendTexture > getTexture(unsigned int characterSize) override
Returns the texture that is used to store glyphs of the given character size.
void setSmooth(bool smooth) override
Enable or disable the smooth filter.
virtual bool loadFromMemory(std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes) override
Loads a font from memory.
bool hasGlyph(char32_t codePoint) const override
Returns whether a font contains a certain glyph.
Base class for font implementations that depend on the backend.
Definition: BackendFont.hpp:43
virtual bool loadFromMemory(std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes)=0
Loads a font from memory.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Definition: BackendFontFreeType.hpp:172
IntRect textureRect
Texture coordinates of the glyph inside the font's texture.
Definition: BackendFontFreeType.hpp:177
float rsbDelta
Right offset after forced autohint. Internally used by getKerning()
Definition: BackendFontFreeType.hpp:175
float lsbDelta
Left offset after forced autohint. Internally used by getKerning()
Definition: BackendFontFreeType.hpp:174
float advance
Offset to move horizontally to the next character.
Definition: BackendFontFreeType.hpp:173
FloatRect bounds
Bounding rectangle of the glyph, in coordinates relative to the baseline.
Definition: BackendFontFreeType.hpp:176
Definition: BackendFontFreeType.hpp:215
unsigned int height
Height of the row.
Definition: BackendFontFreeType.hpp:220
unsigned int width
Current width of the row.
Definition: BackendFontFreeType.hpp:218
unsigned int top
Y position of the row into the texture.
Definition: BackendFontFreeType.hpp:219
Information about a glyph in the font.
Definition: Font.hpp:47