Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: ui/base/resource/resource_bundle.h

Issue 1689623004: Start removing enum ui::ResourceBundle::FontStyle, fix MacViews font sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix transcription error Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/default_style.h ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.h
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index 5a3cc5a4b123117341cfd7b623e9f9ac9af12591..1382aeb9350576250739ccbd15b13e5242009944 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -43,12 +43,16 @@ class ResourceHandle;
// such as theme graphics. Every resource is loaded only once.
class UI_BASE_EXPORT ResourceBundle {
public:
- // An enumeration of the various font styles used throughout Chrome.
- // The following holds true for the font sizes:
- // Small <= SmallBold <= Base <= Bold <= Medium <= MediumBold <= Large.
+ // Legacy font size deltas. Consider these to be magic numbers. New code
+ // should declare their own size delta constant using an identifier that
+ // imparts some semantic meaning.
+ static const int kSmallFontDelta = -1;
+ static const int kMediumFontDelta = 3;
+ static const int kLargeFontDelta = 8;
+
+ // Legacy font style mappings. TODO(tapted): Phase these out in favour of
+ // client code providing their own constant with the desired font size delta.
enum FontStyle {
- // NOTE: depending upon the locale, using one of the *BoldFont below
- // may *not* actually result in a bold font.
SmallFont,
SmallBoldFont,
BaseFont,
@@ -238,10 +242,19 @@ class UI_BASE_EXPORT ResourceBundle {
// string if the message_id is not found.
base::string16 GetLocalizedString(int message_id);
- // Returns the font list for the specified style.
- const gfx::FontList& GetFontList(FontStyle style);
+ // 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);
+
+ // Returns the primary font from the FontList given by GetFontListWithDelta().
+ const gfx::Font& GetFontWithDelta(
+ int size_delta,
+ gfx::Font::FontStyle style = gfx::Font::NORMAL);
- // Returns the font for the specified style.
+ // Deprecated. Returns fonts using hard-coded size deltas implied by |style|.
+ const gfx::FontList& GetFontList(FontStyle style);
const gfx::Font& GetFont(FontStyle style);
// Resets and reloads the cached fonts. This is useful when the fonts of the
@@ -341,10 +354,6 @@ class UI_BASE_EXPORT ResourceBundle {
// Initializes the font description of default gfx::FontList.
void InitDefaultFontList();
- // Initializes all the gfx::FontList members if they haven't yet been
- // initialized.
- void LoadFontsIfNecessary();
-
// Fills the |bitmap| given the data file to look in and the |resource_id|.
// Returns false if the resource does not exist.
//
@@ -411,17 +420,11 @@ class UI_BASE_EXPORT ResourceBundle {
gfx::Image empty_image_;
- // The various font lists used. Cached to avoid repeated GDI
- // creation/destruction.
- scoped_ptr<gfx::FontList> base_font_list_;
- scoped_ptr<gfx::FontList> bold_font_list_;
- scoped_ptr<gfx::FontList> small_font_list_;
- scoped_ptr<gfx::FontList> small_bold_font_list_;
- scoped_ptr<gfx::FontList> medium_font_list_;
- scoped_ptr<gfx::FontList> medium_bold_font_list_;
- scoped_ptr<gfx::FontList> large_font_list_;
- scoped_ptr<gfx::FontList> large_bold_font_list_;
- scoped_ptr<gfx::FontList> web_font_list_;
+ // The various font lists used, as a map from a signed size delta from the
+ // platform base font size, plus style, to the FontList. Cached to avoid
+ // repeated GDI creation/destruction and font derivation.
+ // Must be accessed only while holding |images_and_fonts_lock_|.
+ std::map<std::pair<int, gfx::Font::FontStyle>, gfx::FontList> font_cache_;
base::FilePath overridden_pak_path_;
« no previous file with comments | « ui/base/default_style.h ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698