summaryrefslogtreecommitdiffstats
path: root/ui/gfx/pango_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/pango_util.cc')
-rw-r--r--ui/gfx/pango_util.cc44
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,