15 bool g_initialized {};
22 "Portal::Text already initialized");
27 "Initializing Portal::Text...");
31 "Failed to initialize TypeFaceFoundry");
36 const auto& [family, style, pixel_size, atlas_size] = *config;
39 "Failed to set default font '{}{}{}'", family, style.empty() ?
"" :
" ", style);
43 "No default font configured for Portal::Text");
48 "Portal::Text initialized");
53 std::string_view text,
68 "Shutting down Portal::Text...");
72 g_initialized =
false;
74 "Portal::Text shutdown");
83 std::string_view family,
84 std::string_view style,
88 const auto path =
find_font(family, style);
91 "set_default_font: could not locate '{}{}{}' on this system",
93 style.empty() ?
"" :
" ",
109 atlas !=
nullptr,
"call set_default_font before get_default_atlas");
#define MF_ASSERT(comp, ctx, condition,...)
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
Rasterizes and packs glyphs from a FontFace into a TextureContainer.
GlyphAtlas * get_default_glyph_atlas() const
Return the default GlyphAtlas, or nullptr if set_default_font() has not been called successfully.
bool set_default_font(const std::string &path, uint32_t pixel_size, uint32_t atlas_size=512)
Locate a system font by family and style, then load it as the default.
static TypeFaceFoundry & instance()
void shutdown()
Release the FreeType library handle.
@ Init
Engine/subsystem initialization.
@ API
API calls from external code.
@ Portal
High-level user-facing API layer.
MAYAFLUX_API std::optional< std::string > find_font(std::string_view family, std::string_view style={})
Locate a system font file by family name and optional style.
bool is_initialized()
Returns true after a successful initialize() call.
LayoutResult lay_out(std::string_view text, GlyphAtlas &atlas, float pen_x, float pen_y, uint32_t wrap_w)
Lay out a UTF-8 string into a sequence of screen-space quads.
bool set_default_font(std::string_view family, std::string_view style, uint32_t pixel_size, uint32_t atlas_size)
Locate a system font by family and style, then load it as the default.
void shutdown()
Shutdown Portal::Text.
std::shared_ptr< LayoutResult > create_layout(std::string_view text, float pen_x, float pen_y, uint32_t wrap_w)
Lay out a UTF-8 string into screen-space glyph quads using the default atlas.
GlyphAtlas & get_default_atlas()
Return the default GlyphAtlas, or nullptr if set_default_font() has not been called successfully.