| 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
|
|
|