[go: nahoru, domu]

Clean up a couple APIs.

It makes little sense for GetFontListWithDelta() to also take non-delta
values.  It will also be convenient for a future CL for callers to be
able to use a struct that represents "the meaningful data about a font".
For both these reasons, replace the private FontKey struct with a public
FontDetails struct that bundles these details, and update callers to use
it as appropriate.

Also, replace seemingly-unnecessary usage of Font with FontList in
l10n_font_util.h (and remove dead method there).  This allows removing
another ResourceBundle method.

Bug: none
Change-Id: Ie6b35e7015fe8bdf704fc4111c0e6ca4de522308
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611841
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840663}
diff --git a/ash/display/touch_calibrator_view.cc b/ash/display/touch_calibrator_view.cc
index 2484878..a47c451 100644
--- a/ash/display/touch_calibrator_view.cc
+++ b/ash/display/touch_calibrator_view.cc
@@ -358,8 +358,7 @@
 
   label_font_list_ =
       ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-          kHintBoxLabelTextSize, gfx::Font::FontStyle::NORMAL,
-          gfx::Font::Weight::NORMAL);
+          kHintBoxLabelTextSize);
 
   // Adjust size of label bounds based on text and font.
   gfx::Size size = GetSizeForString(label_text_, label_font_list_);
@@ -379,8 +378,7 @@
 
   sublabel_font_list_ =
       ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-          kHintBoxSublabelTextSize, gfx::Font::FontStyle::NORMAL,
-          gfx::Font::Weight::NORMAL);
+          kHintBoxSublabelTextSize);
 
   // Adjust size of sublabel label bounds based on text and font.
   gfx::Size size = GetSizeForString(sublabel_text_, sublabel_font_list_);
@@ -434,8 +432,7 @@
   text_bounds_.SetRect(x_offset, 0, width() - x_offset, height());
 
   font_list_ = ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-      kCompleteMessageTextSize, gfx::Font::FontStyle::NORMAL,
-      gfx::Font::Weight::NORMAL);
+      kCompleteMessageTextSize);
 
   // crbug/676513 moves this file to src/ash which will require an ash icon
   // file.
@@ -499,8 +496,7 @@
   // calibration setup.
   exit_label_ = AddChildView(std::make_unique<views::Label>(
       rb.GetLocalizedString(IDS_DISPLAY_TOUCH_CALIBRATION_EXIT_LABEL),
-      views::Label::CustomFont{rb.GetFontListWithDelta(
-          8, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::NORMAL)}));
+      views::Label::CustomFont{rb.GetFontListWithDelta(8)}));
   exit_label_->SetBounds((display_.bounds().width() - kExitLabelWidth) / 2,
                          display_.bounds().height() * 3.f / 4, kExitLabelWidth,
                          kExitLabelHeight);
@@ -541,8 +537,7 @@
   // Initialize the tap label.
   tap_label_ = touch_point_view_->AddChildView(std::make_unique<views::Label>(
       rb.GetLocalizedString(IDS_DISPLAY_TOUCH_CALIBRATION_TAP_HERE_LABEL),
-      views::Label::CustomFont{rb.GetFontListWithDelta(
-          6, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::NORMAL)}));
+      views::Label::CustomFont{rb.GetFontListWithDelta(6)}));
   tap_label_->SetBounds(0, kThrobberCircleViewWidth, kTapLabelWidth,
                         kTapLabelHeight);
   tap_label_->SetEnabledColor(kTapHereLabelColor);
diff --git a/ash/shortcut_viewer/views/bubble_view.cc b/ash/shortcut_viewer/views/bubble_view.cc
index dedaba9..392687f9b 100644
--- a/ash/shortcut_viewer/views/bubble_view.cc
+++ b/ash/shortcut_viewer/views/bubble_view.cc
@@ -74,8 +74,9 @@
     text_->SetElideBehavior(gfx::NO_ELIDE);
     constexpr int kLabelFontSizeDelta = 1;
     text_->SetFontList(
-        ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-            kLabelFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM));
+        ui::ResourceBundle::GetSharedInstance().GetFontListForDetails(
+            ui::ResourceBundle::FontDetails(std::string(), kLabelFontSizeDelta,
+                                            gfx::Font::Weight::MEDIUM)));
   }
   text_->SetText(text);
 }
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc
index 1952ed5..7150983 100644
--- a/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc
+++ b/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc
@@ -75,8 +75,9 @@
   category_label->SetEnabledColor(kLabelColor);
   constexpr int kLabelFontSizeDelta = 1;
   category_label->SetFontList(
-      ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-          kLabelFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::BOLD));
+      ui::ResourceBundle::GetSharedInstance().GetFontListForDetails(
+          ui::ResourceBundle::FontDetails(std::string(), kLabelFontSizeDelta,
+                                          gfx::Font::Weight::BOLD)));
   AddChildView(std::move(category_label));
 }
 
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc
index e2f8319..d29fbf2 100644
--- a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc
+++ b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc
@@ -92,8 +92,7 @@
   text->SetEnabledColor(kSearchIllustrationTextColor);
   constexpr int kLabelFontSizeDelta = 1;
   ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
-  text->SetFontList(rb.GetFontListWithDelta(
-      kLabelFontSizeDelta, gfx::Font::NORMAL, gfx::Font::Weight::NORMAL));
+  text->SetFontList(rb.GetFontListWithDelta(kLabelFontSizeDelta));
   illustration_view->AddChildView(std::move(text));
   return illustration_view;
 }
diff --git a/chrome/browser/ui/views/chrome_typography_provider.cc b/chrome/browser/ui/views/chrome_typography_provider.cc
index b84a69c..901615f 100644
--- a/chrome/browser/ui/views/chrome_typography_provider.cc
+++ b/chrome/browser/ui/views/chrome_typography_provider.cc
@@ -111,9 +111,8 @@
 #endif
   }
 
-  return ui::ResourceBundle::GetSharedInstance()
-      .GetFontListWithTypefaceAndDelta(typeface, size_delta, gfx::Font::NORMAL,
-                                       font_weight);
+  return ui::ResourceBundle::GetSharedInstance().GetFontListForDetails(
+      ui::ResourceBundle::FontDetails(typeface, size_delta, font_weight));
 }
 
 SkColor ChromeTypographyProvider::GetColor(const views::View& view,
diff --git a/chrome/browser/ui/views/layout_provider_unittest.cc b/chrome/browser/ui/views/layout_provider_unittest.cc
index a22b4dac..d2323c0a 100644
--- a/chrome/browser/ui/views/layout_provider_unittest.cc
+++ b/chrome/browser/ui/views/layout_provider_unittest.cc
@@ -222,8 +222,9 @@
   gfx::FontList title_font = rb.GetFontListWithDelta(kTitle - kBase);
   gfx::FontList body1_font = rb.GetFontListWithDelta(kBody1 - kBase);
   gfx::FontList body2_font = rb.GetFontListWithDelta(kBody2 - kBase);
-  gfx::FontList button_font = rb.GetFontListWithDelta(
-      kButton - kBase, gfx::Font::NORMAL, kButtonWeight);
+  gfx::FontList button_font =
+      rb.GetFontListForDetails(ui::ResourceBundle::FontDetails(
+          std::string(), kButton - kBase, kButtonWeight));
 
   // The following checks on leading don't need to match the spec. Instead, it
   // means Label::SetLineHeight() needs to be used to increase it. But what we
diff --git a/chrome/browser/ui/views/omnibox/omnibox_text_view.cc b/chrome/browser/ui/views/omnibox/omnibox_text_view.cc
index 5cfa4c3..b0c33131 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_text_view.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_text_view.cc
@@ -301,11 +301,12 @@
 
 void OmniboxTextView::OnStyleChanged() {
   const int height_normal = render_text_->font_list().GetHeight();
+  const int size_delta =
+      render_text_->font_list().GetFontSize() - gfx::FontList().GetFontSize();
   const int height_bold =
       ui::ResourceBundle::GetSharedInstance()
-          .GetFontListWithDelta(render_text_->font_list().GetFontSize() -
-                                    gfx::FontList().GetFontSize(),
-                                gfx::Font::NORMAL, gfx::Font::Weight::BOLD)
+          .GetFontListForDetails(ui::ResourceBundle::FontDetails(
+              std::string(), size_delta, gfx::Font::Weight::BOLD))
           .GetHeight();
   font_height_ = std::max(height_normal, height_bold);
   font_height_ += kVerticalPadding;
diff --git a/chrome/browser/ui/views/payments/payment_request_views_util.cc b/chrome/browser/ui/views/payments/payment_request_views_util.cc
index 1f9874e..11f6b6f 100644
--- a/chrome/browser/ui/views/payments/payment_request_views_util.cc
+++ b/chrome/browser/ui/views/payments/payment_request_views_util.cc
@@ -365,9 +365,10 @@
   // since asking for a MEDIUM font will give a lighter font.
   std::unique_ptr<views::Label> label = std::make_unique<views::Label>(text);
   label->SetFontList(
-      ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-          ui::kLabelFontSizeDelta, gfx::Font::NORMAL,
-          gfx::Font::Weight::MEDIUM));
+      ui::ResourceBundle::GetSharedInstance().GetFontListForDetails(
+          ui::ResourceBundle::FontDetails(std::string(),
+                                          ui::kLabelFontSizeDelta,
+                                          gfx::Font::Weight::MEDIUM)));
   return label;
 }
 
diff --git a/ui/base/cocoa/menu_controller_unittest.mm b/ui/base/cocoa/menu_controller_unittest.mm
index 4d317fc..549e3ab 100644
--- a/ui/base/cocoa/menu_controller_unittest.mm
+++ b/ui/base/cocoa/menu_controller_unittest.mm
@@ -517,8 +517,9 @@
 TEST_F(MenuControllerTest, LabelFontList) {
   Delegate delegate;
   const gfx::FontList& bold =
-      ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-          0, gfx::Font::NORMAL, gfx::Font::Weight::BOLD);
+      ResourceBundle::GetSharedInstance().GetFontListForDetails(
+          ui::ResourceBundle::FontDetails(std::string(), 0,
+                                          gfx::Font::Weight::BOLD));
   FontListMenuModel model(&delegate, &bold, 0);
   model.AddItem(1, ASCIIToUTF16("one"));
   model.AddItem(2, ASCIIToUTF16("two"));
diff --git a/ui/base/l10n/l10n_font_util.cc b/ui/base/l10n/l10n_font_util.cc
index fa6f7d9..7165d277 100644
--- a/ui/base/l10n/l10n_font_util.cc
+++ b/ui/base/l10n/l10n_font_util.cc
@@ -7,33 +7,26 @@
 #include "base/check_op.h"
 #include "base/strings/string_number_conversions.h"
 #include "ui/base/l10n/l10n_util.h"
-#include "ui/gfx/font.h"
+#include "ui/gfx/font_list.h"
 
 namespace ui {
 
-int GetLocalizedContentsWidthForFont(int col_resource_id,
-                                     const gfx::Font& font) {
+int GetLocalizedContentsWidthForFontList(int col_resource_id,
+                                         const gfx::FontList& font_list) {
   int chars = 0;
   base::StringToInt(l10n_util::GetStringUTF8(col_resource_id), &chars);
-  int width = font.GetExpectedTextWidth(chars);
+  int width = font_list.GetExpectedTextWidth(chars);
   DCHECK_GT(width, 0);
   return width;
 }
 
-int GetLocalizedContentsHeightForFont(int row_resource_id,
-                                      const gfx::Font& font) {
+int GetLocalizedContentsHeightForFontList(int row_resource_id,
+                                          const gfx::FontList& font_list) {
   int lines = 0;
   base::StringToInt(l10n_util::GetStringUTF8(row_resource_id), &lines);
-  int height = font.GetHeight() * lines;
+  int height = font_list.GetHeight() * lines;
   DCHECK_GT(height, 0);
   return height;
 }
 
-gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id,
-                                          int row_resource_id,
-                                          const gfx::Font& font) {
-  return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font),
-                   GetLocalizedContentsHeightForFont(row_resource_id, font));
-}
-
 }  // namespace ui
diff --git a/ui/base/l10n/l10n_font_util.h b/ui/base/l10n/l10n_font_util.h
index 81dffd3..979be47 100644
--- a/ui/base/l10n/l10n_font_util.h
+++ b/ui/base/l10n/l10n_font_util.h
@@ -9,7 +9,7 @@
 #include "ui/gfx/geometry/size.h"
 
 namespace gfx {
-class Font;
+class FontList;
 }
 
 namespace ui {
@@ -19,15 +19,11 @@
 // localized string resource identified by |col_resource_id|, the height in the
 // same fashion.
 COMPONENT_EXPORT(UI_BASE)
-int GetLocalizedContentsWidthForFont(int col_resource_id,
-                                     const gfx::Font& font);
+int GetLocalizedContentsWidthForFontList(int col_resource_id,
+                                         const gfx::FontList& font_list);
 COMPONENT_EXPORT(UI_BASE)
-int GetLocalizedContentsHeightForFont(int row_resource_id,
-                                      const gfx::Font& font);
-COMPONENT_EXPORT(UI_BASE)
-gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id,
-                                          int row_resource_id,
-                                          const gfx::Font& font);
+int GetLocalizedContentsHeightForFontList(int row_resource_id,
+                                          const gfx::FontList& font_list);
 
 }  // namespace ui
 
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 5d1df31..9f74540 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -224,33 +224,20 @@
   DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageSource);
 };
 
-struct ResourceBundle::FontKey {
-  FontKey(const std::string& typeface,
-          int in_size_delta,
-          gfx::Font::FontStyle in_style,
-          gfx::Font::Weight in_weight)
-      : typeface(typeface),
-        size_delta(in_size_delta),
-        style(in_style),
-        weight(in_weight) {}
+ResourceBundle::FontDetails::FontDetails(std::string typeface,
+                                         int size_delta,
+                                         gfx::Font::Weight weight)
+    : typeface(typeface), size_delta(size_delta), weight(weight) {}
 
-  ~FontKey() {}
+bool ResourceBundle::FontDetails::operator==(const FontDetails& rhs) const {
+  return std::tie(typeface, size_delta, weight) ==
+         std::tie(rhs.typeface, rhs.size_delta, rhs.weight);
+}
 
-  bool operator==(const FontKey& rhs) const {
-    return std::tie(typeface, size_delta, style, weight) ==
-           std::tie(rhs.typeface, rhs.size_delta, rhs.style, rhs.weight);
-  }
-
-  bool operator<(const FontKey& rhs) const {
-    return std::tie(typeface, size_delta, style, weight) <
-           std::tie(rhs.typeface, rhs.size_delta, rhs.style, rhs.weight);
-  }
-
-  std::string typeface;
-  int size_delta;
-  gfx::Font::FontStyle style;
-  gfx::Font::Weight weight;
-};
+bool ResourceBundle::FontDetails::operator<(const FontDetails& rhs) const {
+  return std::tie(typeface, size_delta, weight) <
+         std::tie(rhs.typeface, rhs.size_delta, rhs.weight);
+}
 
 // static
 std::string ResourceBundle::InitSharedInstanceWithLocale(
@@ -751,74 +738,56 @@
   return LoadDataResourceBytes(resource_id);
 }
 
-const gfx::FontList& ResourceBundle::GetFontListWithDelta(
-    int size_delta,
-    gfx::Font::FontStyle style,
-    gfx::Font::Weight weight) {
-  return GetFontListWithTypefaceAndDelta(/*typeface=*/std::string(), size_delta,
-                                         style, weight);
+const gfx::FontList& ResourceBundle::GetFontListWithDelta(int size_delta) {
+  return GetFontListForDetails(FontDetails(std::string(), size_delta));
 }
 
-const gfx::FontList& ResourceBundle::GetFontListWithTypefaceAndDelta(
-    const std::string& typeface,
-    int size_delta,
-    gfx::Font::FontStyle style,
-    gfx::Font::Weight weight) {
+const gfx::FontList& ResourceBundle::GetFontListForDetails(
+    const FontDetails& details) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
 
-  const FontKey styled_key(typeface, size_delta, style, weight);
-
-  auto found = font_cache_.find(styled_key);
+  auto found = font_cache_.find(details);
   if (found != font_cache_.end())
     return found->second;
 
-  const FontKey base_key(typeface, 0, gfx::Font::NORMAL,
-                         gfx::Font::Weight::NORMAL);
+  const FontDetails base_details(details.typeface);
   gfx::FontList default_font_list = gfx::FontList();
   gfx::FontList base_font_list =
-      typeface.empty()
+      details.typeface.empty()
           ? default_font_list
-          : gfx::FontList({typeface}, default_font_list.GetFontStyle(),
+          : gfx::FontList({details.typeface}, default_font_list.GetFontStyle(),
                           default_font_list.GetFontSize(),
                           default_font_list.GetFontWeight());
-  font_cache_.emplace(base_key, base_font_list);
-  gfx::FontList& base = font_cache_.find(base_key)->second;
-  if (styled_key == base_key)
+  font_cache_.emplace(base_details, base_font_list);
+  gfx::FontList& base = font_cache_.find(base_details)->second;
+  if (details == base_details)
     return base;
 
   // Fonts of a given style are derived from the unstyled font of the same size.
   // Cache the unstyled font by first inserting a default-constructed font list.
   // Then, derive it for the initial insertion, or use the iterator that points
   // to the existing entry that the insertion collided with.
-  const FontKey sized_key(typeface, size_delta, gfx::Font::NORMAL,
-                          gfx::Font::Weight::NORMAL);
-  auto sized = font_cache_.emplace(sized_key, base_font_list);
+  const FontDetails sized_details(details.typeface, details.size_delta);
+  auto sized = font_cache_.emplace(sized_details, base_font_list);
   if (sized.second)
-    sized.first->second = base.DeriveWithSizeDelta(size_delta);
-  if (styled_key == sized_key) {
+    sized.first->second = base.DeriveWithSizeDelta(details.size_delta);
+  if (details == sized_details) {
     return sized.first->second;
   }
 
-  auto styled = font_cache_.emplace(styled_key, base_font_list);
+  auto styled = font_cache_.emplace(details, base_font_list);
   DCHECK(styled.second);  // Otherwise font_cache_.find(..) would have found it.
   styled.first->second = sized.first->second.Derive(
-      0, sized.first->second.GetFontStyle() | style, weight);
+      0, sized.first->second.GetFontStyle(), details.weight);
 
   return styled.first->second;
 }
 
-const gfx::Font& ResourceBundle::GetFontWithDelta(int size_delta,
-                                                  gfx::Font::FontStyle style,
-                                                  gfx::Font::Weight weight) {
-  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  return GetFontListWithDelta(size_delta, style, weight).GetPrimaryFont();
-}
-
 const gfx::FontList& ResourceBundle::GetFontList(FontStyle legacy_style) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL;
+  gfx::Font::Weight weight = gfx::Font::Weight::NORMAL;
   if (legacy_style == BoldFont || legacy_style == MediumBoldFont)
-    font_weight = gfx::Font::Weight::BOLD;
+    weight = gfx::Font::Weight::BOLD;
 
   int size_delta = 0;
   switch (legacy_style) {
@@ -837,7 +806,7 @@
       break;
   }
 
-  return GetFontListWithDelta(size_delta, gfx::Font::NORMAL, font_weight);
+  return GetFontListForDetails(FontDetails(std::string(), size_delta, weight));
 }
 
 const gfx::Font& ResourceBundle::GetFont(FontStyle style) {
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index 51dbdfa..0432b8f 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -67,6 +67,26 @@
     LargeFont,
   };
 
+  struct COMPONENT_EXPORT(UI_BASE) FontDetails {
+    explicit FontDetails(std::string typeface = std::string(),
+                         int size_delta = 0,
+                         gfx::Font::Weight weight = gfx::Font::Weight::NORMAL);
+    FontDetails(const FontDetails&) = default;
+    FontDetails(FontDetails&&) = default;
+    FontDetails& operator=(const FontDetails&) = default;
+    FontDetails& operator=(FontDetails&&) = default;
+    ~FontDetails() = default;
+
+    bool operator==(const FontDetails& rhs) const;
+    bool operator<(const FontDetails& rhs) const;
+
+    // If typeface is empty, we default to the platform-specific "Base" font
+    // list.
+    std::string typeface;
+    int size_delta;
+    gfx::Font::Weight weight;
+  };
+
   enum LoadResources {
     LOAD_COMMON_RESOURCES,
     DO_NOT_LOAD_COMMON_RESOURCES
@@ -293,26 +313,11 @@
 
   // Returns a font list derived from the platform-specific "Base" font list.
   // The result is always cached and exists for the lifetime of the process.
-  const gfx::FontList& GetFontListWithDelta(
-      int size_delta,
-      gfx::Font::FontStyle style = gfx::Font::NORMAL,
-      gfx::Font::Weight weight = gfx::Font::Weight::NORMAL);
+  const gfx::FontList& GetFontListWithDelta(int size_delta);
 
-  // Returns a font list derived from the user-specified typeface. The
-  // result is always cached and exists for the lifetime of the process.
-  // If typeface is empty, we default to the platform-specific "Base" font
-  // list.
-  const gfx::FontList& GetFontListWithTypefaceAndDelta(
-      const std::string& typeface,
-      int size_delta,
-      gfx::Font::FontStyle style = gfx::Font::NORMAL,
-      gfx::Font::Weight weight = gfx::Font::Weight::NORMAL);
-
-  // Returns the primary font from the FontList given by GetFontListWithDelta().
-  const gfx::Font& GetFontWithDelta(
-      int size_delta,
-      gfx::Font::FontStyle style = gfx::Font::NORMAL,
-      gfx::Font::Weight weight = gfx::Font::Weight::NORMAL);
+  // Returns a font list for the given set of |details|. The result is always
+  // cached and exists for the lifetime of the process.
+  const gfx::FontList& GetFontListForDetails(const FontDetails& details);
 
   // Deprecated. Returns fonts using hard-coded size deltas implied by |style|.
   const gfx::FontList& GetFontList(FontStyle style);
@@ -380,8 +385,6 @@
   class ResourceBundleImageSource;
   friend class ResourceBundleImageSource;
 
-  struct FontKey;
-
   using IdToStringMap = std::unordered_map<int, base::string16>;
 
   // Ctor/dtor are private, since we're a singleton.
@@ -509,7 +512,7 @@
   // platform base font size, plus style, to the FontList. Cached to avoid
   // repeated GDI creation/destruction and font derivation.
   // Must be accessed only from UI thread.
-  std::map<FontKey, gfx::FontList> font_cache_;
+  std::map<FontDetails, gfx::FontList> font_cache_;
 
   base::FilePath overridden_pak_path_;
 
diff --git a/ui/views/controls/tabbed_pane/tabbed_pane.cc b/ui/views/controls/tabbed_pane/tabbed_pane.cc
index 4e43dde3..9fbfeab 100644
--- a/ui/views/controls/tabbed_pane/tabbed_pane.cc
+++ b/ui/views/controls/tabbed_pane/tabbed_pane.cc
@@ -5,6 +5,7 @@
 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
 
 #include <algorithm>
+#include <string>
 #include <utility>
 
 #include "base/check_op.h"
@@ -229,8 +230,8 @@
   }
 
   ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
-  title_->SetFontList(
-      rb.GetFontListWithDelta(font_size_delta, gfx::Font::NORMAL, font_weight));
+  title_->SetFontList(rb.GetFontListForDetails(ui::ResourceBundle::FontDetails(
+      std::string(), font_size_delta, font_weight)));
 }
 
 void Tab::OnPaint(gfx::Canvas* canvas) {
diff --git a/ui/views/style/typography_provider.cc b/ui/views/style/typography_provider.cc
index 6e9f7eec..189b559 100644
--- a/ui/views/style/typography_provider.cc
+++ b/ui/views/style/typography_provider.cc
@@ -4,6 +4,8 @@
 
 #include "ui/views/style/typography_provider.h"
 
+#include <string>
+
 #include "base/logging.h"
 #include "build/build_config.h"
 #include "ui/base/default_style.h"
@@ -62,8 +64,8 @@
       if (context == style::CONTEXT_BUTTON) {
         *font_weight = GetValueBolderThan(
             ui::ResourceBundle::GetSharedInstance()
-                .GetFontListWithDelta(*size_delta, gfx::Font::NORMAL,
-                                      *font_weight)
+                .GetFontListForDetails(ui::ResourceBundle::FontDetails(
+                    std::string(), *size_delta, *font_weight))
                 .GetFontWeight());
       }
       break;
@@ -132,8 +134,8 @@
   int size_delta;
   gfx::Font::Weight font_weight;
   GetDefaultFont(context, style, &size_delta, &font_weight);
-  return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
-      size_delta, gfx::Font::NORMAL, font_weight);
+  return ui::ResourceBundle::GetSharedInstance().GetFontListForDetails(
+      ui::ResourceBundle::FontDetails(std::string(), size_delta, font_weight));
 }
 
 SkColor TypographyProvider::GetColor(const View& view,
@@ -162,7 +164,7 @@
   // BOLD font for dialog text; deriving MEDIUM from that would replace the BOLD
   // attribute with something lighter.
   if (ui::ResourceBundle::GetSharedInstance()
-          .GetFontListWithDelta(0, gfx::Font::NORMAL, gfx::Font::Weight::NORMAL)
+          .GetFontListForDetails(ui::ResourceBundle::FontDetails())
           .GetFontWeight() < gfx::Font::Weight::MEDIUM)
     return gfx::Font::Weight::MEDIUM;
   return gfx::Font::Weight::NORMAL;
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 66fec64..52c1d1e 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -271,16 +271,18 @@
 
 // static
 int Widget::GetLocalizedContentsWidth(int col_resource_id) {
-  return ui::GetLocalizedContentsWidthForFont(
-      col_resource_id, ui::ResourceBundle::GetSharedInstance().GetFontWithDelta(
-                           ui::kMessageFontSizeDelta));
+  return ui::GetLocalizedContentsWidthForFontList(
+      col_resource_id,
+      ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
+          ui::kMessageFontSizeDelta));
 }
 
 // static
 int Widget::GetLocalizedContentsHeight(int row_resource_id) {
-  return ui::GetLocalizedContentsHeightForFont(
-      row_resource_id, ui::ResourceBundle::GetSharedInstance().GetFontWithDelta(
-                           ui::kMessageFontSizeDelta));
+  return ui::GetLocalizedContentsHeightForFontList(
+      row_resource_id,
+      ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
+          ui::kMessageFontSizeDelta));
 }
 
 // static