diff options
author | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-15 19:16:10 +0000 |
---|---|---|
committer | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-15 19:16:10 +0000 |
commit | 3bd29d38ab1b03648ba9d3682ddc1d23c5cadad5 (patch) | |
tree | 20e24e86fa15207175dbcd1c0da23b31d980bfb2 /chrome/browser/views | |
parent | 658b4fe27cae13bd99c0d8cb910d3d4ee16fea7c (diff) | |
download | chromium_src-3bd29d38ab1b03648ba9d3682ddc1d23c5cadad5.zip chromium_src-3bd29d38ab1b03648ba9d3682ddc1d23c5cadad5.tar.gz chromium_src-3bd29d38ab1b03648ba9d3682ddc1d23c5cadad5.tar.bz2 |
For some Indian locales, the automatic font fallback by Windows UI components leads to too tiny glyphs for UI strings. Therefore, this patch makes it possible to override the UI font family and UI font size localizable by adding two entries to locale_settings (IDS_UI_FONT_FAMILY and IDS_UI_FONT_SIZE_SCALER - percentile scale).
It's is also to fix a P1 bug for Chrome 2.0 final (so this patch needs to be merged back to the branch).
For most locales, the UI font family is set to 'default' and the UI font size scaler is set to 100, which indicates that the UI font (menu, message, etc) obtained from Windows will be used.
For ml and bn, it's set to the 'kartica' and 'vrinda' (the default Windows fonts for those scripts) and the scaler is set to 150 and 160 respectively. For Hindi and Telugu, only the font size scaler is set to 150.
When IDS_UI_FONT_FAMILY is 'default' and the scaler is 100, the behavior will remain the same. When it's not, their values are used to create ChromeFont (base and derived) and WindowsTitle font. In addition, menu will be drawn by 'owner' (to override the windows font) and the font for table view, tree and tooltip is also set to IDS_UI_FONT_FAMILY.
While working on this, I replaced all the instances of 'static ChromeFont' with 'static ChromeFont*' and initialized them in a lazy manner.
The whole approach is still a hack necessary due to the size issue with the default fonts for some Indic scripts on Windows. We'd not need this on Linux and Mac.
TEST=1. Run chrome with '--lang=bn' or '--lang=ml' and see UI strings are legible in menu, context menu, bookmark, bookmark manager, tooltips, and tab titles. With '--lang=hi' and '--lang=te', the difference is not dramatic but should be more readable. In other locales, it should remain the same.
2.UI test in en-US locale should pass.
3. Running UI tests under Purify should not have any new leak.
BUG=7319
Review URL: http://codereview.chromium.org/62064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/sad_tab_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/sad_tab_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.cc | 8 |
6 files changed, 32 insertions, 30 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index a6cd377..95bfd91 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -267,12 +267,12 @@ class ConstrainedWindowFrameView static void InitClass(); // The font to be used to render the titlebar text. - static ChromeFont title_font_; + static ChromeFont* title_font_; DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView); }; -ChromeFont ConstrainedWindowFrameView::title_font_; +ChromeFont* ConstrainedWindowFrameView::title_font_ = NULL; namespace { // The frame border is only visible in restored mode and is hardcoded to 4 px on @@ -461,7 +461,7 @@ int ConstrainedWindowFrameView::TitleCoordinates( // The bottom spacing should be the same apparent height as the top spacing, // plus have the client edge tacked on. int title_bottom_spacing = *title_top_spacing + kClientEdgeThickness; - *title_thickness = std::max(title_font_.height(), + *title_thickness = std::max(title_font_->height(), min_titlebar_height - *title_top_spacing - title_bottom_spacing); return *title_top_spacing + *title_thickness + title_bottom_spacing; } @@ -511,7 +511,7 @@ void ConstrainedWindowFrameView::PaintFrameBorder(ChromeCanvas* canvas) { } void ConstrainedWindowFrameView::PaintTitleBar(ChromeCanvas* canvas) { - canvas->DrawStringInt(container_->GetWindowTitle(), title_font_, + canvas->DrawStringInt(container_->GetWindowTitle(), *title_font_, GetTitleColor(), MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); } @@ -545,9 +545,9 @@ void ConstrainedWindowFrameView::LayoutTitleBar() { int title_top_spacing, title_thickness; TitleCoordinates(&title_top_spacing, &title_thickness); title_bounds_.SetRect(title_x, - title_top_spacing + ((title_thickness - title_font_.height()) / 2), + title_top_spacing + ((title_thickness - title_font_->height()) / 2), std::max(0, close_button_->x() - kTitleCaptionSpacing - title_x), - title_font_.height()); + title_font_->height()); } void ConstrainedWindowFrameView::LayoutClientView() { @@ -580,7 +580,7 @@ void ConstrainedWindowFrameView::InitWindowResources() { void ConstrainedWindowFrameView::InitClass() { static bool initialized = false; if (!initialized) { - title_font_ = win_util::GetWindowTitleFont(); + title_font_ = new ChromeFont(win_util::GetWindowTitleFont()); initialized = true; } diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index 2e8658c..9e8692b 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -259,7 +259,7 @@ views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL; views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL; views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL; SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL; -ChromeFont OpaqueBrowserFrameView::title_font_; +ChromeFont* OpaqueBrowserFrameView::title_font_ = NULL; namespace { // The frame border is only visible in restored mode and is hardcoded to 4 px on @@ -703,7 +703,7 @@ int OpaqueBrowserFrameView::TitleCoordinates(int* title_top_spacing, *title_top_spacing += title_adjust; title_bottom_spacing -= title_adjust; } - *title_thickness = std::max(title_font_.height(), + *title_thickness = std::max(title_font_->height(), min_titlebar_height - *title_top_spacing - title_bottom_spacing); return *title_top_spacing + *title_thickness + title_bottom_spacing + UnavailablePixelsAtBottomOfNonClientHeight(); @@ -788,7 +788,7 @@ void OpaqueBrowserFrameView::PaintTitleBar(ChromeCanvas* canvas) { // The window icon is painted by the TabIconView. views::WindowDelegate* d = frame_->GetDelegate(); if (d->ShouldShowWindowTitle()) { - canvas->DrawStringInt(d->GetWindowTitle(), title_font_, SK_ColorWHITE, + canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); /* TODO(pkasting): If this window is active, we should also draw a drop @@ -970,6 +970,7 @@ void OpaqueBrowserFrameView::LayoutTitleBar() { // The usable height of the titlebar area is the total height minus the top // resize border and any edge area we draw at its bottom. int title_top_spacing, title_thickness; + InitAppWindowResources(); int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); int available_height = top_height - frame_thickness - UnavailablePixelsAtBottomOfNonClientHeight(); @@ -1001,9 +1002,9 @@ void OpaqueBrowserFrameView::LayoutTitleBar() { int title_x = icon_x + icon_size + (d->ShouldShowWindowIcon() ? kIconTitleSpacing : 0); title_bounds_.SetRect(title_x, - title_top_spacing + ((title_thickness - title_font_.height()) / 2), + title_top_spacing + ((title_thickness - title_font_->height()) / 2), std::max(0, logo_bounds_.x() - kTitleLogoSpacing - title_x), - title_font_.height()); + title_font_->height()); } } @@ -1057,7 +1058,7 @@ void OpaqueBrowserFrameView::InitClass() { void OpaqueBrowserFrameView::InitAppWindowResources() { static bool initialized = false; if (!initialized) { - title_font_ = win_util::GetWindowTitleFont(); + title_font_ = new ChromeFont(win_util::GetWindowTitleFont()); initialized = true; } } diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h index 83a84c5..fd80b7c 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/views/frame/opaque_browser_frame_view.h @@ -158,7 +158,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, static views::WindowResources* inactive_resources_; static views::WindowResources* active_otr_resources_; static views::WindowResources* inactive_otr_resources_; - static ChromeFont title_font_; + static ChromeFont* title_font_; DISALLOW_EVIL_CONSTRUCTORS(OpaqueBrowserFrameView); }; diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc index d7e2de4..509f951 100644 --- a/chrome/browser/views/sad_tab_view.cc +++ b/chrome/browser/views/sad_tab_view.cc @@ -25,8 +25,8 @@ static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64); // static SkBitmap* SadTabView::sad_tab_bitmap_ = NULL; -ChromeFont SadTabView::title_font_; -ChromeFont SadTabView::message_font_; +ChromeFont* SadTabView::title_font_ = NULL; +ChromeFont* SadTabView::message_font_ = NULL; std::wstring SadTabView::title_; std::wstring SadTabView::message_; int SadTabView::title_width_; @@ -47,12 +47,12 @@ void SadTabView::Paint(ChromeCanvas* canvas) { canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y()); - canvas->DrawStringInt(title_, title_font_, kTitleColor, title_bounds_.x(), + canvas->DrawStringInt(title_, *title_font_, kTitleColor, title_bounds_.x(), title_bounds_.y(), title_bounds_.width(), title_bounds_.height(), ChromeCanvas::TEXT_ALIGN_CENTER); - canvas->DrawStringInt(message_, message_font_, kMessageColor, + canvas->DrawStringInt(message_, *message_font_, kMessageColor, message_bounds_.x(), message_bounds_.y(), message_bounds_.width(), message_bounds_.height(), ChromeCanvas::MULTI_LINE); @@ -67,13 +67,13 @@ void SadTabView::Layout() { int title_x = (width() - title_width_) / 2; int title_y = icon_bounds_.bottom() + kIconTitleSpacing; - int title_height = title_font_.height(); + int title_height = title_font_->height(); title_bounds_.SetRect(title_x, title_y, title_width_, title_height); ChromeCanvas cc(0, 0, true); int message_width = static_cast<int>(width() * kMessageSize); int message_height = 0; - cc.SizeStringInt(message_, message_font_, &message_width, &message_height, + cc.SizeStringInt(message_, *message_font_, &message_width, &message_height, ChromeCanvas::MULTI_LINE); int message_x = (width() - message_width) / 2; int message_y = title_bounds_.bottom() + kTitleMessageSpacing; @@ -85,13 +85,14 @@ void SadTabView::InitClass() { static bool initialized = false; if (!initialized) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - title_font_ = rb.GetFont(ResourceBundle::BaseFont). - DeriveFont(2, ChromeFont::BOLD); - message_font_ = rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1); + title_font_ = new ChromeFont( + rb.GetFont(ResourceBundle::BaseFont).DeriveFont(2, ChromeFont::BOLD)); + message_font_ = new ChromeFont( + rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1)); sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); - title_width_ = title_font_.GetStringWidth(title_); + title_width_ = title_font_->GetStringWidth(title_); message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); initialized = true; diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h index 5b2f7e7..766ad77 100644 --- a/chrome/browser/views/sad_tab_view.h +++ b/chrome/browser/views/sad_tab_view.h @@ -39,8 +39,8 @@ class SadTabView : public views::View { // Assorted resources for display. static SkBitmap* sad_tab_bitmap_; - static ChromeFont title_font_; - static ChromeFont message_font_; + static ChromeFont* title_font_; + static ChromeFont* message_font_; static std::wstring title_; static std::wstring message_; static int title_width_; diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index e2d6381..88033a4 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -46,7 +46,7 @@ static const double kHoverOpacity = 0.33; static const double kHoverOpacityVista = 0.7; // TODO(beng): (Cleanup) This stuff should move onto the class. -static ChromeFont title_font; +static ChromeFont* title_font = NULL; static int title_font_height = 0; static SkBitmap* close_button_n = NULL; static SkBitmap* close_button_h = NULL; @@ -74,8 +74,8 @@ void InitResources() { static bool initialized = false; if (!initialized) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - title_font = rb.GetFont(ResourceBundle::BaseFont); - title_font_height = title_font.height(); + title_font = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont)); + title_font_height = title_font->height(); close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE); close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H); @@ -413,7 +413,7 @@ void TabRenderer::Paint(ChromeCanvas* canvas) { SkColor title_color = IsSelected() ? kSelectedTitleColor : kUnselectedTitleColor; - canvas->DrawStringInt(title, title_font, title_color, title_bounds_.x(), + canvas->DrawStringInt(title, *title_font, title_color, title_bounds_.x(), title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); } |