diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 21:34:29 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 21:34:29 +0000 |
commit | ea500fc6e9828bc028a26b5be33d102a260cfc05 (patch) | |
tree | b2dc64ee3cf7b4f9ea825552a2eefe514cf7a8fe /app | |
parent | 8f6f202305d14eef7c3813bc41985f90e28a8f15 (diff) | |
download | chromium_src-ea500fc6e9828bc028a26b5be33d102a260cfc05.zip chromium_src-ea500fc6e9828bc028a26b5be33d102a260cfc05.tar.gz chromium_src-ea500fc6e9828bc028a26b5be33d102a260cfc05.tar.bz2 |
Make gfx::Font use callbacks to perform locale-dependent font adjustments. Also cleans up some of the last remaining l10n_util usages within app/gfx in preparation for moving these files to toplevel gfx.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1110008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/app_base.gypi | 4 | ||||
-rw-r--r-- | app/gfx/canvas.cc | 1 | ||||
-rw-r--r-- | app/gfx/canvas_mac.mm | 1 | ||||
-rw-r--r-- | app/gfx/font.h | 13 | ||||
-rw-r--r-- | app/gfx/font_win.cc | 17 |
5 files changed, 25 insertions, 11 deletions
diff --git a/app/app_base.gypi b/app/app_base.gypi index 0f6f363..578701f 100644 --- a/app/app_base.gypi +++ b/app/app_base.gypi @@ -93,10 +93,10 @@ }, 'sources': [ # Files that are not required for Win64 Native Client loader - 'animation.cc', - 'animation.h', 'active_window_watcher_x.cc', 'active_window_watcher_x.h', + 'animation.cc', + 'animation.h', 'bidi_line_iterator.cc', 'clipboard/clipboard.cc', 'clipboard/clipboard.h', diff --git a/app/gfx/canvas.cc b/app/gfx/canvas.cc index 75ec0a1..11cf3d5 100644 --- a/app/gfx/canvas.cc +++ b/app/gfx/canvas.cc @@ -7,7 +7,6 @@ #include <limits> #include "app/gfx/font.h" -#include "app/l10n_util.h" #include "base/i18n/rtl.h" #include "base/logging.h" #include "gfx/rect.h" diff --git a/app/gfx/canvas_mac.mm b/app/gfx/canvas_mac.mm index acc2d71..37d97db 100644 --- a/app/gfx/canvas_mac.mm +++ b/app/gfx/canvas_mac.mm @@ -7,7 +7,6 @@ #include "app/gfx/canvas.h" #include "app/gfx/font.h" -#include "app/l10n_util.h" #include "base/scoped_cftyperef.h" #include "base/sys_string_conversions.h" #include "gfx/rect.h" diff --git a/app/gfx/font.h b/app/gfx/font.h index f79f6d0..8086117 100644 --- a/app/gfx/font.h +++ b/app/gfx/font.h @@ -125,6 +125,19 @@ class Font { int vertical_dlus_to_pixels(int dlus) { return dlus * font_ref_->height() / 8; } + + // Callback that returns the minimum height that should be used for + // gfx::Fonts. Optional. If not specified, the minimum font size is 0. + typedef int (*GetMinimumFontSizeCallback)(); + static GetMinimumFontSizeCallback get_minimum_font_size_callback; + + // Callback that adjusts a LOGFONT to meet suitability requirements of the + // embedding application. Optional. If not specified, no adjustments are + // performed other than clamping to a minimum font height if + // |get_minimum_font_size_callback| is specified. + typedef void (*AdjustFontCallback)(LOGFONT* lf); + static AdjustFontCallback adjust_font_callback; + #elif !defined(OS_MACOSX) static Font CreateFont(PangoFontDescription* desc); // We need a copy constructor and assignment operator to deal with diff --git a/app/gfx/font_win.cc b/app/gfx/font_win.cc index 1f69afa..cffd417 100644 --- a/app/gfx/font_win.cc +++ b/app/gfx/font_win.cc @@ -9,18 +9,19 @@ #include <algorithm> -#include "app/l10n_util.h" -#include "app/l10n_util_win.h" #include "base/logging.h" #include "base/string_util.h" #include "base/win_util.h" -#include "grit/app_locale_settings.h" namespace gfx { -/*static*/ +// static Font::HFontRef* Font::base_font_ref_; +// static +Font::AdjustFontCallback Font::adjust_font_callback = NULL; +Font::GetMinimumFontSizeCallback Font::get_minimum_font_size_callback = NULL; + // If the tmWeight field of a TEXTMETRIC structure has a value >= this, the // font is bold. static const int kTextMetricWeightBold = 700; @@ -33,8 +34,9 @@ static int AdjustFontSize(int lf_height, int size_delta) { } else { lf_height += size_delta; } - int min_font_size = - StringToInt(l10n_util::GetString(IDS_MINIMUM_UI_FONT_SIZE).c_str()); + int min_font_size = 0; + if (Font::get_minimum_font_size_callback) + min_font_size = Font::get_minimum_font_size_callback(); // Make sure lf_height is not smaller than allowed min font size for current // locale. if (abs(lf_height) < min_font_size) { @@ -99,7 +101,8 @@ Font::HFontRef* Font::GetBaseFontRef() { NONCLIENTMETRICS metrics; win_util::GetNonClientMetrics(&metrics); - l10n_util::AdjustUIFont(&metrics.lfMessageFont); + if (adjust_font_callback) + adjust_font_callback(&metrics.lfMessageFont); metrics.lfMessageFont.lfHeight = AdjustFontSize(metrics.lfMessageFont.lfHeight, 0); HFONT font = CreateFontIndirect(&metrics.lfMessageFont); |