18#include <utility/system_io/file.hpp>
20#include <utility/graphic/text/font_sized.hpp>
22namespace utility::graphic
78 Font(
const std::vector<File> &fontAssets);
196 bool hasGlyph(
char32_t codepoint)
const;
209 std::function<void(std::string, std::shared_ptr<Texture>)>
260 std::map<FontSizedKey, std::shared_ptr<FontSized>>
_sizes;
270 std::map<std::string, std::shared_ptr<std::vector<uint8_t>>>
The Font class represents a font resource that can be used to render text.
std::vector< std::string > getFontPaths(void) const
Retrieves the paths of the loaded font assets.
float getLineHeight(uint32_t fontSize) const
Retrieves the line height for the specified font size.
std::map< FontSizedKey, std::shared_ptr< FontSized > > _sizes
Map of font sizes to their corresponding FontSized objects.
bool hasGlyph(char32_t codepoint) const
Checks if the font contains a glyph for the specified Unicode code point.
~Font()
Destructs the Font object, releasing any allocated resources.
float getAscender(uint32_t fontSize) const
Retrieves the ascender value for the specified font size.
bool isLoaded(void) const
Checks if the font has been successfully loaded.
std::string _getFaceNameForGlyph(uint32_t codePoint) const
Retrieves the font face name associated with a specific Unicode code point.
std::map< std::string, void * > _faces
Map of font paths to their corresponding FreeType face objects.
std::function< void(std::string, std::shared_ptr< Texture >)> onNewTextureCreated
Member function to set a callback that is called when a new texture atlas is created for a font size.
std::map< std::string, std::shared_ptr< std::vector< uint8_t > > > _faceBuffers
In-memory buffers backing FreeType faces.
float getDescender(uint32_t fontSize) const
Retrieves the descender value for the specified font size.
math::Vector2F measureText(uint32_t fontSize, const codePointString &codePoints) const
Measure the bounding size of a string of code points without rasterizing or mutating any glyph atlas.
void * _ftLibrary
FreeType library instance used for managing font resources.
std::vector< Glyph > processCodePoints(uint32_t fontSize, const codePointString &codePoints)
Processes a string of Unicode code points to generate glyphs for rendering text.
3D vector class inheriting from glm::vec3.
std::vector< uint32_t > codePointString
A type representing a string of Unicode code points.
A struct representing a unique key for identifying a specific font face and size combination.
uint32_t fontSize
The size of the font in points (e.g., 12, 14, 16).
std::string faceName
The name of the font face (e.g., "Arial", "Times New Roman").
bool operator<(const FontSizedKey &other) const
Comparison operator to allow FontSizedKey to be used as a key in std::map or other associative contai...