MayaFlux
0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
FontFace.cpp
Go to the documentation of this file.
1
#include "
FontFace.hpp
"
2
3
#include "
MayaFlux/Journal/Archivist.hpp
"
4
#include "
TypeFaceFoundry.hpp
"
5
6
namespace
MayaFlux::Portal::Text
{
7
8
bool
FontFace::load
(
const
std::string& path, FT_Long index)
9
{
10
unload
();
11
12
auto
& ctx =
TypeFaceFoundry::instance
();
13
if
(!ctx.is_initialized()) {
14
MF_ERROR
(
Journal::Component::Portal
,
Journal::Context::API
,
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) {
21
MF_ERROR
(
Journal::Component::Portal
,
Journal::Context::API
,
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
30
MF_INFO
(
Journal::Component::Portal
,
Journal::Context::API
,
31
"FontFace loaded: '{}' ({} glyphs)"
,
path
,
m_face
->num_glyphs);
32
return
true
;
33
}
34
35
void
FontFace::unload
()
36
{
37
if
(!
m_face
) {
38
return
;
39
}
40
41
FT_Done_Face(
m_face
);
42
m_face
=
nullptr
;
43
m_path
.clear();
44
}
45
46
}
// namespace MayaFlux::Portal::Text
MF_INFO
#define MF_INFO(comp, ctx,...)
Definition
Archivist.hpp:373
MF_ERROR
#define MF_ERROR(comp, ctx,...)
Definition
Archivist.hpp:381
Archivist.hpp
FontFace.hpp
TypeFaceFoundry.hpp
MayaFlux::Portal::Text::FontFace::path
const std::string & path() const
Path passed to load(), empty if not yet loaded.
Definition
FontFace.hpp:64
MayaFlux::Portal::Text::FontFace::m_face
FT_Face m_face
Definition
FontFace.hpp:67
MayaFlux::Portal::Text::FontFace::m_path
std::string m_path
Definition
FontFace.hpp:68
MayaFlux::Portal::Text::FontFace::load
bool load(const std::string &path, FT_Long index=0)
Load a font file from disk.
Definition
FontFace.cpp:8
MayaFlux::Portal::Text::FontFace::unload
void unload()
Release the FT_Face handle.
Definition
FontFace.cpp:35
MayaFlux::Portal::Text::TypeFaceFoundry::instance
static TypeFaceFoundry & instance()
Definition
TypeFaceFoundry.hpp:21
MayaFlux::Journal::Context::API
@ API
API calls from external code.
MayaFlux::Journal::Component::Portal
@ Portal
High-level user-facing API layer.
MayaFlux::Portal::Text
Definition
FontDiscovery.cpp:11
src
MayaFlux
Portal
Text
FontFace.cpp
Generated by
1.9.8