mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 13:37:00 +00:00
ImFont: Tweaking layout, shaving bit of alignment and simple hot/cot split
This commit is contained in:
parent
44fb99542f
commit
a20d69f9ce
31
imgui.h
31
imgui.h
@ -1286,15 +1286,6 @@ struct ImFontAtlas
|
|||||||
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
||||||
struct ImFont
|
struct ImFont
|
||||||
{
|
{
|
||||||
// Members: Settings
|
|
||||||
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
|
|
||||||
float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
|
||||||
ImVec2 DisplayOffset; // = (0.0f,1.0f) // Offset font rendering by xx pixels
|
|
||||||
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
|
||||||
ImFontConfig* ConfigData; // // Pointer within ImFontAtlas->ConfigData
|
|
||||||
int ConfigDataCount; //
|
|
||||||
|
|
||||||
// Members: Runtime data
|
|
||||||
struct Glyph
|
struct Glyph
|
||||||
{
|
{
|
||||||
ImWchar Codepoint;
|
ImWchar Codepoint;
|
||||||
@ -1302,13 +1293,23 @@ struct ImFont
|
|||||||
float X0, Y0, X1, Y1;
|
float X0, Y0, X1, Y1;
|
||||||
float U0, V0, U1, V1; // Texture coordinates
|
float U0, V0, U1, V1; // Texture coordinates
|
||||||
};
|
};
|
||||||
float Ascent, Descent; // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
|
||||||
ImFontAtlas* ContainerAtlas; // What we has been loaded into
|
// Members: Hot ~62/78 bytes
|
||||||
ImVector<Glyph> Glyphs;
|
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
|
||||||
|
float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
||||||
|
ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels
|
||||||
|
ImVector<Glyph> Glyphs; // // All glyphs.
|
||||||
|
ImVector<float> IndexXAdvance; // // Sparse. Glyphs->XAdvance in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
||||||
|
ImVector<int> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
|
||||||
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
||||||
float FallbackXAdvance; //
|
float FallbackXAdvance; // == FallbackGlyph->XAdvance
|
||||||
ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
|
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
||||||
ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point.
|
|
||||||
|
// Members: Cold ~18/26 bytes
|
||||||
|
short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
||||||
|
ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData
|
||||||
|
ImFontAtlas* ContainerAtlas; // // What we has been loaded into
|
||||||
|
float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
IMGUI_API ImFont();
|
IMGUI_API ImFont();
|
||||||
|
@ -1725,7 +1725,7 @@ const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const
|
|||||||
{
|
{
|
||||||
const int i = IndexLookup[c];
|
const int i = IndexLookup[c];
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
return &Glyphs[i];
|
return &Glyphs.Data[i];
|
||||||
}
|
}
|
||||||
return FallbackGlyph;
|
return FallbackGlyph;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user