Remove unneeded extra parameter from ImFont::FindGlyph()

This commit is contained in:
ocornut 2014-11-29 00:04:05 +00:00
parent e4a79e9fc8
commit e9aead09cb
2 changed files with 7 additions and 7 deletions

View File

@ -5821,7 +5821,7 @@ void ImFont::BuildLookupTable()
IndexLookup[Glyphs[i].Id] = (int)i; IndexLookup[Glyphs[i].Id] = (int)i;
} }
const ImFont::FntGlyph* ImFont::FindGlyph(unsigned short c, const ImFont::FntGlyph* fallback) const const ImFont::FntGlyph* ImFont::FindGlyph(unsigned short c) const
{ {
if (c < (int)IndexLookup.size()) if (c < (int)IndexLookup.size())
{ {
@ -5829,7 +5829,7 @@ const ImFont::FntGlyph* ImFont::FindGlyph(unsigned short c, const ImFont::FntGly
if (i >= 0 && i < (int)GlyphsCount) if (i >= 0 && i < (int)GlyphsCount)
return &Glyphs[i]; return &Glyphs[i];
} }
return fallback; return FallbackGlyph;
} }
// Convert UTF-8 to 32-bits character, process single character input. // Convert UTF-8 to 32-bits character, process single character input.
@ -6045,7 +6045,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
} }
else else
{ {
if (const FntGlyph* glyph = FindGlyph((unsigned short)c, FallbackGlyph)) if (const FntGlyph* glyph = FindGlyph((unsigned short)c))
char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale; char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale;
} }
@ -6158,7 +6158,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
if (const FntGlyph* glyph = FindGlyph((unsigned short)' ')) if (const FntGlyph* glyph = FindGlyph((unsigned short)' '))
char_width = (glyph->XAdvance + Info->SpacingHoriz) * 4 * scale; char_width = (glyph->XAdvance + Info->SpacingHoriz) * 4 * scale;
} }
else if (const FntGlyph* glyph = FindGlyph((unsigned short)c, FallbackGlyph)) else if (const FntGlyph* glyph = FindGlyph((unsigned short)c))
{ {
char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale; char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale;
} }
@ -6216,7 +6216,7 @@ ImVec2 ImFont::CalcTextSizeW(float size, float max_width, const ImWchar* text_be
} }
else else
{ {
if (const FntGlyph* glyph = FindGlyph((unsigned short)c, FallbackGlyph)) if (const FntGlyph* glyph = FindGlyph((unsigned short)c))
char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale; char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale;
} }
@ -6309,7 +6309,7 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
if (const FntGlyph* glyph = FindGlyph((unsigned short)' ')) if (const FntGlyph* glyph = FindGlyph((unsigned short)' '))
char_width += (glyph->XAdvance + Info->SpacingHoriz) * 4 * scale; char_width += (glyph->XAdvance + Info->SpacingHoriz) * 4 * scale;
} }
else if (const FntGlyph* glyph = FindGlyph((unsigned short)c, FallbackGlyph)) else if (const FntGlyph* glyph = FindGlyph((unsigned short)c))
{ {
char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale; char_width = (glyph->XAdvance + Info->SpacingHoriz) * scale;
if (c != ' ') if (c != ' ')

View File

@ -726,7 +726,7 @@ struct ImFont
IMGUI_API bool LoadFromFile(const char* filename); IMGUI_API bool LoadFromFile(const char* filename);
IMGUI_API void Clear(); IMGUI_API void Clear();
IMGUI_API void BuildLookupTable(); IMGUI_API void BuildLookupTable();
IMGUI_API const FntGlyph* FindGlyph(unsigned short c, const FntGlyph* fallback = NULL) const; IMGUI_API const FntGlyph* FindGlyph(unsigned short c) const;
IMGUI_API float GetFontSize() const { return (float)Info->FontSize; } // before scale! IMGUI_API float GetFontSize() const { return (float)Info->FontSize; } // before scale!
IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; } IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }