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:
parent
03e79f8f12
commit
38f299a054
2 changed files with 25 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue