utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
font_sized.hpp
1/*
2** ETIB PROJECT, 2026
3** utility
4** File description:
5** font_sized
6*/
7
8#pragma once
9
10#include <map>
11#include <memory>
12
13#include <utility/graphic/texture.hpp>
14
15// Types & structs
17#include <utility/graphic/text/glyph.hpp>
18
19namespace utility::graphic
20{
32 {
33 public:
47 FontSized(uint32_t fontSize, void *face);
48
53 ~FontSized() = default;
54
73 std::shared_ptr<Texture> getAtlas(bool shouldRegenerate = false);
74
82 bool hasGlyph(uint32_t codePoint) const;
83
101 Glyph generateGlyph(uint32_t codePoint);
102
120 std::vector<Glyph> generateGlyphs(const codePointString &codePoints);
121
129 Glyph measureGlyph(uint32_t codePoint) const;
130
136
142
148
149 protected:
160 void generateAtlas();
161
167 void resizeAtlas(int newHeight);
168
172 std::shared_ptr<Texture> _generatedAtlas;
173
177 uint32_t _fontSize;
178
187
191 std::map<uint32_t, Glyph> _generatedGlyphs;
192
197
202
206 int _penX;
207
211 int _penY;
212
217 };
218} // namespace utility::graphic
The FontSized class represents a specific size of a font face, managing the glyphs and texture atlas ...
std::map< uint32_t, Glyph > _generatedGlyphs
A map storing the generated glyphs for this font size.
uint32_t _fontSize
The font size in points for this FontSized object.
void resizeAtlas(int newHeight)
Grow the atlas to the given new height, preserving existing glyphs.
std::shared_ptr< Texture > getAtlas(bool shouldRegenerate=false)
Retrieves the texture atlas containing the rendered glyphs for this font size.
std::shared_ptr< Texture > _generatedAtlas
The font size in points for this FontSized object.
int _atlasWidth
The width of the texture atlas.
void generateAtlas()
Generates the texture atlas based on the currently generated glyphs for this font size.
int _penY
The y-coordinate of the pen for glyph placement.
void * _correspondingFace
The corresponding FreeType face associated with this FontSized object.
int _rowHeight
The height of each row in the texture atlas.
~FontSized()=default
Destructs the FontSized object, releasing any allocated resources.
int _atlasHeight
The height of the texture atlas.
float _descender
The descender value for the font size, representing the depth of the lowest glyph below the baseline.
Glyph generateGlyph(uint32_t codePoint)
Generates a glyph for a specific Unicode code point and adds it to the texture atlas.
std::vector< Glyph > generateGlyphs(const codePointString &codePoints)
Generates glyphs for a string of Unicode code points and adds them to the texture atlas.
float _ascender
The ascender value for the font size, representing the height of the tallest glyph above the baseline...
Glyph measureGlyph(uint32_t codePoint) const
Compute glyph metrics for a code point without rasterizing or mutating the texture atlas.
bool hasGlyph(uint32_t codePoint) const
Checks whether a glyph has already been generated for this font size.
float _lineHeight
The line height value for the font size, representing the vertical distance between lines of text.
int _penX
The x-coordinate of the pen for glyph placement.
Code point definitions for text rendering.
std::vector< uint32_t > codePointString
A type representing a string of Unicode code points.
The Glyph struct represents a single character's visual representation in a font atlas.
Definition glyph.hpp:29