Przeglądaj źródła

Fonts: 'float size_pixels' passed to AddFontXXX() functions is now rounded to lowest integer. (#3164, #3309, #6800)

Note that using io.FontGlobalScale or SetWindowFontScale(), with are legacy-ish, partially supported features, can still lead to unrounded sizes and same issues.
ocornut 1 rok temu
rodzic
commit
bd63a9f056
2 zmienionych plików z 10 dodań i 0 usunięć
  1. 3 0
      docs/CHANGELOG.txt
  2. 7 0
      imgui_draw.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -53,6 +53,9 @@ Breaking changes:
 
 Other changes:
 
+- Fonts: 'float size_pixels' passed to AddFontXXX() functions is now rounded to lowest integer.
+  This is because our layout/font system currently doesn't fully support non-integer sizes. Until
+  it does, this has been a common pitfall leading to more or less subtle issues. (#3164, #3309, #6800)
 - InputTextMultiline: Fixed a crash pressing Down on last empty line of a multiline buffer.
   (regression from 1.89.2, only happened in some states). (#6783, #6000)
 - BeginListBox(): Fixed not consuming SetNextWindowXXX data when returning false.

+ 7 - 0
imgui_draw.cpp

@@ -2850,6 +2850,13 @@ static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas* atlas)
 // Note: this is called / shared by both the stb_truetype and the FreeType builder
 void ImFontAtlasBuildInit(ImFontAtlas* atlas)
 {
+    // Round font size
+    // - We started rounding in 1.90 WIP (18991) as our layout system currently doesn't support non-rounded font size well yet.
+    // - Note that using io.FontGlobalScale or SetWindowFontScale(), with are legacy-ish, partially supported features, can still lead to unrounded sizes.
+    // - We may support it better later and remove this rounding.
+    for (ImFontConfig& cfg : atlas->ConfigData)
+       cfg.SizePixels = ImFloor(cfg.SizePixels);
+
     // Register texture region for mouse cursors or standard white pixels
     if (atlas->PackIdMouseCursors < 0)
     {