mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
GlyphArrangement: Make drawFittedText squashing behaviour more similar to JUCE 7
This commit fixes a regression added during the ShapedText based rewrite of the class. The minimumHorizontalScale parameter was mistakenly interpreted as an absolute scale, whereas its meaning in the old implementation was a relative scalar applied to the Font's horizontal scale.
This commit is contained in:
parent
60c1deb4e4
commit
b545b79cb3
1 changed files with 10 additions and 6 deletions
|
|
@ -234,17 +234,17 @@ static auto createFittedText (const Font& f,
|
|||
float height,
|
||||
Justification layout,
|
||||
int maximumLines,
|
||||
float minimumHorizontalScale,
|
||||
float minimumRelativeHorizontalScale,
|
||||
ShapedText::Options baseOptions = {})
|
||||
{
|
||||
if (! layout.testFlags (Justification::bottom | Justification::top))
|
||||
layout = layout.getOnlyHorizontalFlags() | Justification::verticallyCentred;
|
||||
|
||||
if (approximatelyEqual (minimumHorizontalScale, 0.0f))
|
||||
minimumHorizontalScale = Font::getDefaultMinimumHorizontalScaleFactor();
|
||||
if (approximatelyEqual (minimumRelativeHorizontalScale, 0.0f))
|
||||
minimumRelativeHorizontalScale = Font::getDefaultMinimumHorizontalScaleFactor();
|
||||
|
||||
// doesn't make much sense if this is outside a sensible range of 0.5 to 1.0
|
||||
jassert (minimumHorizontalScale > 0 && minimumHorizontalScale <= 1.0f);
|
||||
jassert (0 < minimumRelativeHorizontalScale && minimumRelativeHorizontalScale <= 1.0f);
|
||||
|
||||
if (text.containsAnyOf ("\r\n"))
|
||||
{
|
||||
|
|
@ -278,11 +278,13 @@ static auto createFittedText (const Font& f,
|
|||
return st;
|
||||
|
||||
// If we can fit the entire line, squash by just enough and insert
|
||||
if (requiredWidths.front() * minimumHorizontalScale < width)
|
||||
if (requiredWidths.front() * minimumRelativeHorizontalScale < width)
|
||||
{
|
||||
const auto requiredRelativeScale = width / (requiredWidths.front() + widthFittingTolerance);
|
||||
|
||||
ShapedText squashed { trimmed,
|
||||
baseOptions
|
||||
.withFont (f.withHorizontalScale (width / (requiredWidths.front() + widthFittingTolerance)))
|
||||
.withFont (f.withHorizontalScale (f.getHorizontalScale() * requiredRelativeScale))
|
||||
.withMaxWidth (width)
|
||||
.withHeight (height)
|
||||
.withJustification (layout)
|
||||
|
|
@ -292,6 +294,8 @@ static auto createFittedText (const Font& f,
|
|||
}
|
||||
}
|
||||
|
||||
const auto minimumHorizontalScale = minimumRelativeHorizontalScale * f.getHorizontalScale();
|
||||
|
||||
if (maximumLines <= 1)
|
||||
{
|
||||
ShapedText squashed { trimmed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue