summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 19:26:49 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 19:26:49 +0000
commit5e70f14644629b7f9fe9126553758aed25e17128 (patch)
tree65bd07608366d1f3004535e2ca91a9089327ed92 /chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
parent1bf956b6f611bd3e116489bfdef7ac9048db0308 (diff)
downloadchromium_src-5e70f14644629b7f9fe9126553758aed25e17128.zip
chromium_src-5e70f14644629b7f9fe9126553758aed25e17128.tar.gz
chromium_src-5e70f14644629b7f9fe9126553758aed25e17128.tar.bz2
Reverts linux font change again. Slow down isn't as bad as before. But
still not ideal. BUG=none TEST=none TBR=agl Review URL: http://codereview.chromium.org/194105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc31
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 |