Flutter Engine
The Flutter Engine
asset_font_manager.cc
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
18
19#include <memory>
20
21#include "flutter/fml/logging.h"
24
25namespace txt {
26
28 std::unique_ptr<FontAssetProvider> font_provider)
29 : font_provider_(std::move(font_provider)) {
30 FML_DCHECK(font_provider_ != nullptr);
31}
32
34
35int AssetFontManager::onCountFamilies() const {
36 return font_provider_->GetFamilyCount();
37}
38
39void AssetFontManager::onGetFamilyName(int index, SkString* familyName) const {
40 familyName->set(font_provider_->GetFamilyName(index).c_str());
41}
42
43sk_sp<SkFontStyleSet> AssetFontManager::onCreateStyleSet(int index) const {
44 FML_DCHECK(false);
45 return nullptr;
46}
47
49 const char family_name_string[]) const {
50 std::string family_name(family_name_string);
51 return font_provider_->MatchFamily(family_name);
52}
53
54sk_sp<SkTypeface> AssetFontManager::onMatchFamilyStyle(
55 const char familyName[],
56 const SkFontStyle& style) const {
57 sk_sp<SkFontStyleSet> font_style_set =
58 font_provider_->MatchFamily(std::string(familyName));
59 if (font_style_set == nullptr)
60 return nullptr;
61 return font_style_set->matchStyle(style);
62}
63
64sk_sp<SkTypeface> AssetFontManager::onMatchFamilyStyleCharacter(
65 const char familyName[],
66 const SkFontStyle&,
67 const char* bcp47[],
68 int bcp47Count,
69 SkUnichar character) const {
70 return nullptr;
71}
72
73sk_sp<SkTypeface> AssetFontManager::onMakeFromData(sk_sp<SkData>,
74 int ttcIndex) const {
75 FML_DCHECK(false);
76 return nullptr;
77}
78
79sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamIndex(
80 std::unique_ptr<SkStreamAsset>,
81 int ttcIndex) const {
82 FML_DCHECK(false);
83 return nullptr;
84}
85
86sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamArgs(
87 std::unique_ptr<SkStreamAsset>,
88 const SkFontArguments&) const {
89 FML_DCHECK(false);
90 return nullptr;
91}
92
93sk_sp<SkTypeface> AssetFontManager::onMakeFromFile(const char path[],
94 int ttcIndex) const {
95 FML_DCHECK(false);
96 return nullptr;
97}
98
99sk_sp<SkTypeface> AssetFontManager::onLegacyMakeTypeface(
100 const char familyName[],
101 SkFontStyle) const {
102 return nullptr;
103}
104
105} // namespace txt
int32_t SkUnichar
Definition: SkTypes.h:175
virtual sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern)=0
void set(const SkString &src)
Definition: SkString.h:186
~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:103
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: switches.h:57
Definition: ref_ptr.h:256