TextEngine class
#include <GGUIText/Public/TextEngine.h>
Fonts, shaping, and the glyph atlas, behind the UI core's text interfaces. See the file description.
Public types
- struct Stats
- What the engine has done since it was made.
- class AtlasHold
- While one of these exists no glyph is added, so the pages stay as they are: for whoever copies them while documents may be being updated on other threads.
- struct ShapedGlyph
- One glyph of a run as shaped, in the order it is drawn: for tests and tools.
Public static variables
- static uint32_t PageSize constexpr
- an atlas page's width and height, in pixels
Constructors, destructors, conversion operators
- TextEngine()
- An engine with no fonts; Initialize it before use.
- ~TextEngine()
- TextEngine(const TextEngine&) deleted
Public functions
- auto operator=(const TextEngine&) -> TextEngine& deleted
- auto Initialize() -> bool
- Start FreeType and HarfBuzz. False if they couldn't be; nothing loads until this is true. Calling it again does nothing.
- auto LoadFont(const char* path) -> FontID
- Load a font file (TrueType or OpenType). The first font loaded is font 0. NoFont if it can't be read, or the engine isn't initialized.
- auto FontCount() const -> uint32_t
- How many fonts are loaded.
- void AddFallbackFont(FontID font)
- A font to draw characters from when the font being used does not have them. Fallbacks are tried in the order they were added.
- void NameFont(std::string_view name, FontID font)
- The name styles ask for a font by (
.Font = FontNamed("mono"),font: mono). - void SetDefaultStyle(const FontStyle& style)
- The font text uses when its style class has none of its own.
- void SetClassStyle(std::string_view className, const FontStyle& style)
- The font a style class's text uses.
- auto Measurer() -> TextMeasurer
- What a document measures text with (UIContext::
SetTextMeasurer). It refers to this engine, which must outlive every document using it. - auto Glyphs() const -> const GlyphSource*
- What a document draws text from (UIContext::
SetGlyphSource). The same lifetime. - auto PageCount() const -> uint32_t
- How many atlas pages there are.
- auto Page(uint32_t index) const -> AtlasPage
- Atlas page
index. Read it while holding the atlas (AtlasHold) if documents may be updating. - auto TakePageChanges(uint32_t index, uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height) -> bool
- The rectangle of page
indexthat has been written since this was last called, and forget it: for whoever keeps a copy of the page (a texture) to update only that. - auto ReferenceSampler() const -> ReferenceTextures
- For the reference rasterizer: glyph primitives sample these pages.
- auto GetStats() const -> Stats
- What it has done so far.
- auto Inspect(uint64_t run) const -> std::vector<ShapedGlyph>
- The glyphs of
run(TextMetrics::Run); empty if it isn't kept.
Function documentation
bool GGUI:: TextEngine:: TakePageChanges(uint32_t index,
uint32_t& x,
uint32_t& y,
uint32_t& width,
uint32_t& height)
The rectangle of page index that has been written since this was last called, and forget it: for whoever keeps a copy of the page (a texture) to update only that.
False if nothing was. One caller.