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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/style/typography_provider.cc
diff --git a/ui/views/style/typography_provider.cc b/ui/views/style/typography_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fd17ed4f7497a23b16d099a449f82d75e0cd697e
--- /dev/null
+++ b/ui/views/style/typography_provider.cc
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/style/typography_provider.h"
+
+#include "base/logging.h"
+#include "ui/base/default_style.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/style/typography.h"
+
+namespace views {
+namespace {
+std::unique_ptr<TypographyProvider>& Storage() {
+ CR_DEFINE_STATIC_LOCAL(std::unique_ptr<TypographyProvider>, storage,
+ (new DefaultTypographyProvider));
+ return storage;
+}
+} // namespace
+
+// static
+void TypographyProvider::Set(std::unique_ptr<TypographyProvider> provider) {
+ DCHECK(provider);
+ Storage() = std::move(provider);
+}
+
+// static
+const TypographyProvider& TypographyProvider::Get() {
+ return *Storage().get();
+}
+
+const gfx::FontList& DefaultTypographyProvider::GetFont(TextContext context,
+ TextStyle style) const {
+ int size_delta;
+ gfx::Font::Weight font_weight;
+ GetDefaultFont(context, style, &size_delta, &font_weight);
+ constexpr gfx::Font::FontStyle kFontStyle = gfx::Font::NORMAL;
+ return ResourceBundle::GetSharedInstance().GetFontListWithDelta(
+ size_delta, kFontStyle, font_weight);
+}
+
+void DefaultTypographyProvider::GetDefaultFont(
+ TextContext context,
+ TextStyle style,
+ int* size_delta,
+ gfx::Font::Weight* font_weight) const {
+ switch (context.value()) {
+ case TextContext::DIALOG_TITLE:
+ *size_delta = ui::kTitleFontSizeDelta;
+ break;
+ default:
+ *size_delta = ui::kLabelFontSizeDelta;
+ break;
+ }
+
+ switch (style.value()) {
+ case TextStyle::ACTIVE_TAB:
+ *font_weight = gfx::Font::Weight::BOLD;
+ break;
+ default:
+ *font_weight = gfx::Font::Weight::NORMAL;
+ break;
+ }
+}
+
+SkColor DefaultTypographyProvider::GetColor(TextContext context,
+ TextStyle style) const {
+ return SK_ColorBLACK;
+}
+
+int DefaultTypographyProvider::GetLineSpacing(TextContext context,
+ TextStyle style) const {
+ return 0;
+}
+
+} // namespace views
« 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