mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
ImFont: Added FindGlyphNoFallback. Fixed MergeMode broken by 1ef1acbd8d
This commit is contained in:
@ -1841,7 +1841,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
continue;
|
||||
|
||||
const int codepoint = range.first_unicode_codepoint_in_range + char_idx;
|
||||
if (cfg.MergeMode && dst_font->FindGlyph((unsigned short)codepoint))
|
||||
if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint))
|
||||
continue;
|
||||
|
||||
stbtt_aligned_quad q;
|
||||
@ -2205,8 +2205,7 @@ void ImFont::BuildLookupTable()
|
||||
IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1);
|
||||
}
|
||||
|
||||
FallbackGlyph = NULL;
|
||||
FallbackGlyph = FindGlyph(FallbackChar);
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
@ -2268,13 +2267,22 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
|
||||
{
|
||||
if (c < IndexLookup.Size)
|
||||
{
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i != (unsigned short)-1)
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
return FallbackGlyph;
|
||||
if (c >= IndexLookup.Size)
|
||||
return FallbackGlyph;
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i == (unsigned short)-1)
|
||||
return FallbackGlyph;
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
|
||||
{
|
||||
if (c >= IndexLookup.Size)
|
||||
return NULL;
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i == (unsigned short)-1)
|
||||
return NULL;
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const
|
||||
|
Reference in New Issue
Block a user