Chromium Code Reviews| 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 // A user's gfx::Weight::NORMAL font may already "bold enough" and requesting | |
| 35 // a MEDIUM font can result in a font that is less bold. So this method | |
| 36 // returns NORMAL, if the NORMAL font is at least as bold as |weight|. | |
|
Peter Kasting
2017/04/08 01:38:54
I'm confused. There are fonts where asking for a
tapted
2017/04/10 12:27:33
Yup.
The windows font settings have a "Bold font"
Peter Kasting
2017/04/10 22:56:02
OK, so effectively, the "bold font" checkbox reall
tapted
2017/04/11 01:56:50
It's not quite that bad :). The logic for this is
Peter Kasting
2017/04/11 02:24:20
OK, so the default metrics say e.g. "use weight 60
tapted
2017/04/12 07:31:48
Yup
Peter Kasting
2017/04/13 03:53:17
Yeah, I agree this is too low-level -- the issue i
tapted
2017/05/05 03:08:49
I've implemented this in PatchSet 13. But -- witho
| |
| 37 static gfx::Font::Weight WeightNotLighterThanNormal(gfx::Font::Weight weight); | |
| 38 | |
| 34 protected: | 39 protected: |
| 35 TypographyProvider() = default; | 40 TypographyProvider() = default; |
| 36 | 41 |
| 37 private: | 42 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); | 43 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); |
| 39 }; | 44 }; |
| 40 | 45 |
| 41 // The default provider aims to provide values to match pre-Harmony constants | 46 // The default provider aims to provide values to match pre-Harmony constants |
| 42 // for the given contexts so that old UI does not change. | 47 // for the given contexts so that old UI does not change. |
| 43 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { | 48 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { |
| 44 public: | 49 public: |
| 45 DefaultTypographyProvider() = default; | 50 DefaultTypographyProvider() = default; |
| 46 | 51 |
| 47 // TypographyProvider: | 52 // TypographyProvider: |
| 48 const gfx::FontList& GetFont(int context, int style) const override; | 53 const gfx::FontList& GetFont(int context, int style) const override; |
| 49 SkColor GetColor(int context, int style) const override; | 54 SkColor GetColor(int context, int style) const override; |
| 50 int GetLineHeight(int context, int style) const override; | 55 int GetLineHeight(int context, int style) const override; |
| 51 | 56 |
| 52 // Sets the |size_delta| and |font_weight| that the the default GetFont() | 57 // 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 | 58 // implementation uses. Always sets values, even for styles it doesn't know |
| 54 // about. | 59 // about. |
| 55 void GetDefaultFont(int context, | 60 static void GetDefaultFont(int context, |
| 56 int style, | 61 int style, |
| 57 int* size_delta, | 62 int* size_delta, |
| 58 gfx::Font::Weight* font_weight) const; | 63 gfx::Font::Weight* font_weight); |
| 59 | 64 |
| 60 private: | 65 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); | 66 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 } // namespace views | 69 } // namespace views |
| 65 | 70 |
| 66 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | 71 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
| OLD | NEW |