summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 16:22:56 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 16:22:56 +0000
commita2cf67e5986cdbdba24eb2b4ee0ef7be810e7cc7 (patch)
treee6bc10d56eac0b942b3e0c05e11a5d01614c2306
parentf1c7411610f2f849f74eb8d911665e607657a028 (diff)
downloadchromium_src-a2cf67e5986cdbdba24eb2b4ee0ef7be810e7cc7.zip
chromium_src-a2cf67e5986cdbdba24eb2b4ee0ef7be810e7cc7.tar.gz
chromium_src-a2cf67e5986cdbdba24eb2b4ee0ef7be810e7cc7.tar.bz2
Fix Issue 2918 in chromium: Chrome dialog displayed in large size with Meiryo font.This issue is caused by a font whose text metric |tmAveCharWidth| is not precise as noted in Microsoft Knowledge Base 145994 (*1) To handle this case, this change uses the ChromeFont::horizontal_dlus_to_pixels() function instead of the ChromeFont::ave_char_width() function.(*1) http://support.microsoft.com/kb/145994BUG=2918
Review URL: http://codereview.chromium.org/8051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4213 0039d316-1c4b-4281-b951-d872f2087c98
-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);