MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / SysFonts_DoRegister

Function SysFonts_DoRegister

src/SystemFonts.c:626–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626static int SysFonts_DoRegister(const cc_string* path, int faceIndex, SysFont_RegisterCallback callback) {
627 struct SysFont font;
628 FT_Open_Args args;
629 FT_Error err;
630 int flags, count;
631
632 if (SysFont_Init(path, &font, &args)) return 0;
633 err = FT_New_Face(ft_lib, &args, faceIndex, &font.face);
634 if (err) { SysFont_Done(&font); return 0; }
635
636 flags = font.face->style_flags;
637 count = font.face->num_faces;
638
639 if (flags == (FT_STYLE_FLAG_BOLD | FT_STYLE_FLAG_ITALIC)) {
640 SysFonts_Add(path, font.face, faceIndex, 'Z', "Bold Italic");
641 } else if (flags == FT_STYLE_FLAG_BOLD) {
642 SysFonts_Add(path, font.face, faceIndex, 'B', "Bold");
643 } else if (flags == FT_STYLE_FLAG_ITALIC) {
644 SysFonts_Add(path, font.face, faceIndex, 'I', "Italic");
645 } else if (flags == 0) {
646 SysFonts_Add(path, font.face, faceIndex, 'R', "Regular");
647 }
648
649 if (callback) callback(path);
650 FT_Done_Face(font.face);
651 return count;
652}
653
654cc_result SysFonts_Register(const cc_string* path, SysFont_RegisterCallback callback) {
655 cc_string entry, name, value;

Callers 1

SysFonts_RegisterFunction · 0.85

Calls 6

SysFont_InitFunction · 0.85
SysFont_DoneFunction · 0.85
SysFonts_AddFunction · 0.85
callbackFunction · 0.85
FT_Done_FaceFunction · 0.85
FT_New_FaceFunction · 0.50

Tested by

no test coverage detected