1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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.
This commit is contained in:
attila 2025-05-12 13:25:55 +02:00 committed by Attila Szarvas
parent 283ea12958
commit 724221081b
2 changed files with 9 additions and 4 deletions

View file

@ -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
{

View file

@ -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;