diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/gfx/canvas.h | 10 | ||||
-rw-r--r-- | app/gfx/canvas_win.cc | 14 |
2 files changed, 19 insertions, 5 deletions
diff --git a/app/gfx/canvas.h b/app/gfx/canvas.h index 90cfad8..e6b07a1 100644 --- a/app/gfx/canvas.h +++ b/app/gfx/canvas.h @@ -66,6 +66,16 @@ class Canvas : public skia::PlatformCanvas { // Specifies if words can be split by new lines. // This only works with MULTI_LINE. CHARACTER_BREAK = 1024, + + // Instructs DrawStringInt() to render the text using RTL directionality. + // In most cases, passing this flag is not necessary because information + // about the text directionality is going to be embedded within the string + // in the form of special Unicode characters. However, we don't insert + // directionality characters into strings if the locale is LTR because some + // platforms (for example, an English Windows XP with no RTL fonts + // installed) don't support these characters. Thus, this flag should be + // used to render text using RTL directionality when the locale is LTR. + FORCE_RTL_DIRECTIONALITY = 2048, }; // Creates an empty Canvas. Callers must use initialize before using the diff --git a/app/gfx/canvas_win.cc b/app/gfx/canvas_win.cc index 9f70136..8b5e685 100644 --- a/app/gfx/canvas_win.cc +++ b/app/gfx/canvas_win.cc @@ -106,12 +106,16 @@ int ComputeFormatFlags(int flags, const std::wstring& text) { // Caveat: If the string is purely LTR, don't set DTL_RTLREADING since when // the flag is set, LRE-PDF don't have the desired effect of rendering // multiline English-only text as LTR. - if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && - (f & DT_RIGHT)) { - if (l10n_util::StringContainsStrongRTLChars(text)) { - f |= DT_RTLREADING; - } + // + // Note that if the caller is explicitly requesting displaying the text + // using RTL directionality then we respect that and pass DT_RTLREADING to + // ::DrawText even if the locale is LTR. + if ((flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) || + ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && + (f & DT_RIGHT) && l10n_util::StringContainsStrongRTLChars(text))) { + f |= DT_RTLREADING; } + return f; } |