Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkOrderedFontMgr.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10#include "include/core/SkData.h" // IWYU pragma: keep
12#include "include/core/SkStream.h" // IWYU pragma: keep
13#include "include/core/SkTypeface.h" // IWYU pragma: keep
14
15#include <utility>
16
17class SkString;
18struct SkFontArguments;
19
22
24 fList.push_back(std::move(fm));
25}
26
28 int count = 0;
29 for (const auto& fm : fList) {
30 count += fm->countFamilies();
31 }
32 return count;
33}
34
35void SkOrderedFontMgr::onGetFamilyName(int index, SkString* familyName) const {
36 for (const auto& fm : fList) {
37 const int count = fm->countFamilies();
38 if (index < count) {
39 return fm->getFamilyName(index, familyName);
40 }
41 index -= count;
42 }
43}
44
46 for (const auto& fm : fList) {
47 const int count = fm->countFamilies();
48 if (index < count) {
49 return fm->createStyleSet(index);
50 }
51 index -= count;
52 }
53 return nullptr;
54}
55
57 for (const auto& fm : fList) {
58 if (auto fs = fm->matchFamily(familyName)) {
59 return fs;
60 }
61 }
62 return nullptr;
63}
64
66 const SkFontStyle& style) const {
67 for (const auto& fm : fList) {
68 if (auto tf = fm->matchFamilyStyle(family, style)) {
69 return tf;
70 }
71 }
72 return nullptr;
73}
74
76 const char familyName[], const SkFontStyle& style,
77 const char* bcp47[], int bcp47Count,
78 SkUnichar uni) const
79{
80 for (const auto& fm : fList) {
81 if (auto tf = fm->matchFamilyStyleCharacter(familyName, style, bcp47, bcp47Count, uni)) {
82 return tf;
83 }
84 }
85 return nullptr;
86}
87
88// All of these are defined to fail by returning null
89
91 return nullptr;
92}
93
95 int ttcIndex) const {
96 return nullptr;
97}
98
100 const SkFontArguments&) const {
101 return nullptr;
102}
103
104sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromFile(const char path[], int ttcIndex) const {
105 return nullptr;
106}
107
109 return nullptr;
110}
int count
int32_t SkUnichar
Definition SkTypes.h:175
void append(sk_sp< SkFontMgr >)
sk_sp< SkTypeface > onMakeFromStreamArgs(std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
sk_sp< SkTypeface > onMakeFromFile(const char path[], int ttcIndex) const override
void onGetFamilyName(int index, SkString *familyName) const override
int onCountFamilies() const override
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
sk_sp< SkTypeface > onMakeFromStreamIndex(std::unique_ptr< SkStreamAsset >, int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromData(sk_sp< SkData >, int ttcIndex) const override
sk_sp< SkTypeface > onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const override
~SkOrderedFontMgr() override
sk_sp< SkTypeface > onMatchFamilyStyle(const char familyName[], const SkFontStyle &) const override
sk_sp< SkFontStyleSet > onCreateStyleSet(int index) const override
sk_sp< SkTypeface > onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override