OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | 5 #ifndef UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
6 #define UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | 6 #define UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Gets the FontList for the given |context| and |style|. | 24 // Gets the FontList for the given |context| and |style|. |
25 virtual const gfx::FontList& GetFont(int context, int style) const = 0; | 25 virtual const gfx::FontList& GetFont(int context, int style) const = 0; |
26 | 26 |
27 // Gets the color for the given |context| and |style|. This may consult | 27 // Gets the color for the given |context| and |style|. This may consult |
28 // ui::NativeTheme. | 28 // ui::NativeTheme. |
29 virtual SkColor GetColor(int context, int style) const = 0; | 29 virtual SkColor GetColor(int context, int style) const = 0; |
30 | 30 |
31 // Gets the line spacing, or 0 if it should be provided by gfx::FontList. | 31 // Gets the line spacing, or 0 if it should be provided by gfx::FontList. |
32 virtual int GetLineHeight(int context, int style) const = 0; | 32 virtual int GetLineHeight(int context, int style) const = 0; |
33 | 33 |
| 34 // The system may indicate a "bold" UI font is preferred (e.g. by selecting |
| 35 // the "Bold" checkbox in Windows under "Change only the text size" in |
| 36 // Control Panel). In this case, a user's gfx::Weight::NORMAL font will |
| 37 // already be bold, and requesting a MEDIUM font will result in a font that is |
| 38 // less bold. So this method returns NORMAL, if the NORMAL font is at least as |
| 39 // bold as |weight|. |
| 40 static gfx::Font::Weight WeightNotLighterThanNormal(gfx::Font::Weight weight); |
| 41 |
34 protected: | 42 protected: |
35 TypographyProvider() = default; | 43 TypographyProvider() = default; |
36 | 44 |
37 private: | 45 private: |
38 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); | 46 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); |
39 }; | 47 }; |
40 | 48 |
41 // The default provider aims to provide values to match pre-Harmony constants | 49 // The default provider aims to provide values to match pre-Harmony constants |
42 // for the given contexts so that old UI does not change. | 50 // for the given contexts so that old UI does not change. |
43 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { | 51 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { |
44 public: | 52 public: |
45 DefaultTypographyProvider() = default; | 53 DefaultTypographyProvider() = default; |
46 | 54 |
47 // TypographyProvider: | 55 // TypographyProvider: |
48 const gfx::FontList& GetFont(int context, int style) const override; | 56 const gfx::FontList& GetFont(int context, int style) const override; |
49 SkColor GetColor(int context, int style) const override; | 57 SkColor GetColor(int context, int style) const override; |
50 int GetLineHeight(int context, int style) const override; | 58 int GetLineHeight(int context, int style) const override; |
51 | 59 |
52 // Sets the |size_delta| and |font_weight| that the the default GetFont() | 60 // Sets the |size_delta| and |font_weight| that the the default GetFont() |
53 // implementation uses. Always sets values, even for styles it doesn't know | 61 // implementation uses. Always sets values, even for styles it doesn't know |
54 // about. | 62 // about. |
55 void GetDefaultFont(int context, | 63 static void GetDefaultFont(int context, |
56 int style, | 64 int style, |
57 int* size_delta, | 65 int* size_delta, |
58 gfx::Font::Weight* font_weight) const; | 66 gfx::Font::Weight* font_weight); |
59 | 67 |
60 private: | 68 private: |
61 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); | 69 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); |
62 }; | 70 }; |
63 | 71 |
64 } // namespace views | 72 } // namespace views |
65 | 73 |
66 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | 74 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
OLD | NEW |