소스 검색

Fonts: Fixed font ascent and descent calculation when a font hits exact integer values. (#7399, #7404)

GamingMinds-DanielC 1 년 전
부모
커밋
b475309fa1
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 1
      docs/CHANGELOG.txt
  2. 2 2
      imgui_draw.cpp

+ 4 - 1
docs/CHANGELOG.txt

@@ -43,8 +43,11 @@ Breaking changes:
 
 
 Other changes:
 Other changes:
 
 
+- Fonts: Fixed font ascent and descent calculation when a font hits exact integer values.
+  It is possible that some prior manual use of ImFontConfig::GlyphOffset may become
+  duplicate with this fix. (#7399, #7404) [@GamingMinds-DanielC]
 - Text, DrawList: Improved handling of long single-line wrapped text. Faster and
 - Text, DrawList: Improved handling of long single-line wrapped text. Faster and
-  mitigitate issues with reading vertex indexing limits with 16-bit indices.
+  mitigitate issues with reading vertex indexing limits with 16-bit indices. (#7496, #5720)
 - Backends: SDL3: Fixed text inputs. Re-enable calling SDL_StartTextInput()/SDL_StopTextInput()
 - Backends: SDL3: Fixed text inputs. Re-enable calling SDL_StartTextInput()/SDL_StopTextInput()
   as SDL3 no longer enables it by default. (#7452, #6306, #6071, #1953) [@Green-Sky]
   as SDL3 no longer enables it by default. (#7452, #6306, #6071, #1953) [@Green-Sky]
 
 

+ 2 - 2
imgui_draw.cpp

@@ -2984,8 +2984,8 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
         int unscaled_ascent, unscaled_descent, unscaled_line_gap;
         int unscaled_ascent, unscaled_descent, unscaled_line_gap;
         stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
         stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
 
 
-        const float ascent = ImTrunc(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1));
-        const float descent = ImTrunc(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
+        const float ascent = ImCeil(unscaled_ascent * font_scale);
+        const float descent = ImFloor(unscaled_descent * font_scale);
         ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
         ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
         const float font_off_x = cfg.GlyphOffset.x;
         const float font_off_x = cfg.GlyphOffset.x;
         const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
         const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);