|
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
|
Functions | |
| void | RegisterTtf (ImFont *font, const char *ttfPath) |
| Records a loaded font's TTF path so CssPx can work out its CSS-to-FreeType size ratio from the font's own metrics. | |
| float | CssPx (ImFont *font, float cssPx) |
| The ImGui+FreeType size whose em-square matches a CSS font-size. | |
| void DekiEditor::Fonts::RegisterTtf | ( | ImFont * | font, |
| const char * | ttfPath ) |
Records a loaded font's TTF path so CssPx can work out its CSS-to-FreeType size ratio from the font's own metrics.
Call ONCE per font, right after ImFontAtlas::AddFontFromFileTTF returns.
| float DekiEditor::Fonts::CssPx | ( | ImFont * | font, |
| float | cssPx ) |
The ImGui+FreeType size whose em-square matches a CSS font-size.
ImGui's FreeType wrapper uses FT_SIZE_REQUEST_TYPE_REAL_DIM, which takes pixel_size as the full glyph extent (ascender + |descender|), while CSS takes font-size as the em-square. The ratio differs per font (Inter ≈ 1.21, JetBrains Mono ≈ 1.32, Space Grotesk ≈ 1.26). For "13px CSS" of Inter, call CssPx(g_FontUI, 13.0f).
A fixed-width font moves to the nearest size whose character advance is a whole pixel (12.5 CSS px JetBrains Mono becomes 13.33, 8px per character), since FreeType rounds the advance and a fractional one spreads the letters apart.
Returns cssPx unchanged if the font was not registered.