mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 00:26:36 +00:00
Fixed computation of ImFont::MetricsTotalSurface not taking oversampling into account
This commit is contained in:
parent
bd9868f447
commit
0828a1fd6c
@ -1752,7 +1752,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::SameLine(); ShowHelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)");
|
||||
ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
|
||||
ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
|
||||
ImGui::Text("Texture surface: %d pixels (approx)", font->MetricsTotalSurface);
|
||||
ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)sqrtf((int)font->MetricsTotalSurface), (int)sqrtf((int)font->MetricsTotalSurface));
|
||||
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
|
||||
{
|
||||
ImFontConfig* cfg = &font->ConfigData[config_i];
|
||||
|
@ -1456,7 +1456,7 @@ bool ImFontAtlas::Build()
|
||||
glyph.XAdvance = (pc.xadvance + cfg.GlyphExtraSpacing.x); // Bake spacing into XAdvance
|
||||
if (cfg.PixelSnapH)
|
||||
glyph.XAdvance = (float)(int)(glyph.XAdvance + 0.5f);
|
||||
dst_font->MetricsTotalSurface += (int)(glyph.X1 - glyph.X0 + 1.99f) * (int)(glyph.Y1 - glyph.Y0 + 1.99f); // +1 to account for average padding, +0.99 to round
|
||||
dst_font->MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * TexHeight + 1.99f); // +1 to account for average padding, +0.99 to round
|
||||
}
|
||||
}
|
||||
cfg.DstFont->BuildLookupTable();
|
||||
|
Loading…
Reference in New Issue
Block a user