MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / AddFontDefault

Method AddFontDefault

ImGUI GLFW Tutorial/imgui/imgui_draw.cpp:2109–2128  ·  view source on GitHub ↗

Load embedded ProggyClean.ttf at size 13, disable oversampling

Source from the content-addressed store, hash-verified

2107
2108// Load embedded ProggyClean.ttf at size 13, disable oversampling
2109ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
2110{
2111 ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
2112 if (!font_cfg_template)
2113 {
2114 font_cfg.OversampleH = font_cfg.OversampleV = 1;
2115 font_cfg.PixelSnapH = true;
2116 }
2117 if (font_cfg.SizePixels <= 0.0f)
2118 font_cfg.SizePixels = 13.0f * 1.0f;
2119 if (font_cfg.Name[0] == '\0')
2120 ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
2121 font_cfg.EllipsisChar = (ImWchar)0x0085;
2122 font_cfg.GlyphOffset.y = 1.0f * IM_FLOOR(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units
2123
2124 const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
2125 const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
2126 ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
2127 return font;
2128}
2129
2130ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
2131{

Callers

nothing calls this directly

Calls 3

ImFontConfigClass · 0.70
ImFormatStringFunction · 0.70

Tested by

no test coverage detected