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/chrome_typography.h" | 5 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
6 | 6 |
| 7 #include "build/build_config.h" |
7 #include "ui/base/default_style.h" | 8 #include "ui/base/default_style.h" |
8 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/platform_font.h" |
| 11 |
| 12 void ApplyCommonFontStyles(int context, |
| 13 int style, |
| 14 int* size_delta, |
| 15 gfx::Font::Weight* weight) { |
| 16 #if defined(OS_WIN) |
| 17 if (context == CONTEXT_WINDOWS10_NATIVE) { |
| 18 // Adjusts default font size up to match Win10 modern UI. |
| 19 *size_delta = 15 - gfx::PlatformFont::kDefaultBaseFontSize; |
| 20 *weight = views::TypographyProvider::MediumWeightForUI(); |
| 21 } |
| 22 #endif |
| 23 } |
9 | 24 |
10 const gfx::FontList& LegacyTypographyProvider::GetFont(int context, | 25 const gfx::FontList& LegacyTypographyProvider::GetFont(int context, |
11 int style) const { | 26 int style) const { |
12 constexpr int kHeadlineDelta = 8; | 27 constexpr int kHeadlineDelta = 8; |
13 constexpr int kDialogMessageDelta = 1; | 28 constexpr int kDialogMessageDelta = 1; |
14 | 29 |
15 int size_delta; | 30 int size_delta; |
16 gfx::Font::Weight font_weight; | 31 gfx::Font::Weight font_weight; |
17 GetDefaultFont(context, style, &size_delta, &font_weight); | 32 GetDefaultFont(context, style, &size_delta, &font_weight); |
18 | 33 |
19 #if defined(USE_ASH) | 34 #if defined(USE_ASH) |
20 ash::ApplyAshFontStyles(context, style, &size_delta, &font_weight); | 35 ash::ApplyAshFontStyles(context, style, &size_delta, &font_weight); |
21 #endif | 36 #endif |
22 | 37 |
| 38 ApplyCommonFontStyles(context, style, &size_delta, &font_weight); |
| 39 |
23 switch (context) { | 40 switch (context) { |
24 case CONTEXT_HEADLINE: | 41 case CONTEXT_HEADLINE: |
25 size_delta = kHeadlineDelta; | 42 size_delta = kHeadlineDelta; |
26 break; | 43 break; |
27 case CONTEXT_BODY_TEXT_LARGE: | 44 case CONTEXT_BODY_TEXT_LARGE: |
28 // Note: Not using ui::kMessageFontSizeDelta, so 13pt in most cases. | 45 // Note: Not using ui::kMessageFontSizeDelta, so 13pt in most cases. |
29 size_delta = kDialogMessageDelta; | 46 size_delta = kDialogMessageDelta; |
30 break; | 47 break; |
31 case CONTEXT_BODY_TEXT_SMALL: | 48 case CONTEXT_BODY_TEXT_SMALL: |
32 size_delta = ui::kLabelFontSizeDelta; | 49 size_delta = ui::kLabelFontSizeDelta; |
(...skipping 15 matching lines...) Expand all Loading... |
48 | 65 |
49 SkColor LegacyTypographyProvider::GetColor(int context, | 66 SkColor LegacyTypographyProvider::GetColor(int context, |
50 int style, | 67 int style, |
51 const ui::NativeTheme& theme) const { | 68 const ui::NativeTheme& theme) const { |
52 // Use "disabled grey" for HINT and SECONDARY when Harmony is disabled. | 69 // Use "disabled grey" for HINT and SECONDARY when Harmony is disabled. |
53 if (style == STYLE_HINT || style == STYLE_SECONDARY) | 70 if (style == STYLE_HINT || style == STYLE_SECONDARY) |
54 style = views::style::STYLE_DISABLED; | 71 style = views::style::STYLE_DISABLED; |
55 | 72 |
56 return DefaultTypographyProvider::GetColor(context, style, theme); | 73 return DefaultTypographyProvider::GetColor(context, style, theme); |
57 } | 74 } |
OLD | NEW |