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

Side by Side Diff: ui/views/style/typography_provider.cc

Issue 2734113006: "Bootstrap" a toolkit-views Typography spec. (Closed)
Patch Set: Shred Typography class, follow-up on some other things. fix compile. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/style/typography_provider.h"
6
7 #include "base/logging.h"
8 #include "ui/base/default_style.h"
9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/views/style/typography.h"
11
12 namespace views {
13 namespace {
14 std::unique_ptr<TypographyProvider>& Storage() {
15 CR_DEFINE_STATIC_LOCAL(std::unique_ptr<TypographyProvider>, storage,
16 (new DefaultTypographyProvider));
17 return storage;
18 }
19 } // namespace
20
21 // static
22 void TypographyProvider::Set(std::unique_ptr<TypographyProvider> provider) {
23 DCHECK(provider);
24 Storage() = std::move(provider);
25 }
26
27 // static
28 const TypographyProvider& TypographyProvider::Get() {
29 return *Storage().get();
30 }
31
32 const gfx::FontList& DefaultTypographyProvider::GetFont(TextContext context,
33 TextStyle style) const {
34 int size_delta;
35 gfx::Font::Weight font_weight;
36 GetDefaultFont(context, style, &size_delta, &font_weight);
37 constexpr gfx::Font::FontStyle kFontStyle = gfx::Font::NORMAL;
38 return ResourceBundle::GetSharedInstance().GetFontListWithDelta(
39 size_delta, kFontStyle, font_weight);
40 }
41
42 void DefaultTypographyProvider::GetDefaultFont(
43 TextContext context,
44 TextStyle style,
45 int* size_delta,
46 gfx::Font::Weight* font_weight) const {
47 switch (context.value()) {
48 case TextContext::DIALOG_TITLE:
49 *size_delta = ui::kTitleFontSizeDelta;
50 break;
51 default:
52 *size_delta = ui::kLabelFontSizeDelta;
53 break;
54 }
55
56 switch (style.value()) {
57 case TextStyle::ACTIVE_TAB:
58 *font_weight = gfx::Font::Weight::BOLD;
59 break;
60 default:
61 *font_weight = gfx::Font::Weight::NORMAL;
62 break;
63 }
64 }
65
66 SkColor DefaultTypographyProvider::GetColor(TextContext context,
67 TextStyle style) const {
68 return SK_ColorBLACK;
69 }
70
71 int DefaultTypographyProvider::GetLineSpacing(TextContext context,
72 TextStyle style) const {
73 return 0;
74 }
75
76 } // namespace views
OLDNEW
« ui/views/style/typography_provider.h ('K') | « ui/views/style/typography_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698