| 2133 | } |
| 2134 | |
| 2135 | ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) |
| 2136 | { |
| 2137 | IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); |
| 2138 | size_t data_size = 0; |
| 2139 | void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0); |
| 2140 | if (!data) |
| 2141 | { |
| 2142 | IM_ASSERT_USER_ERROR(0, "Could not load font file!"); |
| 2143 | return NULL; |
| 2144 | } |
| 2145 | ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); |
| 2146 | if (font_cfg.Name[0] == '\0') |
| 2147 | { |
| 2148 | // Store a short copy of filename into into the font name for convenience |
| 2149 | const char* p; |
| 2150 | for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} |
| 2151 | ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels); |
| 2152 | } |
| 2153 | return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges); |
| 2154 | } |
| 2155 | |
| 2156 | // NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). |
| 2157 | ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) |
nothing calls this directly
no test coverage detected