diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:28:49 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:28:49 +0000 |
commit | 13ee61d7b61d186baeb2fec423e7b2b0a17c7e98 (patch) | |
tree | 3b67bf691e186fbdd7bf83f7520c7c8c67346f56 | |
parent | 3c53cfa23d26b9477e3ca46e141c820e9793a5f2 (diff) | |
download | chromium_src-13ee61d7b61d186baeb2fec423e7b2b0a17c7e98.zip chromium_src-13ee61d7b61d186baeb2fec423e7b2b0a17c7e98.tar.gz chromium_src-13ee61d7b61d186baeb2fec423e7b2b0a17c7e98.tar.bz2 |
Force the font size in the omnibox, tabs, find bar, and download shelf
so we don't get layout overflow issues. Ideally, we would have
vector graphics for buttons and stuff so this wouldn't be an issue,
but for now, this will have to do.
BUG=11128
Review URL: http://codereview.chromium.org/113546
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16327 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/link_button_gtk.h | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 11 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 3 |
9 files changed, 36 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 566c8d2..4e6be71 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -16,6 +16,7 @@ #include "chrome/browser/gtk/location_bar_view_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/toolbar_model.h" +#include "chrome/common/gtk_util.h" #include "chrome/common/notification_service.h" #include "googleurl/src/gurl.h" @@ -86,6 +87,8 @@ void AutocompleteEditViewGtk::Init() { tag_table_ = gtk_text_tag_table_new(); text_buffer_ = gtk_text_buffer_new(tag_table_); text_view_ = gtk_text_view_new_with_buffer(text_buffer_); + // Until we switch to vector graphics, force the font size. + gtk_util::ForceFontSizePixels(text_view_, 13.4); // 13.4px == 10pt @ 96dpi // The text view was floating. It will now be owned by the alignment. gtk_container_add(GTK_CONTAINER(alignment_.get()), text_view_); diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index 718b76c..ec74e648 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -248,7 +248,9 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk( // TODO(deanm): We might want to eventually follow what Windows does and // plumb a gfx::Font through. This is because popup windows have a // different font size, although we could just derive that font here. - PangoFontDescription* pfd = PangoFontFromGfxFont(gfx::Font()); + // For now, force the font size to 10pt. + gfx::Font font = gfx::Font::CreateFont(gfx::Font().FontName(), 10); + PangoFontDescription* pfd = PangoFontFromGfxFont(font); pango_layout_set_font_description(layout_, pfd); pango_font_description_free(pfd); diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index 2a3f926..02f2f3f 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -18,6 +18,7 @@ #include "chrome/browser/gtk/download_shelf_gtk.h" #include "chrome/browser/gtk/menu_gtk.h" #include "chrome/browser/gtk/nine_box.h" +#include "chrome/common/gtk_util.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -181,6 +182,9 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, // Left align and vertically center the labels. gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(status_label_), 0, 0.5); + // Until we switch to vector graphics, force the font size. + gtk_util::ForceFontSizePixels(name_label_, 13.4); // 13.4px == 10pt @ 96dpi + gtk_util::ForceFontSizePixels(status_label_, 13.4); // 13.4px == 10pt @ 96dpi // Stack the labels on top of one another. GtkWidget* text_stack = gtk_vbox_new(FALSE, 0); diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index f594a7f..00e81c8 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -14,6 +14,7 @@ #include "chrome/browser/gtk/link_button_gtk.h" #include "chrome/browser/gtk/slide_animator_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/gtk_util.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -96,6 +97,9 @@ DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents) link_button_.reset(new LinkButtonGtk(link_text.c_str())); g_signal_connect(link_button_->widget(), "clicked", G_CALLBACK(OnButtonClick), this); + // Until we switch to vector graphics, force the font size. + // 13.4px == 10pt @ 96dpi + gtk_util::ForceFontSizePixels(link_button_->label(), 13.4); // Make the download arrow icon. ResourceBundle& rb = ResourceBundle::GetSharedInstance(); diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 922cafb..d4c3c9b 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -167,6 +167,9 @@ void FindBarGtk::InitWidgets() { // font size. gtk_widget_set_size_request(text_entry_, -1, 20); gtk_entry_set_has_frame(GTK_ENTRY(text_entry_), FALSE); + // Until we switch to vector graphics, force the font size. + gtk_util::ForceFontSizePixels(text_entry_, 13.4); // 13.4px == 10pt @ 96dpi + gtk_util::ForceFontSizePixels(match_count_label_, 13.4); gtk_box_pack_end(GTK_BOX(content_hbox), match_count_label_, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(content_hbox), text_entry_, TRUE, TRUE, 0); diff --git a/chrome/browser/gtk/link_button_gtk.h b/chrome/browser/gtk/link_button_gtk.h index 745c943..3a37fed 100644 --- a/chrome/browser/gtk/link_button_gtk.h +++ b/chrome/browser/gtk/link_button_gtk.h @@ -17,6 +17,8 @@ class LinkButtonGtk { GtkWidget* widget() { return widget_.get(); } + GtkWidget* label() { return label_; } + private: // Called when the pointer enters or leaves the button. static gboolean OnEnter(GtkWidget* widget, LinkButtonGtk* link_button); diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 07d644f..67212e03 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -600,7 +600,9 @@ void TabRendererGtk::InitResources() { LoadTabImages(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - title_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); + // Force the font size to 10pt. + gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); + title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 10)); title_font_height_ = title_font_->height(); InitializeLoadingAnimationData(&rb, &loading_animation_data); diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index 280a7ea..c3b0ea9 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/linux_util.h" +#include "base/logging.h" #include "third_party/skia/include/core/SkBitmap.h" namespace { @@ -54,6 +55,16 @@ void RemoveAllChildren(GtkWidget* container) { gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); } +void ForceFontSizePixels(GtkWidget* widget, double size_pixels) { + GtkStyle* style = widget->style; + PangoFontDescription* font_desc = style->font_desc; + // pango_font_description_set_absolute_size sets the font size in device + // units, which for us is pixels. + pango_font_description_set_absolute_size(font_desc, + PANGO_SCALE * size_pixels); + gtk_widget_modify_font(widget, font_desc); +} + gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { int x = 0, y = 0; diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index 8a9b3f0..d72045b 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -32,6 +32,9 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, // Remove all children from this container. void RemoveAllChildren(GtkWidget* container); +// Force the font size of the widget to |size_pixels|. +void ForceFontSizePixels(GtkWidget* widget, double size_pixels); + // Gets the position of a gtk widget in screen coordinates. gfx::Point GetWidgetScreenPosition(GtkWidget* widget); |