summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup.cc2
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc7
-rw-r--r--chrome/browser/views/options/options_group_view.cc2
-rw-r--r--chrome/common/gfx/chrome_font.h7
-rw-r--r--chrome/views/text_field.cc2
-rw-r--r--chrome/views/window.cc2
6 files changed, 14 insertions, 8 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup.cc b/chrome/browser/autocomplete/autocomplete_popup.cc
index 7f17572..e44ac90 100644
--- a/chrome/browser/autocomplete/autocomplete_popup.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup.cc
@@ -624,7 +624,7 @@ AutocompletePopupView::DrawLineInfo::DrawLineInfo(const ChromeFont& font) {
static const int kTotalLinePadding = 5;
font_height = std::max(regular_font.height(), bold_font.height());
line_height = font_height + kTotalLinePadding;
- ave_char_width = regular_font.ave_char_width();
+ ave_char_width = regular_font.GetExpectedTextWidth(1);
ellipsis_width = std::max(regular_font.GetStringWidth(ellipsis_str),
bold_font.GetStringWidth(ellipsis_str));
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index 3d94245..aa0b7be 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -172,7 +172,7 @@ void FontDisplayView::Layout() {
gfx::Size FontDisplayView::GetPreferredSize() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
- return gfx::Size(font.ave_char_width() * kFontDisplayMaxWidthChars,
+ return gfx::Size(font.GetExpectedTextWidth(kFontDisplayMaxWidthChars),
font.height() * kFontDisplayMaxHeightChars
+ 2 * kFontDisplayLabelPadding);
}
@@ -405,9 +405,8 @@ void FontsPageView::InitFontLayout() {
const int triple_column_view_set_id = 0;
ColumnSet* column_set = layout->AddColumnSet(triple_column_view_set_id);
- int label_width =
- _wtoi(l10n_util::GetString(IDS_FONTSLANG_LABEL_WIDTH).c_str()) *
- ChromeFont().ave_char_width();
+ int label_width = ChromeFont().GetExpectedTextWidth(
+ _wtoi(l10n_util::GetString(IDS_FONTSLANG_LABEL_WIDTH).c_str()));
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
GridLayout::FIXED, label_width, 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
diff --git a/chrome/browser/views/options/options_group_view.cc b/chrome/browser/views/options/options_group_view.cc
index 3fbbe08..bdf76ea 100644
--- a/chrome/browser/views/options/options_group_view.cc
+++ b/chrome/browser/views/options/options_group_view.cc
@@ -96,7 +96,7 @@ void OptionsGroupView::Init() {
std::wstring left_column_chars =
l10n_util::GetString(IDS_OPTIONS_DIALOG_LEFT_COLUMN_WIDTH_CHARS);
int left_column_width =
- font.ave_char_width() * _wtoi(left_column_chars.c_str());
+ font.GetExpectedTextWidth(_wtoi(left_column_chars.c_str()));
const int two_column_layout_id = 0;
ColumnSet* column_set = layout->AddColumnSet(two_column_layout_id);
diff --git a/chrome/common/gfx/chrome_font.h b/chrome/common/gfx/chrome_font.h
index 77e48f6..2cfd28b 100644
--- a/chrome/common/gfx/chrome_font.h
+++ b/chrome/common/gfx/chrome_font.h
@@ -65,6 +65,13 @@ class ChromeFont {
// string.
int GetStringWidth(const std::wstring& text) const;
+ // Returns the expected number of horizontal pixels needed to display
+ // the specified length of characters.
+ // Call the GetStringWidth() function to retrieve the actual number.
+ int GetExpectedTextWidth(int length) const {
+ return length * font_ref_->dlu_base_x();
+ }
+
// Returns the style of the font.
int style() const { return font_ref_->style(); }
diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc
index be8911d..baa70a1 100644
--- a/chrome/views/text_field.cc
+++ b/chrome/views/text_field.cc
@@ -847,7 +847,7 @@ void TextField::Layout() {
gfx::Size TextField::GetPreferredSize() {
gfx::Insets insets;
CalculateInsets(&insets);
- return gfx::Size(default_width_in_chars_ * font_.ave_char_width() +
+ return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) +
insets.width(),
num_lines_ * font_.height() + insets.height());
}
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index 0eaa599..1566584 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -251,7 +251,7 @@ gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
double chars = _wtof(l10n_util::GetString(col_resource_id).c_str());
double lines = _wtof(l10n_util::GetString(row_resource_id).c_str());
- int width = static_cast<int>(font.ave_char_width() * chars);
+ int width = font.GetExpectedTextWidth(static_cast<int>(chars));
int height = static_cast<int>(font.height() * lines);
DCHECK(width > 0 && height > 0);