Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: ui/gfx/render_text_linux.cc

Issue 10807082: Add RenderText DirectionalityMode enum and support; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments; revert Label and MessageBoxView changes. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text_linux.cc
diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc
index 4c100626d79b26659fda01412213e6820f02362a..e26ecc5bf30cedaef2ac96a5e5dd367955022241 100644
--- a/ui/gfx/render_text_linux.cc
+++ b/ui/gfx/render_text_linux.cc
@@ -80,15 +80,6 @@ RenderTextLinux::~RenderTextLinux() {
ResetLayout();
}
-base::i18n::TextDirection RenderTextLinux::GetTextDirection() {
- EnsureLayout();
-
- PangoDirection base_dir = pango_find_base_dir(layout_text_, -1);
- if (base_dir == PANGO_DIRECTION_RTL || base_dir == PANGO_DIRECTION_WEAK_RTL)
- return base::i18n::RIGHT_TO_LEFT;
- return base::i18n::LEFT_TO_RIGHT;
-}
-
Size RenderTextLinux::GetStringSize() {
EnsureLayout();
int width = 0, height = 0;
@@ -288,13 +279,18 @@ void RenderTextLinux::EnsureLayout() {
layout_ = pango_cairo_create_layout(cr);
cairo_destroy(cr);
cairo_surface_destroy(surface);
- SetupPangoLayoutWithFontDescription(
- layout_,
- GetDisplayText(),
- font_list().GetFontDescriptionString(),
- display_rect().width(),
- base::i18n::GetFirstStrongCharacterDirection(text()),
- Canvas::DefaultCanvasTextAlignment());
+
+ SetupPangoLayoutWithFontDescription(layout_,
+ GetDisplayText(),
+ font_list().GetFontDescriptionString(),
+ display_rect().width(),
+ GetTextDirection(),
+ Canvas::DefaultCanvasTextAlignment());
+
+ // Set Pango's base text direction.
+ pango_context_set_base_dir(pango_layout_get_context(layout_),
Alexei Svitkine (slow) 2012/07/31 23:33:29 Should this be done in SetupPangoLayoutWithFontDes
msw 2012/08/01 17:30:10 Good idea! Moved lower to SetupPangoLayoutWithoutF
+ (GetTextDirection() == base::i18n::RIGHT_TO_LEFT ?
+ PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR));
// No width set so that the x-axis position is relative to the start of the
// text. ToViewPoint and ToTextPoint take care of the position conversion

Powered by Google App Engine
This is Rietveld 408576698