diff options
author | idana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 00:14:31 +0000 |
---|---|---|
committer | idana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 00:14:31 +0000 |
commit | 0dc78175ae33d022a8db10e8e010defe6ccc3623 (patch) | |
tree | 1876f7c55ff6c4bda2ab58c45a72bc48a0bd2a20 /app | |
parent | 5316993fa832907b1e831ae56221c57f02ffbb4f (diff) | |
download | chromium_src-0dc78175ae33d022a8db10e8e010defe6ccc3623.zip chromium_src-0dc78175ae33d022a8db10e8e010defe6ccc3623.tar.gz chromium_src-0dc78175ae33d022a8db10e8e010defe6ccc3623.tar.bz2 |
Added a flag to the Canvas class which allows forcing an RTL directionality
on text drawn using Canvas::DrawStringInt(). Using this flag, it is possible to
render RTL text correctly on platforms where LRE/PDF chars are not supported (e.g.
Windows XP with no RTL fonts installed).
BUG=23425
TEST=Run chrome and enter Hebrew text into the omnibox (see bug description). Make sure suggestions are formatted correctly. Verify in both RTL and LTR UIs.
Review URL: http://codereview.chromium.org/384018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31619 0039d316-1c4b-4281-b951-d872f2087c98
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; } |