diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index fac4fcd..fb98795 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -69,6 +69,33 @@ const int kCornerSize = 3; // UTF-8 Left-to-right embedding. const char* kLRE = "\xe2\x80\xaa"; +// TODO(deanm): We should put this on gfx::Font so it can be shared. +// Returns a new pango font, free with pango_font_description_free(). +PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& chrome_font) { + gfx::Font font = chrome_font; // Copy so we can call non-const methods. + PangoFontDescription* pfd = pango_font_description_new(); + pango_font_description_set_family(pfd, WideToUTF8(font.FontName()).c_str()); + pango_font_description_set_size(pfd, font.FontSize() * PANGO_SCALE); + + switch (font.style()) { + case gfx::Font::NORMAL: + // Nothing to do, should already be PANGO_STYLE_NORMAL. + break; + case gfx::Font::BOLD: + pango_font_description_set_weight(pfd, PANGO_WEIGHT_BOLD); + break; + case gfx::Font::ITALIC: + pango_font_description_set_style(pfd, PANGO_STYLE_ITALIC); + break; + case gfx::Font::UNDERLINED: + // TODO(deanm): How to do underlined? Where do we use it? Probably have + // to paint it ourselves, see pango_font_metrics_get_underline_position. + break; + } + + return pfd; +} + // Return a Rect covering the whole area of |window|. gfx::Rect GetWindowRect(GdkWindow* window) { gint width, height; @@ -246,7 +273,9 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk( // For now, force the font size. gfx::Font font = gfx::Font::CreateFont( gfx::Font().FontName(), browser_defaults::kAutocompletePopupFontSize); - pango_layout_set_font_description(layout_, font.nativeFont()); + PangoFontDescription* pfd = PangoFontFromGfxFont(font); + pango_layout_set_font_description(layout_, pfd); + pango_font_description_free(pfd); gtk_widget_add_events(window_, GDK_BUTTON_MOTION_MASK | GDK_POINTER_MOTION_MASK | |