MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / AddFontFromFileTTF

Method AddFontFromFileTTF

include/imgui/imgui_draw.cpp:3224–3247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3222}
3223
3224ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
3225{
3226 IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
3227 size_t data_size = 0;
3228 void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
3229 if (!data)
3230 {
3231 if (font_cfg_template == NULL || (font_cfg_template->Flags & ImFontFlags_NoLoadError) == 0)
3232 {
3233 IMGUI_DEBUG_LOG("While loading '%s'\n", filename);
3234 IM_ASSERT_USER_ERROR(0, "Could not load font file!");
3235 }
3236 return NULL;
3237 }
3238 ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3239 if (font_cfg.Name[0] == '\0')
3240 {
3241 // Store a short copy of filename into the font name for convenience
3242 const char* p;
3243 for (p = filename + ImStrlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
3244 ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "%s", p);
3245 }
3246 return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
3247}
3248
3249// NB: Transfer ownership of 'font_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
3250ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* font_data, int font_data_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)

Callers

nothing calls this directly

Calls 3

ImFileLoadToMemoryFunction · 0.85
ImFontConfigClass · 0.85
ImFormatStringFunction · 0.85

Tested by

no test coverage detected