diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 19:40:52 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 19:40:52 +0000 |
commit | 761a23dc57767c16599b03df11547cc810d31968 (patch) | |
tree | 7d5ca17842c75a30c723d80982fbb5d20b38717c | |
parent | 800065dcdca61a5012b3e01059fab456d612e101 (diff) | |
download | chromium_src-761a23dc57767c16599b03df11547cc810d31968.zip chromium_src-761a23dc57767c16599b03df11547cc810d31968.tar.gz chromium_src-761a23dc57767c16599b03df11547cc810d31968.tar.bz2 |
[gtk] make tab title font irrespective of display DPI.
The font size is changed from 9 to 13 in order to offset the new correction. The font has the same same pixel size that was displayed before on my 101 DPI display.
BUG=62536
TEST=using Xephyr -dpi XXX
Review URL: http://codereview.chromium.org/4837002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65971 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 8 | ||||
-rw-r--r-- | gfx/platform_font_gtk.cc | 4 | ||||
-rw-r--r-- | gfx/platform_font_gtk.h | 6 |
3 files changed, 10 insertions, 8 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 318fcbe..cf1f62c0 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -22,6 +22,7 @@ #include "chrome/common/notification_service.h" #include "gfx/canvas_skia_paint.h" #include "gfx/favicon_size.h" +#include "gfx/platform_font_gtk.h" #include "gfx/skbitmap_operations.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" @@ -1070,10 +1071,11 @@ void TabRendererGtk::InitResources() { LoadTabImages(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - // Force the font size to 9pt, which matches Windows' default font size - // (taken from the system). const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); - title_font_ = new gfx::Font(base_font.GetFontName(), 9); + // 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); title_font_height_ = title_font_->GetHeight(); crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); diff --git a/gfx/platform_font_gtk.cc b/gfx/platform_font_gtk.cc index 5ed7793..7633c10 100644 --- a/gfx/platform_font_gtk.cc +++ b/gfx/platform_font_gtk.cc @@ -135,7 +135,7 @@ PlatformFontGtk::PlatformFontGtk(NativeFont native_font) { // font_size_ is treated as scaled (see comment in GetPangoScaleFactor). If // we get here the font size is absolute though, and we need to invert the // scale so that when scaled in the rest of this class everything lines up. - size /= PlatformFontGtk::GetPangoScaleFactor(); + size /= GetPangoScaleFactor(); } // Find best match font for |family_name| to make sure we can get @@ -350,7 +350,7 @@ void PlatformFontGtk::PaintSetup(SkPaint* paint) const { paint->setAntiAlias(false); paint->setSubpixelText(false); paint->setTextSize( - SkFloatToScalar(font_size_ * PlatformFontGtk::GetPangoScaleFactor())); + SkFloatToScalar(font_size_ * GetPangoScaleFactor())); paint->setTypeface(typeface_); paint->setFakeBoldText((gfx::Font::BOLD & style_) && !typeface_->isBold()); paint->setTextSkewX((gfx::Font::ITALIC & style_) && !typeface_->isItalic() ? diff --git a/gfx/platform_font_gtk.h b/gfx/platform_font_gtk.h index bd26d8f..bc7be66 100644 --- a/gfx/platform_font_gtk.h +++ b/gfx/platform_font_gtk.h @@ -46,6 +46,9 @@ class PlatformFontGtk : public PlatformFont { virtual int GetFontSize() const; virtual NativeFont GetNativeFont() const; + // Return the scale factor for fonts that account for DPI. + static float GetPangoScaleFactor(); + private: // Create a new instance of this object with the specified properties. Called // from DeriveFont. @@ -72,9 +75,6 @@ class PlatformFontGtk : public PlatformFont { // Make |this| a copy of |other|. void CopyFont(const Font& other); - // Return the scale factor for fonts that account for DPI. - static float GetPangoScaleFactor(); - // The average width of a character, initialized and cached if needed. double GetAverageWidth() const; |