|
gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
|
a truetype font More...
#include <font.h>
Classes | |
| struct | glyph |
| struct | atlas_region |
| a rectangle of the atlas, in texels More... | |
Public Member Functions | |
| const glyph * | try_get (char32_t aCodepoint) |
| the glyph for a codepoint or nullptr when the atlas has no room left for it. | |
| const glyph & | fallback () const |
| the font's .notdef glyph, which most fonts draw as a visible box. | |
| void | clear () |
| empties the atlas back to the size it was constructed with. | |
| float | kerning (char32_t aLeft, char32_t aRight) const |
| additional spacing between two adjacent codepoints 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. | |
| std::size_t | atlas_generation () const |
| a number that changes whenever the atlas does. | |
| float | line_height () const |
| baseline to baseline distance in pixels | |
| float | ascent () const |
| baseline to the top of the tallest glyph, in pixels | |
| float | descent () const |
| baseline to the bottom of the lowest glyph, in pixels. Negative. | |
| 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 | |
| std::size_t | atlas_edge () const |
| the atlas's current edge length in texels. Changes when the atlas grows. | |
| font (font &&) noexcept | |
| font & | operator= (font &&) noexcept |
| font (const font &)=delete | |
| font & | operator= (const font &)=delete |
a truetype font
Glyphs are rasterised the first time they are asked for and packed into a single atlas texture, rather than a fixed set dont up front.
The atlas is a single channel (texture_data::format::grey) coverage map. Upload it to a texture with atlas(), and re-upload when atlas_generation() differs from the one last uploaded.
| gdk::graphics::ext::font::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
| aTrueTypeData | the bytes of a .ttf, .otf, .ttc or .otc. Copied: the font owns its own copy for its lifetime |
| aPixelSize | the size to rasterise at, in pixels. Of what is aSettings.sizing: ascent to descent unless told otherwise |
| aSettings | the face, the sizing and the atlas's bounds, all defaulted. |
| void gdk::graphics::ext::font::clear | ( | ) |
empties the atlas back to the size it was constructed with.
|
nodiscard |
the font's .notdef glyph, which most fonts draw as a visible box.
Always present: it is rasterised at construction and put back after every growth and every clear, so it is there to draw even when nothing else will fit. A caller that wants tofu where try_get() came back empty asks for it, rather than being handed it silently.
|
nodiscard |
the glyph for a codepoint or nullptr when the atlas has no room left for it.