mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-03 03:30:06 +00:00
JustifiedText: Fix line spacing for multi-font text
Prior to this change, the spacing between line N and line N + 1 would be lineHeight (N). This resulted in incorrect spacing when using multiple fonts in a text. This commit uses the correct spacing, which is maxDescent (N) + maxAscent (N + 1). This is also the same rule that was used by TextLayout prior to JUCE 8, and the rule that CoreText's AttributedString features are using as a general rule. Note: lineHeight (N) = maxAscent (N) + maxDescent (N).
This commit is contained in:
parent
99adac2871
commit
aee65c147e
1 changed files with 4 additions and 1 deletions
|
|
@ -342,7 +342,10 @@ JustifiedText::JustifiedText (const SimpleShapedText& t, const ShapedTextOptions
|
|||
whitespaceStretch.set (stretchRange,
|
||||
lineInfo.mainAxisLineAlignment.extraWhitespaceAdvance);
|
||||
|
||||
y += (1.0f + leading) * lineInfo.lineHeight;
|
||||
const auto maxDescent = lineInfo.lineHeight - lineInfo.maxAscent;
|
||||
const auto nextLineMaxAscent = lineIndex < (int) lineInfos.size() - 1 ? lineInfos[(size_t) lineIndex + 1].maxAscent : 0.0f;
|
||||
|
||||
y += (1.0f + leading) * (maxDescent + nextLineMaxAscent);
|
||||
}
|
||||
|
||||
rangesToDraw.set ({ 0, (int64) shapedText.getGlyphs().size() }, DrawType::normal);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue