MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / AddFontDefaultBitmap

Method AddFontDefaultBitmap

imgui_tiny_app/imgui/imgui_draw.cpp:3147–3168  ·  view source on GitHub ↗

Load embedded ProggyClean.ttf. Default size 13, disable oversampling. If you want a similar font which may be better scaled, consider using AddFontDefaultVector().

Source from the content-addressed store, hash-verified

3145// Load embedded ProggyClean.ttf. Default size 13, disable oversampling.
3146// If you want a similar font which may be better scaled, consider using AddFontDefaultVector().
3147ImFont* ImFontAtlas::AddFontDefaultBitmap(const ImFontConfig* font_cfg_template)
3148{
3149#ifndef IMGUI_DISABLE_DEFAULT_FONT
3150 ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3151 if (!font_cfg_template)
3152 font_cfg.PixelSnapH = true; // Prevents sub-integer scaling factors at lower-level layers.
3153 if (font_cfg.SizePixels <= 0.0f)
3154 font_cfg.SizePixels = 13.0f; // This only serves (1) as a reference for GlyphOffset.y setting and (2) as a default for pre-1.92 backend.
3155 if (font_cfg.Name[0] == '\0')
3156 ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "ProggyClean.ttf");
3157 font_cfg.EllipsisChar = (ImWchar)0x0085;
3158 font_cfg.GlyphOffset.y += 1.0f * (font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units
3159
3160 int ttf_compressed_size = 0;
3161 const char* ttf_compressed = GetDefaultCompressedFontDataProggyClean(&ttf_compressed_size);
3162 return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg);
3163#else
3164 IM_ASSERT(0 && "Function is disabled in this build.");
3165 IM_UNUSED(font_cfg_template);
3166 return NULL;
3167#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
3168}
3169
3170// Load a minimal version of ProggyForever, designed to match our good old ProggyClean, but nicely scalable.
3171// (See build script in https://github.com/ocornut/proggyforever for details)

Callers

nothing calls this directly

Calls 3

ImFontConfigClass · 0.85
ImFormatStringFunction · 0.85

Tested by

no test coverage detected