Flutter Engine
 
Loading...
Searching...
No Matches
asset_font_manager.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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
6
7#include <memory>
8
10#include "third_party/skia/include/core/SkString.h"
11#include "third_party/skia/include/core/SkTypeface.h"
12
13namespace txt {
14
16 std::unique_ptr<FontAssetProvider> font_provider)
17 : font_provider_(std::move(font_provider)) {
18 FML_DCHECK(font_provider_ != nullptr);
19}
20
22
23int AssetFontManager::onCountFamilies() const {
24 return font_provider_->GetFamilyCount();
25}
26
27void AssetFontManager::onGetFamilyName(int index, SkString* familyName) const {
28 familyName->set(font_provider_->GetFamilyName(index).c_str());
29}
30
31sk_sp<SkFontStyleSet> AssetFontManager::onCreateStyleSet(int index) const {
32 FML_DCHECK(false);
33 return nullptr;
34}
35
36sk_sp<SkFontStyleSet> AssetFontManager::onMatchFamily(
37 const char family_name_string[]) const {
38 std::string family_name(family_name_string);
39 return font_provider_->MatchFamily(family_name);
40}
41
42sk_sp<SkTypeface> AssetFontManager::onMatchFamilyStyle(
43 const char familyName[],
44 const SkFontStyle& style) const {
45 sk_sp<SkFontStyleSet> font_style_set =
46 font_provider_->MatchFamily(std::string(familyName));
47 if (font_style_set == nullptr) {
48 return nullptr;
49 }
50 return font_style_set->matchStyle(style);
51}
52
53sk_sp<SkTypeface> AssetFontManager::onMatchFamilyStyleCharacter(
54 const char familyName[],
55 const SkFontStyle&,
56 const char* bcp47[],
57 int bcp47Count,
58 SkUnichar character) const {
59 return nullptr;
60}
61
62sk_sp<SkTypeface> AssetFontManager::onMakeFromData(sk_sp<SkData>,
63 int ttcIndex) const {
64 FML_DCHECK(false);
65 return nullptr;
66}
67
68sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamIndex(
69 std::unique_ptr<SkStreamAsset>,
70 int ttcIndex) const {
71 FML_DCHECK(false);
72 return nullptr;
73}
74
75sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamArgs(
76 std::unique_ptr<SkStreamAsset>,
77 const SkFontArguments&) const {
78 FML_DCHECK(false);
79 return nullptr;
80}
81
82sk_sp<SkTypeface> AssetFontManager::onMakeFromFile(const char path[],
83 int ttcIndex) const {
84 FML_DCHECK(false);
85 return nullptr;
86}
87
88sk_sp<SkTypeface> AssetFontManager::onLegacyMakeTypeface(
89 const char familyName[],
90 SkFontStyle) const {
91 return nullptr;
92}
93
94} // namespace txt
~AssetFontManager() override
AssetFontManager(std::unique_ptr< FontAssetProvider > font_provider)
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
std::unique_ptr< FontAssetProvider > font_provider_
#define FML_DCHECK(condition)
Definition logging.h:122
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switch_defs.h:52
Definition ref_ptr.h:261