From 724221081bcec977c9feb5484f896020fca83b86 Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 12 May 2025 13:25:55 +0200 Subject: [PATCH] Change the value returned by Font::getAscentInPoints and getDescentInPoints Prior to this commit the returned values were always normalised to the value returned by getHeightInPoints(). I.e. getAscentInPoints() + getDescentInPoints() would always equal getHeightInPoints(), even if ascent or descent overrides were in place. With this change in place getAscentInPoints() + getDescentInPoints() will always equal getHeightInPoints() * (getAscentOverride() + getDescentOverride()) JUCE classes don't use this value for layout logic, so this commit causes no visible changes in how JUCE draws text. --- modules/juce_graphics/fonts/juce_Font.cpp | 4 ++-- modules/juce_graphics/fonts/juce_Font.h | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 09e63cf051..33ff25fac7 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -802,8 +802,8 @@ float Font::getHeightInPoints() const return 0.0f; } -float Font::getAscentInPoints() const { return getAscent() * getHeightToPointsFactor(); } -float Font::getDescentInPoints() const { return getDescent() * getHeightToPointsFactor(); } +float Font::getAscentInPoints() const { return font->getAscentDescent (*this).ascent * getHeightInPoints(); } +float Font::getDescentInPoints() const { return font->getAscentDescent (*this).descent * getHeightInPoints(); } int Font::getStringWidth (const String& text) const { diff --git a/modules/juce_graphics/fonts/juce_Font.h b/modules/juce_graphics/fonts/juce_Font.h index 9cbc7f0263..fba72f2045 100644 --- a/modules/juce_graphics/fonts/juce_Font.h +++ b/modules/juce_graphics/fonts/juce_Font.h @@ -298,6 +298,7 @@ public: This is the maximum height, from the top of the ascent to the bottom of the descenders. + This value is not affected by the optional ascent or descent override. @see withPointHeight, getHeight */ float getHeightInPoints() const; @@ -310,7 +311,9 @@ public: /** Returns the height of the font above its baseline, in points. This is the maximum height from the baseline to the top. - @see getHeight, getDescent + + This value is affected by the optional ascent override. + @see getAscentOverride, getHeightInPoints, getDescentInPoints */ float getAscentInPoints() const; @@ -322,7 +325,9 @@ public: /** Returns the amount that the font descends below its baseline, in points. This is calculated as (getHeight() - getAscent()). - @see getAscent, getHeight + + This value is affected by the optional descent override. + @see getDescentOverride, getHeightInPoints, getAscentInPoints */ float getDescentInPoints() const;