diff options
author | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-02 20:33:23 +0000 |
---|---|---|
committer | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-02 20:33:23 +0000 |
commit | 77c2e235cb8ed0214de790422777bf7e520bd7a9 (patch) | |
tree | 6dad4ed30f67701c717377a9f604b10bf2d33886 /chrome/browser | |
parent | adeb5ed2b5ff8135d9cd94bd874b1c5e373b1d7a (diff) | |
download | chromium_src-77c2e235cb8ed0214de790422777bf7e520bd7a9.zip chromium_src-77c2e235cb8ed0214de790422777bf7e520bd7a9.tar.gz chromium_src-77c2e235cb8ed0214de790422777bf7e520bd7a9.tar.bz2 |
Clean-up: Replaces gfx::Font with gfx::FontList in c/b/ui/views.
As part of effort to support multiple fonts, this CL changes methods which are now taking gfx::Font so they will take gfx::FontList instead.
See https://docs.google.com/a/chromium.org/document/d/1D_25fp9B8b9aZJORfAjDIFq61NWvUquZ5xmKH-VcC4k/view
TBR=estade@chromium.org, jianli@chromium.org, markusheintz@chromium.org
BUG=265485
TEST=Run unit_tests, ui_unittests, views_unittests
Review URL: https://codereview.chromium.org/121183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242786 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
36 files changed, 170 insertions, 192 deletions
diff --git a/chrome/browser/ui/views/accessibility/invert_bubble_view.cc b/chrome/browser/ui/views/accessibility/invert_bubble_view.cc index dc120bb..52c3db1 100644 --- a/chrome/browser/ui/views/accessibility/invert_bubble_view.cc +++ b/chrome/browser/ui/views/accessibility/invert_bubble_view.cc @@ -68,30 +68,32 @@ InvertBubbleView::~InvertBubbleView() { void InvertBubbleView::Init() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const gfx::Font& original_font = rb.GetFont(ui::ResourceBundle::MediumFont); + const gfx::FontList& original_font_list = + rb.GetFontList(ui::ResourceBundle::MediumFont); views::Label* title = new views::Label( - l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_NOTIFICATION)); - title->SetFont(original_font.DeriveFont(2, gfx::Font::BOLD)); + l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_NOTIFICATION), + original_font_list.DeriveFontListWithSizeDeltaAndStyle(2, + gfx::Font::BOLD)); title->SetMultiLine(true); title->SizeToFit(kBubbleWidth); learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); - learn_more_->SetFont(original_font); + learn_more_->SetFontList(original_font_list); learn_more_->set_listener(this); high_contrast_ = new views::Link(l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_EXT)); - high_contrast_->SetFont(original_font); + high_contrast_->SetFontList(original_font_list); high_contrast_->set_listener(this); dark_theme_ = new views::Link(l10n_util::GetStringUTF16(IDS_DARK_THEME)); - dark_theme_->SetFont(original_font); + dark_theme_->SetFontList(original_font_list); dark_theme_->set_listener(this); close_ = new views::Link(l10n_util::GetStringUTF16(IDS_CLOSE)); - close_->SetFont(original_font); + close_->SetFontList(original_font_list); close_->set_listener(this); views::GridLayout* layout = views::GridLayout::CreatePanel(this); diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index e0948e9..eebd2e1 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -35,6 +35,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/path.h" #include "ui/gfx/point.h" #include "ui/gfx/skia_util.h" @@ -392,19 +393,16 @@ class LoadingAnimationView : public views::View, container_->SetLayoutManager( new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); - gfx::Font font = ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont).DeriveFont(8); - animation_.reset(new LoadingAnimation(this, font.GetHeight())); + const gfx::FontList& font_list = + ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::LargeFont); + animation_.reset(new LoadingAnimation(this, font_list.GetHeight())); - views::Label* label = new views::Label(); - label->SetText(text); - label->SetFont(font); + views::Label* label = new views::Label(text, font_list); container_->AddChildView(label); for (size_t i = 0; i < 3; ++i) { - views::Label* dot = new views::Label(); - dot->SetText(base::ASCIIToUTF16(".")); - dot->SetFont(font); + views::Label* dot = new views::Label(base::ASCIIToUTF16("."), font_list); container_->AddChildView(dot); } @@ -589,7 +587,7 @@ void AutofillDialogViews::OverlayView::UpdateState() { message_view_->SetVisible(!state.string.text.empty()); message_view_->SetText(state.string.text); - message_view_->SetFont(state.string.font); + message_view_->SetFontList(gfx::FontList(state.string.font)); message_view_->SetEnabledColor(state.string.text_color); message_view_->set_border( views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, @@ -789,9 +787,8 @@ AutofillDialogViews::SectionContainer::SectionContainer( kDialogEdgePadding)); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - gfx::FontList default_fonts = rb.GetFontList(ui::ResourceBundle::BaseFont); - gfx::FontList bold_fonts = default_fonts.DeriveFontList(gfx::Font::BOLD); - views::Label* label_view = new views::Label(label, bold_fonts); + views::Label* label_view = new views::Label( + label, rb.GetFontList(ui::ResourceBundle::BoldFont)); label_view->SetHorizontalAlignment(gfx::ALIGN_LEFT); views::View* label_bar = new views::View(); diff --git a/chrome/browser/ui/views/avatar_label.cc b/chrome/browser/ui/views/avatar_label.cc index 3a36579..de923db 100644 --- a/chrome/browser/ui/views/avatar_label.cc +++ b/chrome/browser/ui/views/avatar_label.cc @@ -11,11 +11,11 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/events/event.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" +#include "ui/gfx/font_list.h" #include "ui/views/painter.h" namespace { @@ -40,11 +40,11 @@ AvatarLabelBorder::AvatarLabelBorder() { const int kHorizontalInsetLeft = 43; const int kVerticalInsetTop = 2; const int kVerticalInsetBottom = 3; - // We want to align with the top of the tab. This works if the BaseFont size - // is 13. If it is smaller, we need to increase the TopInset accordingly. - gfx::Font font = ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont); - int difference = (font.GetFontSize() < 13) ? 13 - font.GetFontSize() : 0; + // We want to align with the top of the tab. This works if the default font + // size is 13. If it is smaller, we need to increase the TopInset accordingly. + const gfx::FontList font_list; + int difference = + (font_list.GetFontSize() < 13) ? 13 - font_list.GetFontSize() : 0; int addToTop = difference / 2; int addToBottom = difference - addToTop; SetInsets(gfx::Insets(kVerticalInsetTop + addToTop, @@ -95,8 +95,6 @@ AvatarLabel::AvatarLabel(BrowserView* browser_view) : TextButton(NULL, l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL)), browser_view_(browser_view) { - SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont)); ClearMaxTextSize(); set_border(new AvatarLabelBorder); UpdateLabelStyle(); diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc index 77339ed..f1093bb 100644 --- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc +++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc @@ -269,9 +269,9 @@ ProfileItemView::ProfileItemView(const AvatarMenu::Item& item, // Add a label to show the profile name. ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); name_label_ = new views::Label(item_.name, - rb->GetFont(item_.active ? - ui::ResourceBundle::BoldFont : - ui::ResourceBundle::BaseFont)); + rb->GetFontList(item_.active ? + ui::ResourceBundle::BoldFont : + ui::ResourceBundle::BaseFont)); name_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); AddChildView(name_label_); @@ -279,7 +279,8 @@ ProfileItemView::ProfileItemView(const AvatarMenu::Item& item, sync_state_label_ = new views::Label(item_.sync_state); if (item_.signed_in) sync_state_label_->SetElideBehavior(views::Label::ELIDE_AS_EMAIL); - sync_state_label_->SetFont(rb->GetFont(ui::ResourceBundle::SmallFont)); + sync_state_label_->SetFontList( + rb->GetFontList(ui::ResourceBundle::SmallFont)); sync_state_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); sync_state_label_->SetEnabled(false); AddChildView(sync_state_label_); @@ -761,7 +762,7 @@ void AvatarMenuBubbleView::InitManagedUserContents( // Add information about managed users. managed_user_info_ = new views::Label(avatar_menu_->GetManagedUserInformation(), - ui::ResourceBundle::GetSharedInstance().GetFont( + ui::ResourceBundle::GetSharedInstance().GetFontList( ui::ResourceBundle::SmallFont)); managed_user_info_->SetMultiLine(true); managed_user_info_->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc index 987577b..1bde9f6 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc @@ -134,7 +134,7 @@ void BookmarkBubbleView::Init() { newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK)); ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); - title_label->SetFont(rb->GetFont(ui::ResourceBundle::MediumFont)); + title_label->SetFontList(rb->GetFontList(ui::ResourceBundle::MediumFont)); remove_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16( IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK)); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_prompt_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_prompt_view.cc index d3940df..fe66839 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_prompt_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_prompt_view.cc @@ -53,8 +53,7 @@ void BookmarkPromptView::Init() { views::Label* label = new views::Label(l10n_util::GetStringUTF16( IDS_BOOKMARK_PROMPT_MESSAGE)); ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); - label->SetFont(rb->GetFont(ui::ResourceBundle::MediumFont) - .DeriveFont(0, gfx::Font::BOLD)); + label->SetFontList(rb->GetFontList(ui::ResourceBundle::MediumBoldFont)); AddChildView(label); dismiss_link_ = new views::Link(l10n_util::GetStringUTF16( diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc index 0fb6d3c..ff32dbd 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.cc +++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc @@ -24,6 +24,8 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/font_list.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/radio_button.h" @@ -338,10 +340,11 @@ void ContentSettingBubbleContents::Init() { } } - gfx::Font domain_font = - views::Label().font().DeriveFont(0, gfx::Font::BOLD); + const gfx::FontList& domain_font = + ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::BoldFont); for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( - bubble_content.domain_lists.begin()); + bubble_content.domain_lists.begin()); i != bubble_content.domain_lists.end(); ++i) { layout->StartRow(0, kSingleColumnSetId); views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); diff --git a/chrome/browser/ui/views/create_application_shortcut_view.cc b/chrome/browser/ui/views/create_application_shortcut_view.cc index 9316a40..fca0654 100644 --- a/chrome/browser/ui/views/create_application_shortcut_view.cc +++ b/chrome/browser/ui/views/create_application_shortcut_view.cc @@ -107,11 +107,12 @@ void AppInfoView::Init(const base::string16& title_text, icon_->SetImageSize(gfx::Size(kIconPreviewSizePixels, kIconPreviewSizePixels)); - title_ = new views::Label(title_text); + title_ = new views::Label( + title_text, + ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::BoldFont)); title_->SetMultiLine(true); title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - title_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD)); PrepareDescriptionLabel(description_text); diff --git a/chrome/browser/ui/views/critical_notification_bubble_view.cc b/chrome/browser/ui/views/critical_notification_bubble_view.cc index f2939a6..7359b48c 100644 --- a/chrome/browser/ui/views/critical_notification_bubble_view.cc +++ b/chrome/browser/ui/views/critical_notification_bubble_view.cc @@ -177,7 +177,7 @@ void CriticalNotificationBubbleView::Init() { layout->AddView(image); headline_ = new views::Label(); - headline_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + headline_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); UpdateBubbleHeadline(GetRemainingTime()); layout->AddView(headline_); diff --git a/chrome/browser/ui/views/extensions/bundle_installed_bubble.cc b/chrome/browser/ui/views/extensions/bundle_installed_bubble.cc index 3a6ca7b..e2ce524 100644 --- a/chrome/browser/ui/views/extensions/bundle_installed_bubble.cc +++ b/chrome/browser/ui/views/extensions/bundle_installed_bubble.cc @@ -135,7 +135,7 @@ class BundleInstalledBubble : public views::BubbleDelegateView, void AddHeading(GridLayout* layout, const base::string16& heading) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); views::Label* heading_label = new views::Label( - heading, rb.GetFont(ui::ResourceBundle::MediumFont)); + heading, rb.GetFontList(ui::ResourceBundle::MediumFont)); heading_label->SetMultiLine(true); heading_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); heading_label->SizeToFit(kLeftColumnWidth); diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc index dba1fa3..3bd21a3 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc @@ -30,6 +30,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/slide_animation.h" +#include "ui/gfx/text_utils.h" #include "ui/gfx/transform.h" #include "ui/views/background.h" #include "ui/views/border.h" @@ -568,23 +569,25 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( layout->AddView(rating); prompt.AppendRatingStars(AddResourceIcon, rating); - views::Label* rating_count = new views::Label(prompt.GetRatingCount()); - rating_count->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont)); + const gfx::FontList& small_font_list = + rb.GetFontList(ui::ResourceBundle::SmallFont); + views::Label* rating_count = + new views::Label(prompt.GetRatingCount(), small_font_list); // Add some space between the stars and the rating count. rating_count->set_border(views::Border::CreateEmptyBorder(0, 2, 0, 0)); rating->AddChildView(rating_count); layout->StartRow(0, column_set_id); - views::Label* user_count = new views::Label(prompt.GetUserCount()); + views::Label* user_count = + new views::Label(prompt.GetUserCount(), small_font_list); user_count->SetAutoColorReadabilityEnabled(false); user_count->SetEnabledColor(SK_ColorGRAY); - user_count->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont)); layout->AddView(user_count); layout->StartRow(0, column_set_id); views::Link* store_link = new views::Link( l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); - store_link->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont)); + store_link->SetFontList(small_font_list); store_link->set_listener(this); layout->AddView(store_link); } @@ -621,12 +624,12 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( layout->StartRow(0, column_set_id); views::Label* permissions_header = NULL; if (is_bundle_install()) { - // We need to pass the Font in the constructor, rather than calling - // SetFont later, because otherwise SizeToFit mis-judges the width + // We need to pass the FontList in the constructor, rather than calling + // SetFontList later, because otherwise SizeToFit mis-judges the width // of the line. permissions_header = new views::Label( prompt.GetPermissionsHeading(), - rb.GetFont(ui::ResourceBundle::MediumFont)); + rb.GetFontList(ui::ResourceBundle::MediumFont)); } else { permissions_header = new views::Label(prompt.GetPermissionsHeading()); } @@ -894,8 +897,8 @@ views::GridLayout* ExtensionInstallDialogView::CreateLayout( ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - views::Label* heading = new views::Label(prompt_.GetHeading()); - heading->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + views::Label* heading = new views::Label( + prompt_.GetHeading(), rb.GetFontList(ui::ResourceBundle::MediumFont)); heading->SetMultiLine(true); heading->SetHorizontalAlignment(gfx::ALIGN_LEFT); heading->SizeToFit(left_column_width); @@ -1247,10 +1250,12 @@ ExpandableContainerView::ExpandableContainerView( // toggle. int link_col_width = views::kRelatedControlHorizontalSpacing + - std::max(link->font_list().GetStringWidth( - l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS)), - link->font_list().GetStringWidth( - l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS))); + std::max(gfx::GetStringWidth( + l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS), + link->font_list()), + gfx::GetStringWidth( + l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS), + link->font_list())); column_set = layout->AddColumnSet(++column_set_id); // Padding to the left of the More Details column. If the parent is using @@ -1269,11 +1274,11 @@ ExpandableContainerView::ExpandableContainerView( link_col_width); // The Up/Down arrow column. column_set->AddColumn(views::GridLayout::LEADING, - views::GridLayout::LEADING, - 0, - views::GridLayout::USE_PREF, - 0, - 0); + views::GridLayout::LEADING, + 0, + views::GridLayout::USE_PREF, + 0, + 0); // Add the More Details link. layout->StartRow(0, column_set_id); diff --git a/chrome/browser/ui/views/extensions/extension_message_bubble_view.cc b/chrome/browser/ui/views/extensions/extension_message_bubble_view.cc index 3e940a9..659e946 100644 --- a/chrome/browser/ui/views/extensions/extension_message_bubble_view.cc +++ b/chrome/browser/ui/views/extensions/extension_message_bubble_view.cc @@ -203,9 +203,8 @@ void ExtensionMessageBubbleView::Init() { top_columns->AddPaddingColumn(1, 0); layout->StartRow(0, headline_column_set_id); - headline_ = new views::Label(); - headline_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); - headline_->SetText(delegate_->GetTitle()); + headline_ = new views::Label(delegate_->GetTitle(), + rb.GetFontList(ui::ResourceBundle::MediumFont)); layout->AddView(headline_); layout->AddPaddingRow(0, kHeadlineRowPadding); diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index 36c8893..a87902d 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -82,7 +82,6 @@ FindBarView::FindBarView(FindBarHost* host) find_text_ = new views::Textfield; find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); - find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); find_text_->set_default_width_in_chars(kDefaultCharWidth); find_text_->SetController(this); find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); @@ -90,7 +89,6 @@ FindBarView::FindBarView(FindBarHost* host) AddChildView(find_text_); match_count_text_ = new views::Label(); - match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); AddChildView(match_count_text_); // Create a focus forwarder view which sends focus to find_text_. diff --git a/chrome/browser/ui/views/first_run_bubble.cc b/chrome/browser/ui/views/first_run_bubble.cc index 030e7bb..9f4150b 100644 --- a/chrome/browser/ui/views/first_run_bubble.cc +++ b/chrome/browser/ui/views/first_run_bubble.cc @@ -38,21 +38,23 @@ FirstRunBubble* FirstRunBubble::ShowBubble(Browser* browser, void FirstRunBubble::Init() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const gfx::Font& original_font = rb.GetFont(ui::ResourceBundle::MediumFont); + const gfx::FontList& original_font_list = + rb.GetFontList(ui::ResourceBundle::MediumFont); views::Label* title = new views::Label(l10n_util::GetStringFUTF16( IDS_FR_BUBBLE_TITLE, browser_ ? GetDefaultSearchEngineName(browser_->profile()) : base::string16())); - title->SetFont(original_font.DeriveFont(2, gfx::Font::BOLD)); + title->SetFontList(original_font_list.DeriveFontListWithSizeDeltaAndStyle( + 2, gfx::Font::BOLD)); views::Link* change = new views::Link(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_CHANGE)); - change->SetFont(original_font); + change->SetFontList(original_font_list); change->set_listener(this); views::Label* subtext = new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); - subtext->SetFont(original_font); + subtext->SetFontList(original_font_list); views::GridLayout* layout = views::GridLayout::CreatePanel(this); SetLayoutManager(layout); diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 6b50b78..f3ae9d8 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -37,7 +37,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/font.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/path.h" @@ -134,7 +134,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, } window_title_ = new views::Label(browser_view->GetWindowTitle(), - BrowserFrame::GetTitleFont()); + gfx::FontList(BrowserFrame::GetTitleFont())); window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); window_title_->SetEnabledColor(SK_ColorWHITE); // TODO(msw): Use a transparent background color as a workaround to use the diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc index 8a6f09b..59cfc0b 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc @@ -206,8 +206,7 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { tab_icon_view_->set_id(VIEW_ID_WINDOW_ICON); root_view_->AddChildView(tab_icon_view_); - window_title_ = new views::Label(delegate_->GetWindowTitle(), - default_font_); + window_title_ = new views::Label(delegate_->GetWindowTitle()); window_title_->SetVisible(delegate_->ShouldShowWindowTitle()); window_title_->SetEnabledColor(SK_ColorWHITE); window_title_->SetBackgroundColor(0x00000000); @@ -246,8 +245,6 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { EXPECT_EQ("453,1 43x18", close_button_->bounds().ToString()); } - gfx::Font default_font_; - Widget* widget_; views::View* root_view_; OpaqueBrowserFrameViewLayout* layout_manager_; diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc index b653cfb..231725a 100644 --- a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc +++ b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc @@ -141,14 +141,13 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( SetFocusable(false); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - message_label_ = new views::Label(); - message_label_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + const gfx::FontList& medium_font_list = + rb.GetFontList(ui::ResourceBundle::MediumFont); + message_label_ = new views::Label(base::string16(), medium_font_list); - mouse_lock_exit_instruction_ = new views::Label(); + mouse_lock_exit_instruction_ = + new views::Label(bubble_->GetInstructionText(), medium_font_list); mouse_lock_exit_instruction_->set_collapse_when_hidden(true); - mouse_lock_exit_instruction_->SetText(bubble_->GetInstructionText()); - mouse_lock_exit_instruction_->SetFont( - rb.GetFont(ui::ResourceBundle::MediumFont)); link_ = new views::Link(); link_->set_collapse_when_hidden(true); @@ -158,7 +157,7 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); #endif link_->set_listener(this); - link_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + link_->SetFontList(medium_font_list); link_->SetPressedColor(message_label_->enabled_color()); link_->SetEnabledColor(message_label_->enabled_color()); link_->SetVisible(false); diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc index 1ed157b..dfb3934 100644 --- a/chrome/browser/ui/views/global_error_bubble_view.cc +++ b/chrome/browser/ui/views/global_error_bubble_view.cc @@ -79,7 +79,7 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( scoped_ptr<views::Label> title_label(new views::Label(title_string)); title_label->SetMultiLine(true); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); - title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + title_label->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); std::vector<base::string16> message_strings(error_->GetBubbleViewMessages()); std::vector<views::Label*> message_labels; diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index dab49e7..b404b4c 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -80,8 +80,8 @@ InfoBarView::~InfoBarView() { views::Label* InfoBarView::CreateLabel(const base::string16& text) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - views::Label* label = new views::Label(text, - rb.GetFont(ui::ResourceBundle::MediumFont)); + views::Label* label = new views::Label( + text, rb.GetFontList(ui::ResourceBundle::MediumFont)); label->SizeToPreferredSize(); label->SetBackgroundColor(background()->get_color()); label->SetEnabledColor(SK_ColorBLACK); @@ -92,9 +92,8 @@ views::Label* InfoBarView::CreateLabel(const base::string16& text) const { views::Link* InfoBarView::CreateLink(const base::string16& text, views::LinkListener* listener) const { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - views::Link* link = new views::Link; - link->SetText(text); - link->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + views::Link* link = new views::Link(text); + link->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); link->SizeToPreferredSize(); link->SetHorizontalAlignment(gfx::ALIGN_LEFT); link->set_listener(listener); @@ -127,7 +126,7 @@ views::MenuButton* InfoBarView::CreateMenuButton( rb.GetImageNamed(IDR_INFOBARBUTTON_MENU_DROPARROW).ToImageSkia()); menu_button->SetEnabledColor(SK_ColorBLACK); menu_button->SetHoverColor(SK_ColorBLACK); - menu_button->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + menu_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); menu_button->SizeToPreferredSize(); menu_button->SetFocusable(true); return menu_button; @@ -159,7 +158,7 @@ views::LabelButton* InfoBarView::CreateLabelButton( label_button->SetTextColor(views::Button::STATE_NORMAL, SK_ColorBLACK); label_button->SetTextColor(views::Button::STATE_HOVERED, SK_ColorBLACK); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - label_button->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + label_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); #if defined(OS_WIN) if (needs_elevation && (base::win::GetVersion() >= base::win::VERSION_VISTA) && diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index b02239b..7d85ca0 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -80,6 +80,7 @@ #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/skia_util.h" +#include "ui/gfx/text_utils.h" #include "ui/native_theme/native_theme.h" #include "ui/views/background.h" #include "ui/views/border.h" @@ -906,8 +907,8 @@ void LocationBarView::Layout() { // Layout |ime_inline_autocomplete_view_| next to the user input. if (ime_inline_autocomplete_view_->visible()) { int width = - ime_inline_autocomplete_view_->font().GetStringWidth( - ime_inline_autocomplete_view_->text()) + + gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), + ime_inline_autocomplete_view_->font_list()) + ime_inline_autocomplete_view_->GetInsets().width(); // All the target languages (IMEs) are LTR, and we do not need to support // RTL so far. In other words, no testable RTL environment so far. diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc index 09abe62..39aa3fa 100644 --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc @@ -216,8 +216,9 @@ void ZoomBubbleView::Init() { int zoom_percent = zoom_controller->zoom_percent(); label_ = new views::Label( l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); - label_->SetFont( - ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); + label_->SetFontList( + ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::MediumFont)); AddChildView(label_); views::LabelButton* set_default_button = new views::LabelButton( diff --git a/chrome/browser/ui/views/new_avatar_button.cc b/chrome/browser/ui/views/new_avatar_button.cc index 2804e15..0b7a213 100644 --- a/chrome/browser/ui/views/new_avatar_button.cc +++ b/chrome/browser/ui/views/new_avatar_button.cc @@ -14,6 +14,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/text_elider.h" #include "ui/views/border.h" #include "ui/views/painter.h" @@ -43,8 +44,7 @@ base::string16 GetElidedText(const base::string16& original_text) { // Maximum characters the button can be before the text will get elided. const int kMaxCharactersToDisplay = 15; - gfx::FontList font_list = ui::ResourceBundle::GetSharedInstance().GetFontList( - ui::ResourceBundle::BaseFont); + const gfx::FontList font_list; return gfx::ElideText( original_text, font_list, @@ -64,7 +64,6 @@ NewAvatarButton::NewAvatarButton( set_animate_on_state_change(false); ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); - SetFont(rb->GetFont(ui::ResourceBundle::BaseFont)); bool is_win8 = false; #if defined(OS_WIN) @@ -124,8 +123,7 @@ void NewAvatarButton::OnPaint(gfx::Canvas* canvas) { canvas->DrawStringRectWithHalo( text(), - ui::ResourceBundle::GetSharedInstance().GetFontList( - ui::ResourceBundle::BaseFont), + gfx::FontList(), SK_ColorWHITE, SK_ColorDKGRAY, rect, diff --git a/chrome/browser/ui/views/notifications/balloon_view_views.cc b/chrome/browser/ui/views/notifications/balloon_view_views.cc index 12241c8..61cb591d 100644 --- a/chrome/browser/ui/views/notifications/balloon_view_views.cc +++ b/chrome/browser/ui/views/notifications/balloon_view_views.cc @@ -384,7 +384,7 @@ void BalloonViewImpl::Show(Balloon* balloon) { options_menu_button_->set_border(NULL); options_menu_button_->SetBoundsRect(GetOptionsButtonBounds()); - source_label_->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont)); + source_label_->SetFontList(rb.GetFontList(ui::ResourceBundle::SmallFont)); source_label_->SetBackgroundColor(kControlBarBackgroundColor); source_label_->SetEnabledColor(kControlBarTextColor); source_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/chrome/browser/ui/views/outdated_upgrade_bubble_view.cc b/chrome/browser/ui/views/outdated_upgrade_bubble_view.cc index a2d2346..52aecd3 100644 --- a/chrome/browser/ui/views/outdated_upgrade_bubble_view.cc +++ b/chrome/browser/ui/views/outdated_upgrade_bubble_view.cc @@ -98,7 +98,7 @@ void OutdatedUpgradeBubbleView::Init() { this, l10n_util::GetStringFUTF16(IDS_REINSTALL_APP, product_name)); reinstall_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); reinstall_button_->SetIsDefault(true); - reinstall_button_->SetFont(rb.GetFont(ui::ResourceBundle::BoldFont)); + reinstall_button_->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); later_button_ = new views::LabelButton( this, l10n_util::GetStringUTF16(IDS_LATER)); @@ -106,7 +106,7 @@ void OutdatedUpgradeBubbleView::Init() { views::Label* title_label = new views::Label( l10n_util::GetStringFUTF16(IDS_UPGRADE_BUBBLE_TITLE, product_name)); - title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + title_label->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); views::Label* text_label = new views::Label( diff --git a/chrome/browser/ui/views/panels/panel_frame_view.cc b/chrome/browser/ui/views/panels/panel_frame_view.cc index 9a1ad20..6dda800 100644 --- a/chrome/browser/ui/views/panels/panel_frame_view.cc +++ b/chrome/browser/ui/views/panels/panel_frame_view.cc @@ -16,6 +16,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/path.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/label.h" @@ -43,10 +44,6 @@ const int kNonAeroBorderThickness = 1; // The height and width in pixels of the icon. const int kIconSize = 16; -// The font to use to draw the title. -const char* kTitleFontName = "Arial Bold"; -const int kTitleFontSize = 14; - // The extra padding between the button and the top edge. const int kExtraPaddingBetweenButtonAndTop = 1; @@ -73,7 +70,7 @@ const gfx::ImageSkia& GetTopLeftCornerImage(panel::CornerStyle corner_style) { static gfx::ImageSkia* rounded_image = NULL; static gfx::ImageSkia* non_rounded_image = NULL; if (!rounded_image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); rounded_image = rb.GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER); non_rounded_image = rb.GetImageSkiaNamed(IDR_PANEL_TOP_LEFT_CORNER); } @@ -85,7 +82,7 @@ const gfx::ImageSkia& GetTopRightCornerImage(panel::CornerStyle corner_style) { static gfx::ImageSkia* rounded_image = NULL; static gfx::ImageSkia* non_rounded_image = NULL; if (!rounded_image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); rounded_image = rb.GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER); non_rounded_image = rb.GetImageSkiaNamed(IDR_PANEL_TOP_RIGHT_CORNER); } @@ -98,7 +95,7 @@ const gfx::ImageSkia& GetBottomLeftCornerImage( static gfx::ImageSkia* rounded_image = NULL; static gfx::ImageSkia* non_rounded_image = NULL; if (!rounded_image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); rounded_image = rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); non_rounded_image = rb.GetImageSkiaNamed(IDR_PANEL_BOTTOM_LEFT_CORNER); } @@ -111,7 +108,7 @@ const gfx::ImageSkia& GetBottomRightCornerImage( static gfx::ImageSkia* rounded_image = NULL; static gfx::ImageSkia* non_rounded_image = NULL; if (!rounded_image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); rounded_image = rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER); non_rounded_image = rb.GetImageSkiaNamed(IDR_PANEL_BOTTOM_RIGHT_CORNER); } @@ -122,7 +119,7 @@ const gfx::ImageSkia& GetBottomRightCornerImage( const gfx::ImageSkia& GetTopEdgeImage() { static gfx::ImageSkia* image = NULL; if (!image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); image = rb.GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER); } return *image; @@ -131,7 +128,7 @@ const gfx::ImageSkia& GetTopEdgeImage() { const gfx::ImageSkia& GetBottomEdgeImage() { static gfx::ImageSkia* image = NULL; if (!image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); image = rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER); } return *image; @@ -140,7 +137,7 @@ const gfx::ImageSkia& GetBottomEdgeImage() { const gfx::ImageSkia& GetLeftEdgeImage() { static gfx::ImageSkia* image = NULL; if (!image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); image = rb.GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE); } return *image; @@ -149,20 +146,13 @@ const gfx::ImageSkia& GetLeftEdgeImage() { const gfx::ImageSkia& GetRightEdgeImage() { static gfx::ImageSkia* image = NULL; if (!image) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); image = rb.GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE); } return *image; } #endif // defined(OS_WIN) -const gfx::Font& GetTitleFont() { - static gfx::Font* font = NULL; - if (!font) - font = new gfx::Font(kTitleFontName, kTitleFontSize); - return *font; -} - const gfx::ImageSkia* GetActiveBackgroundDefaultImage() { static gfx::ImageSkia* image = NULL; if (!image) @@ -266,7 +256,7 @@ PanelFrameView::~PanelFrameView() { } void PanelFrameView::Init() { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_ = new views::ImageButton(this); close_button_->SetImage(views::CustomButton::STATE_NORMAL, @@ -314,10 +304,11 @@ void PanelFrameView::Init() { AddChildView(title_icon_); title_icon_->Update(); - title_label_ = new views::Label(panel_view_->panel()->GetWindowTitle()); + title_label_ = new views::Label( + panel_view_->panel()->GetWindowTitle(), + rb.GetFontList(ui::ResourceBundle::BoldFont)); title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); title_label_->SetAutoColorReadabilityEnabled(false); - title_label_->SetFont(GetTitleFont()); AddChildView(title_label_); #if defined(USE_AURA) @@ -555,7 +546,7 @@ void PanelFrameView::Layout() { // Layout the title. int title_x = title_icon_->bounds().right() + panel::kIconAndTitlePadding; - int title_height = GetTitleFont().GetHeight(); + int title_height = title_label_->font_list().GetHeight(); title_label_->SetBounds( title_x, icon_y + ((kIconSize - title_height - 1) / 2), diff --git a/chrome/browser/ui/views/password_generation_bubble_view.cc b/chrome/browser/ui/views/password_generation_bubble_view.cc index c3114f3..7aa8e27 100644 --- a/chrome/browser/ui/views/password_generation_bubble_view.cc +++ b/chrome/browser/ui/views/password_generation_bubble_view.cc @@ -152,7 +152,7 @@ void PasswordGenerationBubbleView::Init() { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); title_label_ = new views::Label( l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_BUBBLE_TITLE), - rb.GetFont(ui::ResourceBundle::MediumFont)); + rb.GetFontList(ui::ResourceBundle::MediumFont)); AddChildView(title_label_); regenerate_button_ = new views::ImageButton(this); diff --git a/chrome/browser/ui/views/profile_chooser_view.cc b/chrome/browser/ui/views/profile_chooser_view.cc index aa99a52..03a5fd3f 100644 --- a/chrome/browser/ui/views/profile_chooser_view.cc +++ b/chrome/browser/ui/views/profile_chooser_view.cc @@ -236,8 +236,9 @@ class EditableProfileName : public views::TextButton, : views::TextButton(this, text), profile_name_textfield_(NULL) { ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); - gfx::Font medium_font = rb->GetFont(ui::ResourceBundle::MediumFont); - SetFont(medium_font); + const gfx::FontList& medium_font_list = + rb->GetFontList(ui::ResourceBundle::MediumFont); + SetFontList(medium_font_list); set_border(NULL); if (!is_editing_allowed) @@ -249,7 +250,7 @@ class EditableProfileName : public views::TextButton, // Textfield that overlaps the button. profile_name_textfield_ = new views::Textfield(); profile_name_textfield_->SetController(controller); - profile_name_textfield_->SetFont(medium_font); + profile_name_textfield_->SetFontList(medium_font_list); profile_name_textfield_->SetVisible(false); AddChildView(profile_name_textfield_); } @@ -715,7 +716,7 @@ views::View* ProfileChooserView::CreateOtherProfilesView( open_other_profile_indexes_map_[button] = index; button->SetIcon(*image.ToImageSkia()); button->set_icon_text_spacing(views::kItemLabelSpacing); - button->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( + button->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( ui::ResourceBundle::MediumFont)); button->set_border(NULL); @@ -832,7 +833,6 @@ void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, width()), is_primary_account ? NULL : this, // Cannot delete the primary account. !is_primary_account); - email_button->SetFont(rb->GetFont(ui::ResourceBundle::BaseFont)); email_button->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 0)); if (!is_primary_account) { email_button->set_menu_marker( diff --git a/chrome/browser/ui/views/profile_reset_bubble_view.cc b/chrome/browser/ui/views/profile_reset_bubble_view.cc index 29bb842..ccb23c3 100644 --- a/chrome/browser/ui/views/profile_reset_bubble_view.cc +++ b/chrome/browser/ui/views/profile_reset_bubble_view.cc @@ -208,9 +208,9 @@ void ProfileResetBubbleView::SetupLayoutManager(bool report_checked) { // Bubble title label. views::Label* title_label = new views::Label( - l10n_util::GetStringFUTF16(IDS_RESET_BUBBLE_TITLE, product_name)); + l10n_util::GetStringFUTF16(IDS_RESET_BUBBLE_TITLE, product_name), + rb.GetFontList(ui::ResourceBundle::BoldFont)); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); - title_label->SetFont(rb.GetFont(ui::ResourceBundle::BoldFont)); // Description text label. views::Label* text_label = new views::Label( @@ -235,7 +235,8 @@ void ProfileResetBubbleView::SetupLayoutManager(bool report_checked) { this, l10n_util::GetStringUTF16(reset_button_string_id)); controls_.reset_button->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); controls_.reset_button->SetIsDefault(true); - controls_.reset_button->SetFont(rb.GetFont(ui::ResourceBundle::BoldFont)); + controls_.reset_button->SetFontList( + rb.GetFontList(ui::ResourceBundle::BoldFont)); controls_.reset_button->SetEnabled(!resetting_); // For the Resetting... text to fit. gfx::Size reset_button_size = controls_.reset_button->GetPreferredSize(); diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index 68889ec..5bee30f 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -107,7 +107,7 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind) (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - title->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + title->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); layout->StartRowWithPadding(0, column_set_id, 0, kPadding); layout->AddView(title); diff --git a/chrome/browser/ui/views/speech_recognition_bubble_views.cc b/chrome/browser/ui/views/speech_recognition_bubble_views.cc index 0e4a0eb..6bcdf29 100644 --- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc +++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc @@ -131,21 +131,18 @@ gfx::Rect SpeechRecognitionBubbleView::GetAnchorRect() { } void SpeechRecognitionBubbleView::Init() { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + const gfx::FontList& font_list = + rb.GetFontList(ui::ResourceBundle::MediumFont); heading_ = new views::Label( - l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); + l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING), font_list); heading_->set_border(views::Border::CreateEmptyBorder( kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); - heading_->SetFont(font); heading_->SetHorizontalAlignment(gfx::ALIGN_CENTER); - heading_->SetText( - l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); AddChildView(heading_); - message_ = new views::Label(); - message_->SetFont(font); + message_ = new views::Label(base::string16(), font_list); message_->SetMultiLine(true); AddChildView(message_); diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index c7e4e9d..6e4a1d0 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -12,21 +12,21 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/themes/theme_properties.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" #include "net/base/net_util.h" #include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkRect.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/linear_animation.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/point.h" +#include "ui/gfx/rect.h" #include "ui/gfx/screen.h" #include "ui/gfx/skia_util.h" #include "ui/gfx/text_elider.h" +#include "ui/gfx/text_utils.h" #include "ui/native_theme/native_theme.h" #include "ui/views/controls/scrollbar/native_scroll_bar.h" #include "ui/views/widget/root_view.h" @@ -102,8 +102,6 @@ class StatusBubbleViews::StatusView : public views::View, ui::ThemeProvider* theme_provider); virtual ~StatusView(); - static const gfx::FontList& GetDefaultFontList(); - // Set the bubble text to a certain value, hides the bubble if text is // an empty string. Trigger animation sequence to display if // |should_animate_open|. @@ -193,12 +191,6 @@ StatusBubbleViews::StatusView::~StatusView() { CancelTimer(); } -// static -const gfx::FontList& StatusBubbleViews::StatusView::GetDefaultFontList() { - return ResourceBundle::GetSharedInstance().GetFontList( - ResourceBundle::BaseFont); -} - void StatusBubbleViews::StatusView::SetText(const base::string16& text, bool should_animate_open) { if (text.empty()) { @@ -449,9 +441,9 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { // Draw highlight text and then the text body. In order to make sure the text // is aligned to the right on RTL UIs, we mirror the text bounds if the // locale is RTL. - const gfx::FontList& font_list(GetDefaultFontList()); + const gfx::FontList font_list; int text_width = std::min( - font_list.GetStringWidth(text_), + gfx::GetStringWidth(text_, font_list), width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); int text_height = height - (kShadowThickness * 2); gfx::Rect body_bounds(kShadowThickness + kTextPositionX, @@ -608,8 +600,7 @@ void StatusBubbleViews::Reposition() { } gfx::Size StatusBubbleViews::GetPreferredSize() { - return gfx::Size(0, ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont).GetHeight() + kTotalVerticalPadding); + return gfx::Size(0, gfx::FontList().GetHeight() + kTotalVerticalPadding); } void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { @@ -670,8 +661,7 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::string& languages) { gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); int text_width = static_cast<int>(popup_bounds.width() - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); - url_text_ = - gfx::ElideUrl(url, view_->GetDefaultFontList(), text_width, languages); + url_text_ = gfx::ElideUrl(url, gfx::FontList(), text_width, languages); // An URL is always treated as a left-to-right string. On right-to-left UIs // we need to explicitly mark the URL as LTR to make sure it is displayed @@ -828,14 +818,15 @@ void StatusBubbleViews::ExpandBubble() { // still be too long to fit) before expanding bubble. gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); int max_status_bubble_width = GetMaxStatusBubbleWidth(); - url_text_ = gfx::ElideUrl(url_, view_->GetDefaultFontList(), + const gfx::FontList font_list; + url_text_ = gfx::ElideUrl(url_, font_list, max_status_bubble_width, languages_); int expanded_bubble_width = std::max(GetStandardStatusBubbleWidth(), - std::min(view_->GetDefaultFontList().GetStringWidth(url_text_) + + std::min(gfx::GetStringWidth(url_text_, font_list) + (kShadowThickness * 2) + kTextPositionX + kTextHorizPadding + 1, - max_status_bubble_width)); + max_status_bubble_width)); is_expanded_ = true; expand_view_->StartExpansion(url_text_, popup_bounds.width(), expanded_bubble_width); diff --git a/chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc b/chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc index 6c2a1cc..499f52a 100644 --- a/chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc +++ b/chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc @@ -208,9 +208,9 @@ void OneClickSigninBubbleView::InitDialogContent(views::GridLayout* layout) { layout->StartRow(0, COLUMN_SET_TITLE_BAR); views::Label* label = new views::Label( - l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE_NEW)); + l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE_NEW), + rb.GetFontList(ui::ResourceBundle::MediumBoldFont)); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); - label->SetFont(label->font().DeriveFont(3, gfx::Font::BOLD)); layout->AddView(label); close_button_ = new views::ImageButton(this); diff --git a/chrome/browser/ui/views/toolbar/site_chip_view.cc b/chrome/browser/ui/views/toolbar/site_chip_view.cc index bceb9d3..918efae 100644 --- a/chrome/browser/ui/views/toolbar/site_chip_view.cc +++ b/chrome/browser/ui/views/toolbar/site_chip_view.cc @@ -291,7 +291,7 @@ void SiteChipView::Init() { host_label_ = new views::Label(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - host_label_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + host_label_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); AddChildView(location_icon_view_); AddChildView(host_label_); @@ -511,4 +511,3 @@ void SiteChipView::OnSafeBrowsingMatch( const SafeBrowsingUIManager::UnsafeResource& resource) { OnChanged(); } - diff --git a/chrome/browser/ui/views/toolbar/wrench_menu.cc b/chrome/browser/ui/views/toolbar/wrench_menu.cc index a82b5f2..3bac99e 100644 --- a/chrome/browser/ui/views/toolbar/wrench_menu.cc +++ b/chrome/browser/ui/views/toolbar/wrench_menu.cc @@ -39,6 +39,7 @@ #include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia_source.h" #include "ui/gfx/skia_util.h" @@ -405,7 +406,7 @@ class WrenchMenuView : public views::View, button->set_border( new MenuButtonBorder(menu_config, menu_->use_new_menu())); button->SetHorizontalAlignment(gfx::ALIGN_CENTER); - button->SetFont(menu_config.font); + button->SetFontList(gfx::FontList(menu_config.font)); ui::NativeTheme* native_theme = button->GetNativeTheme(); button->SetTextColor( views::Button::STATE_DISABLED, @@ -626,7 +627,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView { const MenuConfig& menu_config(menu->GetMenuConfig()); zoom_label_->set_border( new MenuButtonBorder(menu_config, menu->use_new_menu())); - zoom_label_->SetFont(menu_config.font); + zoom_label_->SetFontList(gfx::FontList(menu_config.font)); AddChildView(zoom_label_); zoom_label_width_ = MaxWidthForZoomLabel(); @@ -766,7 +767,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView { // Calculates the max width the zoom string can be. int MaxWidthForZoomLabel() { - gfx::Font font = zoom_label_->font(); + const gfx::FontList& font_list = zoom_label_->font_list(); int border_width = zoom_label_->border() ? zoom_label_->border()->GetInsets().width() : 0; @@ -780,13 +781,13 @@ class WrenchMenu::ZoomView : public WrenchMenuView { int step = (max_percent - min_percent) / 10; for (int i = min_percent; i <= max_percent; i += step) { - int w = font.GetStringWidth( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i)); + int w = gfx::GetStringWidth( + l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, i), font_list); max_w = std::max(w, max_w); } } else { - max_w = font.GetStringWidth( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100)); + max_w = gfx::GetStringWidth( + l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100), font_list); } return max_w + border_width; diff --git a/chrome/browser/ui/views/validation_message_bubble_delegate.cc b/chrome/browser/ui/views/validation_message_bubble_delegate.cc index 8a4cdbd..bee71d5 100644 --- a/chrome/browser/ui/views/validation_message_bubble_delegate.cc +++ b/chrome/browser/ui/views/validation_message_bubble_delegate.cc @@ -28,16 +28,16 @@ ValidationMessageBubbleDelegate::ValidationMessageBubbleDelegate( set_arrow(views::BubbleBorder::TOP_LEFT); SetAnchorRect(anchor_in_screen); - ResourceBundle& bundle = ResourceBundle::GetSharedInstance(); + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); views::ImageView* icon = new views::ImageView(); icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); gfx::Size size = icon->GetPreferredSize(); icon->SetBounds(kPadding, kPadding, size.width(), size.height()); AddChildView(icon); - views::Label* label = new views::Label(main_text); + views::Label* label = new views::Label( + main_text, bundle.GetFontList(ui::ResourceBundle::MediumFont)); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); - label->SetFont(bundle.GetFont(ResourceBundle::MediumFont)); label->set_directionality_mode(views::Label::AUTO_DETECT_DIRECTIONALITY); int text_start_x = kPadding + size.width() + kIconTextMargin; int min_available = kWindowMinWidth - text_start_x - kPadding; diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc index 6aba873..9cd17b4 100644 --- a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc +++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc @@ -29,7 +29,7 @@ #include "ui/base/models/simple_menu_model.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/font.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/image/image.h" #include "ui/gfx/insets.h" #include "ui/views/controls/button/image_button.h" @@ -57,8 +57,6 @@ const int kConnectionSectionPaddingLeft = 18; const int kConnectionSectionPaddingTop = 16; const int kConnectionSectionPaddingRight = 18; -// Font size of the label for the site identity. -const int kIdentityNameFontSize = 14; // The text color that is used for the site identity status text, if the site's // identity was sucessfully verified. const int kIdentityVerifiedTextColor = 0xFF298a27; @@ -175,14 +173,13 @@ PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) layout->AddPaddingRow(0, kHeaderPaddingTop); layout->StartRow(0, label_column); - name_ = new views::Label(base::string16()); - gfx::Font headline_font(name_->font().GetFontName(), kIdentityNameFontSize); - name_->SetFont(headline_font.DeriveFont(0, gfx::Font::BOLD)); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + name_ = new views::Label( + base::string16(), rb.GetFontList(ui::ResourceBundle::BoldFont)); layout->AddView(name_, 1, 1, views::GridLayout::LEADING, views::GridLayout::TRAILING); views::ImageButton* close_button = new views::ImageButton(close_button_listener); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button->SetImage(views::CustomButton::STATE_NORMAL, rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia()); close_button->SetImage(views::CustomButton::STATE_HOVERED, @@ -651,8 +648,9 @@ views::View* WebsiteSettingsPopupView::CreateSection( layout->AddPaddingRow(1, kPermissionsSectionPaddingTop); layout->StartRow(1, content_column); - views::Label* headline = new views::Label(headline_text); - headline->SetFont(headline->font().DeriveFont(0, gfx::Font::BOLD)); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + views::Label* headline = new views::Label( + headline_text, rb.GetFontList(ui::ResourceBundle::BoldFont)); layout->AddView(headline, 1, 1, views::GridLayout::LEADING, views::GridLayout::CENTER); @@ -721,9 +719,9 @@ void WebsiteSettingsPopupView::ResetConnectionSection( 0, 0); if (!headline.empty()) { - views::Label* headline_label = new views::Label(headline); - headline_label->SetFont( - headline_label->font().DeriveFont(0, gfx::Font::BOLD)); + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + views::Label* headline_label = new views::Label( + headline, rb.GetFontList(ui::ResourceBundle::BoldFont)); headline_label->SetMultiLine(true); headline_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); // Allow linebreaking in the middle of words if necessary, so that extremely |