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 #include "chrome/browser/ui/views/harmony/harmony_typography_provider.h" | 5 #include "chrome/browser/ui/views/harmony/harmony_typography_provider.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" | 7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/gfx/platform_font.h" | 9 #include "ui/gfx/platform_font.h" |
10 | 10 |
11 #if defined(USE_ASH) | |
12 #include "ash/common/ash_typography.h" | |
13 #endif | |
14 | |
11 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context, | 15 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context, |
12 int text_style) const { | 16 int text_style) const { |
13 // "Target" font size constants from the Harmony spec. | 17 // "Target" font size constants from the Harmony spec. |
14 constexpr int kHeadlineSize = 20; | 18 constexpr int kHeadlineSize = 20; |
15 constexpr int kTitleSize = 15; | 19 constexpr int kTitleSize = 15; |
16 constexpr int kBodyTextLargeSize = 13; | 20 constexpr int kBodyTextLargeSize = 13; |
17 constexpr int kDefaultSize = 12; | 21 constexpr int kDefaultSize = 12; |
18 | 22 |
19 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
20 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::BOLD; | 24 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::BOLD; |
21 #else | 25 #else |
22 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::MEDIUM; | 26 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::MEDIUM; |
23 #endif | 27 #endif |
24 | 28 |
25 int size_delta = kDefaultSize - gfx::PlatformFont::kDefaultBaseFontSize; | 29 int size_delta = kDefaultSize - gfx::PlatformFont::kDefaultBaseFontSize; |
26 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL; | 30 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL; |
27 switch (text_context) { | 31 switch (text_context) { |
28 case CONTEXT_HEADLINE: | 32 case CONTEXT_HEADLINE: |
29 size_delta = kHeadlineSize - gfx::PlatformFont::kDefaultBaseFontSize; | 33 size_delta = kHeadlineSize - gfx::PlatformFont::kDefaultBaseFontSize; |
30 break; | 34 break; |
31 case views::style::CONTEXT_DIALOG_TITLE: | 35 case views::style::CONTEXT_DIALOG_TITLE: |
32 size_delta = kTitleSize - gfx::PlatformFont::kDefaultBaseFontSize; | 36 size_delta = kTitleSize - gfx::PlatformFont::kDefaultBaseFontSize; |
33 break; | 37 break; |
34 case CONTEXT_BODY_TEXT_LARGE: | 38 case CONTEXT_BODY_TEXT_LARGE: |
35 size_delta = kBodyTextLargeSize - gfx::PlatformFont::kDefaultBaseFontSize; | 39 size_delta = kBodyTextLargeSize - gfx::PlatformFont::kDefaultBaseFontSize; |
36 break; | 40 break; |
37 case views::style::CONTEXT_BUTTON: | 41 case views::style::CONTEXT_BUTTON_MD: |
38 font_weight = kButtonFontWeight; | 42 font_weight = WeightNotLighterThanNormal(kButtonFontWeight); |
39 break; | 43 break; |
40 default: | 44 default: |
41 break; | 45 break; |
42 } | 46 } |
43 | 47 |
44 // Ignore |text_style| since it only affects color in the Harmony spec. | 48 // Ignore |text_style| since it only affects color in the Harmony spec. |
49 | |
50 #if defined(USE_ASH) | |
51 ash::GetDefaultAshFont(text_context, text_style, &size_delta, &font_weight); | |
Peter Kasting
2017/04/08 01:38:54
Nit: I liked doing this above the switch, as you d
tapted
2017/04/10 12:27:33
Done.
| |
52 #endif | |
53 | |
45 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | 54 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
46 size_delta, gfx::Font::NORMAL, font_weight); | 55 size_delta, gfx::Font::NORMAL, font_weight); |
47 } | 56 } |
48 | 57 |
49 SkColor HarmonyTypographyProvider::GetColor(int text_context, | 58 SkColor HarmonyTypographyProvider::GetColor(int text_context, |
50 int text_style) const { | 59 int text_style) const { |
51 // TODO(tapted): Look up colors from the spec. | 60 // TODO(tapted): Look up colors from the spec. |
52 return SK_ColorBLACK; | 61 return SK_ColorBLACK; |
53 } | 62 } |
54 | 63 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 case views::style::CONTEXT_DIALOG_TITLE: | 121 case views::style::CONTEXT_DIALOG_TITLE: |
113 return title_height; | 122 return title_height; |
114 case CONTEXT_BODY_TEXT_LARGE: | 123 case CONTEXT_BODY_TEXT_LARGE: |
115 return body_large_height; | 124 return body_large_height; |
116 case views::style::CONTEXT_BUTTON: | 125 case views::style::CONTEXT_BUTTON: |
117 return kButtonAbsoluteHeight; | 126 return kButtonAbsoluteHeight; |
118 default: | 127 default: |
119 return default_height; | 128 return default_height; |
120 } | 129 } |
121 } | 130 } |
OLD | NEW |