3#ifndef GDK_GRAPHICS_EXT_FONT_H
4#define GDK_GRAPHICS_EXT_FONT_H
13namespace gdk::graphics::ext {
14 enum class font_sizing {
25 font_sizing
sizing = font_sizing::ascent_to_descent;
75 [[nodiscard]]
float kerning(
char32_t aLeft,
char32_t aRight)
const;
82 std::size_t x = 0, y = 0, width = 0, height = 0;
108 std::span<const texture_data::encoded_byte> aTrueTypeData,
122 font &operator=(const
font &) = delete;
126 std::unique_ptr<impl> m_pImpl;
float kerning(char32_t aLeft, char32_t aRight) const
additional spacing between two adjacent codepoints in pixels.
void clear()
empties the atlas back to the size it was constructed with.
std::size_t atlas_edge() const
the atlas's current edge length in texels. Changes when the atlas grows.
const glyph & fallback() const
the font's .notdef glyph, which most fonts draw as a visible box.
float line_height() const
baseline to baseline distance in pixels
font(std::span< const texture_data::encoded_byte > aTrueTypeData, float aPixelSize, font_settings aSettings={})
builds a font from the contents of a truetype or opentype file, or a collection
float ascent() const
baseline to the top of the tallest glyph, in pixels
texture_data::view atlas() const
view of the atlas texture
std::optional< atlas_region > atlas_changed_since(std::size_t aGeneration) const
which part of the atlas has changed since a given generation.
const glyph * try_get(char32_t aCodepoint)
the glyph for a codepoint or nullptr when the atlas has no room left for it.
float descent() const
baseline to the bottom of the lowest glyph, in pixels. Negative.
std::size_t atlas_generation() const
a number that changes whenever the atlas does.
a rectangle of the atlas, in texels
Definition font.h:81
float top
baseline to the quad's top edge, in pixels, up is positive
Definition font.h:50
float s0
atlas texture coordinates
Definition font.h:44
float width
quad width in pixels
Definition font.h:51
float t0
atlas texture coordinates
Definition font.h:45
float left
pen to the quad's left edge, in pixels
Definition font.h:49
float t1
atlas texture coordinates
Definition font.h:47
float s1
atlas texture coordinates
Definition font.h:46
float height
quad height in pixels
Definition font.h:52
float advance
how far the pen moves after this glyph, in pixels
Definition font.h:53
everything about a font that has a default
Definition font.h:20
font_sizing sizing
what the constructor's pixel size measures.
Definition font.h:25
std::size_t atlas_edge
the atlas starts square with this edge length
Definition font.h:28
std::size_t face
which font of a collection (.ttc, .otc) to use
Definition font.h:22
std::size_t max_atlas_edge
how far the atlas may grow
Definition font.h:31
provides a pointer a contiguous list of channel data representing 2D texture metadata that contains i...
Definition texture_data.h:27
what the core takes: decoded channel data and the metadata describing it