You are not logged in.

#1 2011-02-06 03:35:40

hjl3
Member
Registered: 2011-01-21
Posts: 13

[Solved] Chromium Interface Font Size/DPI Issue

I'm having an issue with getting Chromium to adhere to to the GTK / X font or DPI size, and it makes chromium look awkward.

chromiumfontissue.png

As you can see, the size of the fonts for the Tabs and Bookmarks are much larger than that of other GTK apps (Thunar in this case). I've attempted setting the font options in .Xdefaults as I've seen the wiki and some threads advise, but this doesn't help. How can I adjust the font sizes for the interface or get it to match the DPI or GTK theme?

Last edited by hjl3 (2011-02-16 15:28:48)

Offline

#2 2011-02-09 12:24:19

hjl3
Member
Registered: 2011-01-21
Posts: 13

Re: [Solved] Chromium Interface Font Size/DPI Issue

I still haven't had any luck figuring this out.  Does no one know?

Offline

#3 2011-02-09 14:54:46

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: [Solved] Chromium Interface Font Size/DPI Issue

The interface font is hardcoded to 10pt. You'll have to patch the source to change it.

Offline

#4 2011-02-09 15:07:28

hjl3
Member
Registered: 2011-01-21
Posts: 13

Re: [Solved] Chromium Interface Font Size/DPI Issue

My GTK font is set to a larger size; 11pt. Is it also hard coded to a specific DPI?  My current X DPI is 72, but chromium's UI font doesn't change when I adjust the DPI.

Offline

#5 2011-02-09 15:33:39

sirocco
Member
Registered: 2008-03-10
Posts: 149

Re: [Solved] Chromium Interface Font Size/DPI Issue

Try to install ttf-google-webfonts

Offline

#6 2011-02-09 18:22:55

hjl3
Member
Registered: 2011-01-21
Posts: 13

Re: [Solved] Chromium Interface Font Size/DPI Issue

sirocco wrote:

Try to install ttf-google-webfonts

Unfortunately this wouldn't address the UI font. I've dug a little further, and it does appear to be all hard coded. Very disappointing.

Offline

#7 2011-02-09 18:43:12

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: [Solved] Chromium Interface Font Size/DPI Issue

If you don't mind compiling yourself, here's a patch:

diff -Nur a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
--- a/chrome/browser/defaults.cc    2011-01-27 10:01:45.000000000 +0100
+++ b/chrome/browser/defaults.cc    2011-01-27 23:48:06.853026996 +0100
@@ -35,15 +35,15 @@
 
 #elif defined(TOOLKIT_USES_GTK)
 
-// 13.4px = 10pt @ 96dpi.
-const double kAutocompleteEditFontPixelSize = 13.4;
+// 10.7px = 8pt @ 96dpi.
+const double kAutocompleteEditFontPixelSize = 10.7;
 
 // On Windows, popup windows' autocomplete box have a font 5/6 the size of a
 // regular window, which we duplicate here for GTK.
 const double kAutocompleteEditFontPixelSizeInPopup =
     kAutocompleteEditFontPixelSize * 5.0 / 6.0;
 
-const int kAutocompletePopupFontSize = 10;
+const int kAutocompletePopupFontSize = 8;
 
 #if defined(TOOLKIT_VIEWS)
 const bool kCanToggleSystemTitleBar = false;
diff -Nur a/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc b/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc
--- a/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc    2011-01-27 23:38:11.471027005 +0100
@@ -38,9 +38,9 @@
                    G_CALLBACK(OnButtonClickThunk), this);
   gtk_util::SetButtonTriggersNavigation(instructions_link_);
   // Until we switch to vector graphics, force the font size.
-  // 13.4px == 10pt @ 96dpi
+  // 10.7px == 8pt @ 96dpi
   gtk_util::ForceFontSizePixels(
-      GTK_CHROME_LINK_BUTTON(instructions_link_)->label, 13.4);
+      GTK_CHROME_LINK_BUTTON(instructions_link_)->label, 10.7);
   gtk_util::CenterWidgetInHBox(instructions_hbox_, instructions_link_,
                                false, 6);
   g_signal_connect(GTK_CHROME_LINK_BUTTON(instructions_link_)->label, "map",
diff -Nur a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc
--- a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc    2011-01-27 23:38:47.940027001 +0100
@@ -67,7 +67,7 @@
   if (!label_string.empty()) {
     GtkWidget* label = gtk_label_new(label_string.c_str());
     // Until we switch to vector graphics, force the font size.
-    gtk_util::ForceFontSizePixels(label, 13.4);  // 13.4px == 10pt @ 96dpi
+    gtk_util::ForceFontSizePixels(label, 10.7);  // 10.7px == 8pt @ 96dpi
 
     // Ellipsize long bookmark names.
     if (ellipsize) {
diff -Nur a/chrome/browser/ui/gtk/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download_shelf_gtk.cc
--- a/chrome/browser/ui/gtk/download_shelf_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/download_shelf_gtk.cc    2011-01-27 23:39:45.779026988 +0100
@@ -109,9 +109,9 @@
                    G_CALLBACK(OnButtonClickThunk), this);
   gtk_util::SetButtonTriggersNavigation(link_button_);
   // Until we switch to vector graphics, force the font size.
-  // 13.4px == 10pt @ 96dpi
+  // 10.7px == 8pt @ 96dpi
   gtk_util::ForceFontSizePixels(GTK_CHROME_LINK_BUTTON(link_button_)->label,
-                                13.4);
+                                10.7);
 
   // Make the download arrow icon.
   ResourceBundle& rb = ResourceBundle::GetSharedInstance();
diff -Nur a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc
--- a/chrome/browser/ui/gtk/find_bar_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/find_bar_gtk.cc    2011-01-27 23:40:14.431026982 +0100
@@ -507,8 +507,8 @@
                            &kEntryTextColor);
 
     // 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_util::ForceFontSizePixels(text_entry_, 10.7);  // 10.7px == 8pt @ 96dpi
+    gtk_util::ForceFontSizePixels(match_count_label_, 10.7);
 
     // Force the text widget height so it lines up with the buttons regardless
     // of font size.
diff -Nur a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc
--- a/chrome/browser/ui/gtk/first_run_dialog.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/first_run_dialog.cc    2011-01-27 23:40:39.043026965 +0100
@@ -183,8 +183,8 @@
   GtkWidget* welcome_message = gtk_util::CreateBoldLabel(
       l10n_util::GetStringUTF8(IDS_FR_SEARCH_MAIN_LABEL));
   // Force the font size to make sure the label doesn't overlap the image.
-  // 13.4px == 10pt @ 96dpi
-  gtk_util::ForceFontSizePixels(welcome_message, 13.4);
+  // 10.7px == 8pt @ 96dpi
+  gtk_util::ForceFontSizePixels(welcome_message, 10.7);
 
   GtkWidget* top_area = gtk_floating_container_new();
   gtk_container_add(GTK_CONTAINER(top_area), top_image);
diff -Nur a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc    2011-01-27 23:41:43.555026995 +0100
@@ -1074,10 +1074,8 @@
 
   ResourceBundle& rb = ResourceBundle::GetSharedInstance();
   const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
-  // Dividing by the pango scale factor maintains an absolute pixel size across
-  // all DPIs.
-  int size = static_cast<int>(13 / gfx::PlatformFontGtk::GetPangoScaleFactor());
-  title_font_ = new gfx::Font(base_font.GetFontName(), size);
+  // Force the font size to 8pt
+  title_font_ = new gfx::Font(base_font.GetFontName(), 8);
   title_font_height_ = title_font_->GetHeight();
 
   crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);

It's for Chromium 10, it won't apply to earlier versions. I posted a version for Chromium 8 to pastebin.ca once, but it's not accessible for me at the moment: http://pastebin.ca/2022940

Offline

#8 2011-02-09 19:23:26

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: [Solved] Chromium Interface Font Size/DPI Issue

Offline

#9 2011-02-16 15:28:18

hjl3
Member
Registered: 2011-01-21
Posts: 13

Re: [Solved] Chromium Interface Font Size/DPI Issue

Gusar wrote:

If you don't mind compiling yourself, here's a patch:

diff -Nur a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
--- a/chrome/browser/defaults.cc    2011-01-27 10:01:45.000000000 +0100
+++ b/chrome/browser/defaults.cc    2011-01-27 23:48:06.853026996 +0100
@@ -35,15 +35,15 @@
 
 #elif defined(TOOLKIT_USES_GTK)
 
-// 13.4px = 10pt @ 96dpi.
-const double kAutocompleteEditFontPixelSize = 13.4;
+// 10.7px = 8pt @ 96dpi.
+const double kAutocompleteEditFontPixelSize = 10.7;
 
 // On Windows, popup windows' autocomplete box have a font 5/6 the size of a
 // regular window, which we duplicate here for GTK.
 const double kAutocompleteEditFontPixelSizeInPopup =
     kAutocompleteEditFontPixelSize * 5.0 / 6.0;
 
-const int kAutocompletePopupFontSize = 10;
+const int kAutocompletePopupFontSize = 8;
 
 #if defined(TOOLKIT_VIEWS)
 const bool kCanToggleSystemTitleBar = false;
diff -Nur a/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc b/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc
--- a/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/bookmark_bar_instructions_gtk.cc    2011-01-27 23:38:11.471027005 +0100
@@ -38,9 +38,9 @@
                    G_CALLBACK(OnButtonClickThunk), this);
   gtk_util::SetButtonTriggersNavigation(instructions_link_);
   // Until we switch to vector graphics, force the font size.
-  // 13.4px == 10pt @ 96dpi
+  // 10.7px == 8pt @ 96dpi
   gtk_util::ForceFontSizePixels(
-      GTK_CHROME_LINK_BUTTON(instructions_link_)->label, 13.4);
+      GTK_CHROME_LINK_BUTTON(instructions_link_)->label, 10.7);
   gtk_util::CenterWidgetInHBox(instructions_hbox_, instructions_link_,
                                false, 6);
   g_signal_connect(GTK_CHROME_LINK_BUTTON(instructions_link_)->label, "map",
diff -Nur a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc
--- a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc    2011-01-27 23:38:47.940027001 +0100
@@ -67,7 +67,7 @@
   if (!label_string.empty()) {
     GtkWidget* label = gtk_label_new(label_string.c_str());
     // Until we switch to vector graphics, force the font size.
-    gtk_util::ForceFontSizePixels(label, 13.4);  // 13.4px == 10pt @ 96dpi
+    gtk_util::ForceFontSizePixels(label, 10.7);  // 10.7px == 8pt @ 96dpi
 
     // Ellipsize long bookmark names.
     if (ellipsize) {
diff -Nur a/chrome/browser/ui/gtk/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download_shelf_gtk.cc
--- a/chrome/browser/ui/gtk/download_shelf_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/download_shelf_gtk.cc    2011-01-27 23:39:45.779026988 +0100
@@ -109,9 +109,9 @@
                    G_CALLBACK(OnButtonClickThunk), this);
   gtk_util::SetButtonTriggersNavigation(link_button_);
   // Until we switch to vector graphics, force the font size.
-  // 13.4px == 10pt @ 96dpi
+  // 10.7px == 8pt @ 96dpi
   gtk_util::ForceFontSizePixels(GTK_CHROME_LINK_BUTTON(link_button_)->label,
-                                13.4);
+                                10.7);
 
   // Make the download arrow icon.
   ResourceBundle& rb = ResourceBundle::GetSharedInstance();
diff -Nur a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc
--- a/chrome/browser/ui/gtk/find_bar_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/find_bar_gtk.cc    2011-01-27 23:40:14.431026982 +0100
@@ -507,8 +507,8 @@
                            &kEntryTextColor);
 
     // 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_util::ForceFontSizePixels(text_entry_, 10.7);  // 10.7px == 8pt @ 96dpi
+    gtk_util::ForceFontSizePixels(match_count_label_, 10.7);
 
     // Force the text widget height so it lines up with the buttons regardless
     // of font size.
diff -Nur a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc
--- a/chrome/browser/ui/gtk/first_run_dialog.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/first_run_dialog.cc    2011-01-27 23:40:39.043026965 +0100
@@ -183,8 +183,8 @@
   GtkWidget* welcome_message = gtk_util::CreateBoldLabel(
       l10n_util::GetStringUTF8(IDS_FR_SEARCH_MAIN_LABEL));
   // Force the font size to make sure the label doesn't overlap the image.
-  // 13.4px == 10pt @ 96dpi
-  gtk_util::ForceFontSizePixels(welcome_message, 13.4);
+  // 10.7px == 8pt @ 96dpi
+  gtk_util::ForceFontSizePixels(welcome_message, 10.7);
 
   GtkWidget* top_area = gtk_floating_container_new();
   gtk_container_add(GTK_CONTAINER(top_area), top_image);
diff -Nur a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc    2011-01-27 10:01:43.000000000 +0100
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc    2011-01-27 23:41:43.555026995 +0100
@@ -1074,10 +1074,8 @@
 
   ResourceBundle& rb = ResourceBundle::GetSharedInstance();
   const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
-  // Dividing by the pango scale factor maintains an absolute pixel size across
-  // all DPIs.
-  int size = static_cast<int>(13 / gfx::PlatformFontGtk::GetPangoScaleFactor());
-  title_font_ = new gfx::Font(base_font.GetFontName(), size);
+  // Force the font size to 8pt
+  title_font_ = new gfx::Font(base_font.GetFontName(), 8);
   title_font_height_ = title_font_->GetHeight();
 
   crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);

It's for Chromium 10, it won't apply to earlier versions. I posted a version for Chromium 8 to pastebin.ca once, but it's not accessible for me at the moment: http://pastebin.ca/2022940

I found the same patch against Chromium 9, and adjusted the settings for my DPI. Compiled and installed via tweaked PKGBUILD and fonts look good now. Thanks!

Offline

Board footer

Powered by FluxBB