diff options
author | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 04:09:01 +0000 |
---|---|---|
committer | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 04:09:01 +0000 |
commit | 732ef6737ef6e1346255be7230032dcaf4e9ad03 (patch) | |
tree | c9663673eba42c9f33c413a909c16a37d7bd2ebb /ui/gfx/pango_util.cc | |
parent | 963c1b96abd9baa3ccddb7bc59da8a93e0c2ae93 (diff) | |
download | chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.zip chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.tar.gz chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.tar.bz2 |
specify locale-dependent font list for UI on ChromeOS, so that those fonts have higher priority over the fallback fonts Pango picks up.
BUG=103860
TEST=build aura, start chromium in 'ar' locale. type in Arabic and check the Arabic text's shapes. remove IDS_UI_FONT_FAMILY_CROS from 'ar' resource file, build aura again, start chromium in 'ar', type in Arabic and the Arabic text's shapes should be different.
Review URL: http://codereview.chromium.org/8770034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/pango_util.cc')
-rw-r--r-- | ui/gfx/pango_util.cc | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc index 55e4374..1c7e9e4 100644 --- a/ui/gfx/pango_util.cc +++ b/ui/gfx/pango_util.cc @@ -169,12 +169,12 @@ void DrawTextOntoCairoSurface(cairo_t* cr, } // Pass a width greater than 0 to force wrapping and eliding. -void SetupPangoLayout(PangoLayout* layout, - const string16& text, - const Font& font, - int width, - base::i18n::TextDirection text_direction, - int flags) { +static void SetupPangoLayoutWithoutFont( + PangoLayout* layout, + const string16& text, + int width, + base::i18n::TextDirection text_direction, + int flags) { cairo_font_options_t* cairo_font_options = GetCairoFontOptions(); // This needs to be done early on; it has no effect when called just before // pango_cairo_show_layout(). @@ -221,10 +221,6 @@ void SetupPangoLayout(PangoLayout* layout, resolution); } - PangoFontDescription* desc = font.GetNativeFont(); - pango_layout_set_font_description(layout, desc); - pango_font_description_free(desc); - // Set text and accelerator character if needed. if (flags & Canvas::SHOW_PREFIX) { // Escape the text string to be used as markup. @@ -254,6 +250,34 @@ void SetupPangoLayout(PangoLayout* layout, } } +void SetupPangoLayout(PangoLayout* layout, + const string16& text, + const Font& font, + int width, + base::i18n::TextDirection text_direction, + int flags) { + SetupPangoLayoutWithoutFont(layout, text, width, text_direction, flags); + + PangoFontDescription* desc = font.GetNativeFont(); + pango_layout_set_font_description(layout, desc); + pango_font_description_free(desc); +} + +void SetupPangoLayoutWithFontDescription( + PangoLayout* layout, + const string16& text, + const std::string& font_description, + int width, + base::i18n::TextDirection text_direction, + int flags) { + SetupPangoLayoutWithoutFont(layout, text, width, text_direction, flags); + + PangoFontDescription* desc = pango_font_description_from_string( + font_description.c_str()); + pango_layout_set_font_description(layout, desc); + pango_font_description_free(desc); +} + void AdjustTextRectBasedOnLayout(PangoLayout* layout, const gfx::Rect& bounds, int flags, |