Forráskód Böngészése

Fonts: Fixed debug name not being zero-terminated if longer than storage buffer + made buffer slightly longer as well.

omar 7 éve
szülő
commit
3dfac93ebe
2 módosított fájl, 2 hozzáadás és 2 törlés
  1. 1 1
      imgui.h
  2. 1 1
      imgui_draw.cpp

+ 1 - 1
imgui.h

@@ -1628,7 +1628,7 @@ struct ImFontConfig
     float           RasterizerMultiply;         // 1.0f     // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
     float           RasterizerMultiply;         // 1.0f     // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
 
 
     // [Internal]
     // [Internal]
-    char            Name[32];                               // Name (strictly to ease debugging)
+    char            Name[40];                               // Name (strictly to ease debugging)
     ImFont*         DstFont;
     ImFont*         DstFont;
 
 
     IMGUI_API ImFontConfig();
     IMGUI_API ImFontConfig();

+ 1 - 1
imgui_draw.cpp

@@ -1543,7 +1543,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
         // Store a short copy of filename into into the font name for convenience
         // Store a short copy of filename into into the font name for convenience
         const char* p;
         const char* p;
         for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
         for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
-        snprintf(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels);
+        ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels);
     }
     }
     return AddFontFromMemoryTTF(data, data_size, size_pixels, &font_cfg, glyph_ranges);
     return AddFontFromMemoryTTF(data, data_size, size_pixels, &font_cfg, glyph_ranges);
 }
 }