Browse Source

Fonts: removed unnecessary const qualifier from ImFont::FindGlyph()

Amend 0bde57c
ocornut 6 months ago
parent
commit
914fbcf2e5
3 changed files with 12 additions and 10 deletions
  1. 9 7
      imgui.h
  2. 2 2
      imgui_draw.cpp
  3. 1 1
      imgui_widgets.cpp

+ 9 - 7
imgui.h

@@ -3412,6 +3412,7 @@ struct ImFontAtlas
     // Members
     // Members
     //-------------------------------------------
     //-------------------------------------------
 
 
+    // Input
     ImFontAtlasFlags            Flags;              // Build flags (see ImFontAtlasFlags_)
     ImFontAtlasFlags            Flags;              // Build flags (see ImFontAtlasFlags_)
     ImTextureID                 TexID;              // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
     ImTextureID                 TexID;              // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
     int                         TexDesiredWidth;    // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
     int                         TexDesiredWidth;    // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
@@ -3443,8 +3444,8 @@ struct ImFontAtlas
     int                         PackIdLines;        // Custom texture rectangle ID for baked anti-aliased lines
     int                         PackIdLines;        // Custom texture rectangle ID for baked anti-aliased lines
 
 
     // [Obsolete]
     // [Obsolete]
-    //typedef ImFontAtlasCustomRect    CustomRect;         // OBSOLETED in 1.72+
-    //typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
+    //typedef ImFontAtlasCustomRect    CustomRect;              // OBSOLETED in 1.72+
+    //typedef ImFontGlyphRangesBuilder GlyphRangesBuilder;      // OBSOLETED in 1.67+
 };
 };
 
 
 // Font runtime data and rendering
 // Font runtime data and rendering
@@ -3459,7 +3460,7 @@ struct ImFont
     // [Internal] Members: Hot ~28/40 bytes (for RenderText loop)
     // [Internal] Members: Hot ~28/40 bytes (for RenderText loop)
     ImVector<ImU16>             IndexLookup;        // 12-16 // out // Sparse. Index glyphs by Unicode code-point.
     ImVector<ImU16>             IndexLookup;        // 12-16 // out // Sparse. Index glyphs by Unicode code-point.
     ImVector<ImFontGlyph>       Glyphs;             // 12-16 // out // All glyphs.
     ImVector<ImFontGlyph>       Glyphs;             // 12-16 // out // All glyphs.
-    const ImFontGlyph*          FallbackGlyph;      // 4-8   // out // = FindGlyph(FontFallbackChar)
+    ImFontGlyph*                FallbackGlyph;      // 4-8   // out // = FindGlyph(FontFallbackChar)
 
 
     // [Internal] Members: Cold ~32/40 bytes
     // [Internal] Members: Cold ~32/40 bytes
     // Conceptually ConfigData[] is the list of font sources merged to create this font.
     // Conceptually ConfigData[] is the list of font sources merged to create this font.
@@ -3480,12 +3481,13 @@ struct ImFont
     // Methods
     // Methods
     IMGUI_API ImFont();
     IMGUI_API ImFont();
     IMGUI_API ~ImFont();
     IMGUI_API ~ImFont();
-    IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c);
-    IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c);
+    IMGUI_API ImFontGlyph*      FindGlyph(ImWchar c);
+    IMGUI_API ImFontGlyph*      FindGlyphNoFallback(ImWchar c);
     float                       GetCharAdvance(ImWchar c)       { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
     float                       GetCharAdvance(ImWchar c)       { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
     bool                        IsLoaded() const                { return ContainerAtlas != NULL; }
     bool                        IsLoaded() const                { return ContainerAtlas != NULL; }
     const char*                 GetDebugName() const            { return ConfigData ? ConfigData->Name : "<unknown>"; }
     const char*                 GetDebugName() const            { return ConfigData ? ConfigData->Name : "<unknown>"; }
 
 
+    // [Internal] Don't use!
     // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
     // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
     // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
     // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
     IMGUI_API ImVec2            CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL); // utf8
     IMGUI_API ImVec2            CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL); // utf8
@@ -3552,7 +3554,7 @@ struct ImGuiPlatformIO
     IMGUI_API ImGuiPlatformIO();
     IMGUI_API ImGuiPlatformIO();
 
 
     //------------------------------------------------------------------
     //------------------------------------------------------------------
-    // Interface with OS and Platform backend
+    // Input - Interface with OS and Platform backend (most common stuff)
     //------------------------------------------------------------------
     //------------------------------------------------------------------
 
 
     // Optional: Access OS clipboard
     // Optional: Access OS clipboard
@@ -3577,7 +3579,7 @@ struct ImGuiPlatformIO
     ImWchar     Platform_LocaleDecimalPoint;     // '.'
     ImWchar     Platform_LocaleDecimalPoint;     // '.'
 
 
     //------------------------------------------------------------------
     //------------------------------------------------------------------
-    // Interface with Renderer Backend
+    // Input - Interface with Renderer Backend
     //------------------------------------------------------------------
     //------------------------------------------------------------------
 
 
     // Written by some backends during ImGui_ImplXXXX_RenderDrawData() call to point backend_specific ImGui_ImplXXXX_RenderState* structure.
     // Written by some backends during ImGui_ImplXXXX_RenderDrawData() call to point backend_specific ImGui_ImplXXXX_RenderState* structure.

+ 2 - 2
imgui_draw.cpp

@@ -3903,7 +3903,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
 }
 }
 
 
 // Find glyph, return fallback if missing
 // Find glyph, return fallback if missing
-const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
+ImFontGlyph* ImFont::FindGlyph(ImWchar c)
 {
 {
     if (c >= (size_t)IndexLookup.Size)
     if (c >= (size_t)IndexLookup.Size)
         return FallbackGlyph;
         return FallbackGlyph;
@@ -3913,7 +3913,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c)
     return &Glyphs.Data[i];
     return &Glyphs.Data[i];
 }
 }
 
 
-const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c)
+ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c)
 {
 {
     if (c >= (size_t)IndexLookup.Size)
     if (c >= (size_t)IndexLookup.Size)
         return NULL;
         return NULL;

+ 1 - 1
imgui_widgets.cpp

@@ -4252,7 +4252,7 @@ void ImGui::PushPasswordFont()
     ImGuiContext& g = *GImGui;
     ImGuiContext& g = *GImGui;
     ImFont* in_font = g.Font;
     ImFont* in_font = g.Font;
     ImFont* out_font = &g.InputTextPasswordFont;
     ImFont* out_font = &g.InputTextPasswordFont;
-    const ImFontGlyph* glyph = in_font->FindGlyph('*');
+    ImFontGlyph* glyph = in_font->FindGlyph('*');
     out_font->FontSize = in_font->FontSize;
     out_font->FontSize = in_font->FontSize;
     out_font->Scale = in_font->Scale;
     out_font->Scale = in_font->Scale;
     out_font->Ascent = in_font->Ascent;
     out_font->Ascent = in_font->Ascent;