Skip to content

Commit

Permalink
Improve code style
Browse files Browse the repository at this point in the history
This will also fix compile error when invoke FindGlyph of a const instance of class ImFont
  • Loading branch information
halx99 committed Jan 1, 2025
1 parent 6982ce4 commit 71368a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3461,8 +3461,8 @@ struct ImFont
// Methods
IMGUI_API ImFont();
IMGUI_API ~ImFont();
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c);
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c);
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
float GetCharAdvance(ImWchar c) { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
bool IsLoaded() const { return ContainerAtlas != NULL; }
const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
Expand All @@ -3481,7 +3481,7 @@ struct ImFont
IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const;
};

//-----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,7 @@ void ImFont::BuildLookupTable()

// API is designed this way to avoid exposing the 4K page size
// e.g. use with IsGlyphRangeUnused(0, 255)
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) const
{
unsigned int page_begin = (c_begin / 4096);
unsigned int page_last = (c_last / 4096);
Expand Down Expand Up @@ -3896,7 +3896,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
}

// Find glyph, return fallback if missing
const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
{
if (c >= (size_t)IndexLookup.Size)
return FallbackGlyph;
Expand All @@ -3906,7 +3906,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
return &Glyphs.Data[i];
}

const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c)
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
{
if (c >= (size_t)IndexLookup.Size)
return NULL;
Expand Down

0 comments on commit 71368a7

Please sign in to comment.