|
@@ -1386,7 +1386,7 @@ bool ImFontAtlas::Build()
|
|
{
|
|
{
|
|
ImFontConfig& cfg = ConfigData[input_i];
|
|
ImFontConfig& cfg = ConfigData[input_i];
|
|
ImFontTempBuildData& tmp = tmp_array[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);
|
|
float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels);
|
|
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
|
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
|
@@ -1403,6 +1403,7 @@ bool ImFontAtlas::Build()
|
|
dst_font->Ascent = ascent;
|
|
dst_font->Ascent = ascent;
|
|
dst_font->Descent = descent;
|
|
dst_font->Descent = descent;
|
|
dst_font->Glyphs.resize(0);
|
|
dst_font->Glyphs.resize(0);
|
|
|
|
+ dst_font->MetricsTotalSurface = 0;
|
|
}
|
|
}
|
|
dst_font->ConfigDataCount++;
|
|
dst_font->ConfigDataCount++;
|
|
float off_y = (cfg.MergeMode && cfg.MergeGlyphCenterV) ? (ascent - dst_font->Ascent) * 0.5f : 0.0f;
|
|
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
|
|
glyph.XAdvance = (pc.xadvance + cfg.GlyphExtraSpacing.x); // Bake spacing into XAdvance
|
|
if (cfg.PixelSnapH)
|
|
if (cfg.PixelSnapH)
|
|
glyph.XAdvance = (float)(int)(glyph.XAdvance + 0.5f);
|
|
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();
|
|
cfg.DstFont->BuildLookupTable();
|
|
@@ -1703,6 +1705,7 @@ void ImFont::Clear()
|
|
ConfigData = NULL;
|
|
ConfigData = NULL;
|
|
ContainerAtlas = NULL;
|
|
ContainerAtlas = NULL;
|
|
Ascent = Descent = 0.0f;
|
|
Ascent = Descent = 0.0f;
|
|
|
|
+ MetricsTotalSurface = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void ImFont::BuildLookupTable()
|
|
void ImFont::BuildLookupTable()
|