Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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
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
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
65 const char familyName[],
66 const SkFontStyle&,
67 const char* bcp47[],
68 int bcp47Count,
69 SkUnichar character) const {
70 return nullptr;
71}
72
74 int ttcIndex) const {
75 FML_DCHECK(false);
76 return nullptr;
77}
78
80 std::unique_ptr<SkStreamAsset>,
81 int ttcIndex) const {
82 FML_DCHECK(false);
83 return nullptr;
84}
85
87 std::unique_ptr<SkStreamAsset>,
88 const SkFontArguments&) const {
89 FML_DCHECK(false);
90 return nullptr;
91}
92
94 int ttcIndex) const {
95 FML_DCHECK(false);
96 return nullptr;
97}
98
100 const char familyName[],
101 SkFontStyle) const {
102 return nullptr;
103}
104
105} // namespace txt
int32_t SkUnichar
Definition SkTypes.h:175
void set(const SkString &src)
Definition SkString.h:186
sk_sp< SkTypeface > onMatchFamilyStyle(const char familyName[], const SkFontStyle &) const override
sk_sp< SkTypeface > onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override
~AssetFontManager() override
sk_sp< SkTypeface > onMakeFromFile(const char path[], int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromStreamArgs(std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
void onGetFamilyName(int index, SkString *familyName) const override
sk_sp< SkTypeface > onMakeFromData(sk_sp< SkData >, int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromStreamIndex(std::unique_ptr< SkStreamAsset >, int ttcIndex) const override
AssetFontManager(std::unique_ptr< FontAssetProvider > font_provider)
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
std::unique_ptr< FontAssetProvider > font_provider_
sk_sp< SkFontStyleSet > onCreateStyleSet(int index) const override
int onCountFamilies() const override
sk_sp< SkTypeface > onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const override
#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