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

TextLayout: Respect the ReadingDirection parameter of AttributedString

This commit is contained in:
Oliver James 2024-05-30 12:08:51 +01:00
parent 03e79f8f12
commit 38f299a054
2 changed files with 25 additions and 2 deletions

View file

@ -390,6 +390,21 @@ static MaxFontAscentAndDescent getMaxFontAscentAndDescentInEnclosingLine (const
return result;
}
static std::optional<TextDirection> getTextDirection (const AttributedString& text)
{
using ReadingDirection = AttributedString::ReadingDirection;
const auto dir = text.getReadingDirection();
if (dir == ReadingDirection::leftToRight)
return TextDirection::ltr;
if (dir == ReadingDirection::rightToLeft)
return TextDirection::rtl;
return std::nullopt;
}
void TextLayout::createStandardLayout (const AttributedString& text)
{
detail::RangedValues<Font> fonts;
@ -407,7 +422,8 @@ void TextLayout::createStandardLayout (const AttributedString& text)
.withMaxWidth (width)
.withLanguage (SystemStats::getUserLanguage())
.withTrailingWhitespacesShouldFit (false)
.withJustification (justification) };
.withJustification (justification)
.withReadingDirection (getTextDirection (text)) };
std::optional<int64> lastLineNumber;
std::unique_ptr<Line> line;