26#ifndef TGUI_BACKEND_FONT_SDL_TTF_HPP
27#define TGUI_BACKEND_FONT_SDL_TTF_HPP
29#include <TGUI/Backend/Font/BackendFont.hpp>
30#include <TGUI/extlibs/IncludeSDL.hpp>
32#include <unordered_map>
59 virtual bool loadFromMemory(std::unique_ptr<std::uint8_t[]> data, std::size_t sizeInBytes)
override;
70 bool hasGlyph(
char32_t codePoint)
const override;
86 virtual FontGlyph getGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness = 0)
override;
103 virtual float getKerning(
char32_t first,
char32_t second,
unsigned int characterSize,
bool bold)
override;
149 std::shared_ptr<BackendTexture>
getTexture(
unsigned int characterSize)
override;
170 TTF_Font* getInternalFont(
unsigned int characterSize);
179 std::pair<int, int> getUnderlineInfo(
unsigned int characterSize);
185 IntRect findAvailableGlyphRect(
unsigned int width,
unsigned int height);
193 Row(
unsigned int rowTop,
unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight) {}
200 std::unique_ptr<std::uint8_t[]> m_fileContents;
201 std::size_t m_fileSize = 0;
204 std::unordered_map<unsigned int, TTF_Font*> m_fonts;
205 std::unordered_map<unsigned int, bool> m_lastBoldFlag;
206 std::unordered_map<unsigned int, float> m_lastOutlineThickness;
208 std::unordered_map<unsigned int, std::pair<int, int>> m_cachedUnderlineInfo;
210 std::unordered_map<std::uint64_t, FontGlyph> m_glyphs;
211 unsigned int m_nextRow = 3;
212 std::vector<Row> m_rows;
214 std::unique_ptr<std::uint8_t[]> m_pixels;
215 std::shared_ptr<BackendTexture> m_texture;
216 unsigned int m_textureSize = 0;
217 bool m_textureUpToDate =
false;
Font implementations that uses SDL_ttf to load glyphs.
Definition: BackendFontSDLttf.hpp:42
float getUnderlinePosition(unsigned int characterSize) override
Get the position of the underline.
float getUnderlineThickness(unsigned int characterSize) override
Get the thickness of the underline.
virtual float getLineSpacing(unsigned int characterSize) override
Returns the line spacing.
std::shared_ptr< BackendTexture > getTexture(unsigned int characterSize) override
Returns the texture that is used to store glyphs of the given character size.
virtual bool loadFromMemory(std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes) override
Loads a font from memory.
void setSmooth(bool smooth) override
Enable or disable the smooth filter.
virtual float getKerning(char32_t first, char32_t second, unsigned int characterSize, bool bold) override
Returns the kerning offset of two glyphs.
virtual FontGlyph getGlyph(char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override
Retrieve a glyph of the font.
bool hasGlyph(char32_t codePoint) const override
Returns whether a font contains a certain glyph.
~BackendFontSDLttf()
Destructor that cleans up the SDL resources.
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
Information about a glyph in the font.
Definition: Font.hpp:47