MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ load()

bool MayaFlux::Portal::Text::FontFace::load ( const std::string &  path,
FT_Long  index = 0 
)

Load a font file from disk.

Parameters
pathAbsolute or relative path to a TTF, OTF, or collection file.
indexFace index within a collection; 0 for ordinary font files.
Returns
true on success.
Precondition
FreeTypeContext::instance().is_initialized() must be true.

Definition at line 8 of file FontFace.cpp.

9{
10 unload();
11
12 auto& ctx = TypeFaceFoundry::instance();
13 if (!ctx.is_initialized()) {
15 "FontFace::load called before TypeFaceFoundry is initialized");
16 return false;
17 }
18
19 if (const FT_Error err = FT_New_Face(ctx.get_library(), path.c_str(), index, &m_face);
20 err != 0) {
22 "FT_New_Face failed for '{}' (index {}) with error {}",
23 path, index, static_cast<int>(err));
24 m_face = nullptr;
25 return false;
26 }
27
28 m_path = path;
29
31 "FontFace loaded: '{}' ({} glyphs)", path, m_face->num_glyphs);
32 return true;
33}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
const std::string & path() const
Path passed to load(), empty if not yet loaded.
Definition FontFace.hpp:64
void unload()
Release the FT_Face handle.
Definition FontFace.cpp:35
@ API
API calls from external code.
@ Portal
High-level user-facing API layer.

References MayaFlux::Journal::API, MayaFlux::Portal::Text::TypeFaceFoundry::instance(), m_face, m_path, MF_ERROR, MF_INFO, path(), MayaFlux::Journal::Portal, and unload().

+ Here is the call graph for this function: