MCPcopy Create free account
hub / github.com/defold/defold / FontLoadFromMemory

Function FontLoadFromMemory

engine/font/src/font.cpp:58–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58HFont FontLoadFromMemory(const char* path, void* data, uint32_t data_size, bool allocate)
59{
60 Font* font = 0;
61
62 FontType type = GetFontType(path);
63 switch(type)
64 {
65 case FONT_TYPE_STBTTF:
66 case FONT_TYPE_STBOTF: font = FontLoadFromMemoryTTF(path, data, data_size, allocate); break;
67 default:
68 {
69 const char* ext = strrchr(path, '.');
70 dmLogError("Unsupported file type: '%s'", ext?ext:"");
71 return 0;
72 }
73 }
74
75 if (font)
76 {
77 font->m_Type = type;
78 font->m_Path = strdup(path);
79 font->m_PathHash= dmHashString32(path);
80 }
81
82 return font;
83}
84
85HFont FontLoadFromPath(const char* path)
86{

Callers 3

FontLoadFromPathFunction · 0.85
TTF_CreateFunction · 0.85
TTF_RecreateFunction · 0.85

Calls 2

GetFontTypeFunction · 0.85
FontLoadFromMemoryTTFFunction · 0.85

Tested by

no test coverage detected