MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / AddFontFromFileTTF

Method AddFontFromFileTTF

Dependencies/ImGui/src/imgui_draw.cpp:2668–2687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2666}
2667
2668ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
2669{
2670 IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
2671 size_t data_size = 0;
2672 void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
2673 if (!data)
2674 {
2675 IM_ASSERT_USER_ERROR(0, "Could not load font file!");
2676 return NULL;
2677 }
2678 ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
2679 if (font_cfg.Name[0] == '\0')
2680 {
2681 // Store a short copy of filename into into the font name for convenience
2682 const char* p;
2683 for (p = filename + ImStrlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
2684 ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels);
2685 }
2686 return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
2687}
2688
2689// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
2690ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* font_data, int font_data_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)

Callers 1

LoadFontMethod · 0.80

Calls 3

ImFileLoadToMemoryFunction · 0.85
ImFontConfigClass · 0.85
ImFormatStringFunction · 0.85

Tested by

no test coverage detected