25#ifndef TGUI_BACKEND_FONT_RAYLIB_HPP
26#define TGUI_BACKEND_FONT_RAYLIB_HPP
28#include <TGUI/Config.hpp>
29#if !TGUI_BUILD_AS_CXX_MODULE
30 #include <TGUI/Backend/Font/BackendFont.hpp>
35#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
36 #include <unordered_map>
41TGUI_MODULE_EXPORT
namespace tgui
59 bool loadFromMemory(std::unique_ptr<std::uint8_t[]> data, std::size_t sizeInBytes)
override;
60 using BackendFont::loadFromMemory;
69 TGUI_NODISCARD
bool hasGlyph(
char32_t codePoint)
const override;
84 TGUI_NODISCARD
FontGlyph getGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness = 0)
override;
100 TGUI_NODISCARD
float getKerning(
char32_t first,
char32_t second,
unsigned int characterSize,
bool bold)
override;
129 TGUI_NODISCARD
float getAscent(
unsigned int characterSize)
override;
138 TGUI_NODISCARD
float getDescent(
unsigned int characterSize)
override;
170 TGUI_NODISCARD std::shared_ptr<BackendTexture>
getTexture(
unsigned int characterSize,
unsigned int& textureVersion)
override;
199 void setFontScale(
float scale)
override;
207 FontGlyph loadGlyph(
const GlyphInfo& glyphInfo,
char32_t codePoint,
unsigned int scaledTextSize,
bool bold,
float scaledOutlineThickness);
212 TGUI_NODISCARD
UIntRect findAvailableGlyphRect(
unsigned int width,
unsigned int height);
219 int estimateFontSize(
unsigned int scaledTextSize);
226 Row(
unsigned int rowTop,
unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight) {}
233 std::unordered_map<std::uint64_t, FontGlyph> m_glyphs;
234 unsigned int m_nextRow = 3;
235 std::vector<Row> m_rows;
237 std::unique_ptr<std::uint8_t[]> m_fileContents;
238 std::size_t m_fileSize = 0;
240 std::unique_ptr<std::uint8_t[]> m_pixels;
241 std::shared_ptr<BackendTexture> m_texture;
242 unsigned int m_textureSize = 0;
243 unsigned int m_textureVersion = 0;
245 std::unordered_map<unsigned int, int> m_cachedAscents;
246 std::unordered_map<unsigned int, int> m_correctedTextSizes;
Font implementations that uses Raylib to load glyphs.
Definition BackendFontRaylib.hpp:48
float getFontHeight(unsigned int characterSize) override
Returns the height required to render a line of text.
float getUnderlinePosition(unsigned int characterSize) override
Get the position of the underline.
std::shared_ptr< BackendTexture > getTexture(unsigned int characterSize, unsigned int &textureVersion) override
Returns the texture that is used to store glyphs of the given character size.
FontGlyph getGlyph(char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override
Retrieve a glyph of the font.
Vector2u getTextureSize(unsigned int characterSize) override
Returns the size of the texture that is used to store glyphs of the given character size.
float getUnderlineThickness(unsigned int characterSize) override
Get the thickness of the underline.
bool hasGlyph(char32_t codePoint) const override
Returns whether a font contains a certain glyph.
float getLineSpacing(unsigned int characterSize) override
Returns the line spacing.
float getKerning(char32_t first, char32_t second, unsigned int characterSize, bool bold) override
Returns the kerning offset of two glyphs.
float getDescent(unsigned int characterSize) override
Returns the maximum height of a glyph below the baseline.
void setSmooth(bool smooth) override
Enable or disable the smooth filter.
float getAscent(unsigned int characterSize) override
Returns the maximum height of a glyph above the baseline.
bool loadFromMemory(std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes) override
Loads a font from memory.
Base class for font implementations that depend on the backend.
Definition BackendFont.hpp:45
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
Definition BackendFontRaylib.hpp:225
unsigned int width
Current width of the row.
Definition BackendFontRaylib.hpp:228
unsigned int height
Height of the row.
Definition BackendFontRaylib.hpp:230
unsigned int top
Y position of the row into the texture.
Definition BackendFontRaylib.hpp:229
Information about a glyph in the font.
Definition Font.hpp:48