From 0e6bbcc55cd710c22d7ce59073164bfdbac1c359 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 8 Jun 2012 15:29:58 +0100 Subject: [PATCH] DirectWrite RTL layout fix. --- .../native/juce_win32_DirectWriteTypeLayout.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index 602dcc3593..8dbb9b211e 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp @@ -198,13 +198,22 @@ namespace DirectWriteTypeLayout default: jassertfalse; break; // Illegal flags! } - format->SetTextAlignment (alignment); - format->SetWordWrapping (wrapType); - // DirectWrite does not automatically set reading direction // This must be set correctly and manually when using RTL Scripts (Hebrew, Arabic) if (text.getReadingDirection() == AttributedString::rightToLeft) + { format->SetReadingDirection (DWRITE_READING_DIRECTION_RIGHT_TO_LEFT); + + switch (text.getJustification().getOnlyHorizontalFlags()) + { + case Justification::left: alignment = DWRITE_TEXT_ALIGNMENT_TRAILING; break; + case Justification::right: alignment = DWRITE_TEXT_ALIGNMENT_LEADING; break; + default: break; + } + } + + format->SetTextAlignment (alignment); + format->SetWordWrapping (wrapType); } void addAttributedRange (const AttributedString::Attribute& attr, IDWriteTextLayout* textLayout,