mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
ImFont: Store the texture surface used to get an idea of how costly each font is.
This commit is contained in:
@ -1386,7 +1386,7 @@ bool ImFontAtlas::Build()
|
||||
{
|
||||
ImFontConfig& cfg = ConfigData[input_i];
|
||||
ImFontTempBuildData& tmp = tmp_array[input_i];
|
||||
ImFont* dst_font = cfg.DstFont;
|
||||
ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true)
|
||||
|
||||
float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels);
|
||||
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
||||
@ -1403,6 +1403,7 @@ bool ImFontAtlas::Build()
|
||||
dst_font->Ascent = ascent;
|
||||
dst_font->Descent = descent;
|
||||
dst_font->Glyphs.resize(0);
|
||||
dst_font->MetricsTotalSurface = 0;
|
||||
}
|
||||
dst_font->ConfigDataCount++;
|
||||
float off_y = (cfg.MergeMode && cfg.MergeGlyphCenterV) ? (ascent - dst_font->Ascent) * 0.5f : 0.0f;
|
||||
@ -1435,6 +1436,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
|
||||
}
|
||||
}
|
||||
cfg.DstFont->BuildLookupTable();
|
||||
@ -1703,6 +1705,7 @@ void ImFont::Clear()
|
||||
ConfigData = NULL;
|
||||
ContainerAtlas = NULL;
|
||||
Ascent = Descent = 0.0f;
|
||||
MetricsTotalSurface = 0;
|
||||
}
|
||||
|
||||
void ImFont::BuildLookupTable()
|
||||
|
Reference in New Issue
Block a user