2 * Copyright 2021 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "include/utils/SkOrderedFontMgr.h"
10 #include "include/core/SkData.h" // IWYU pragma: keep
11 #include "include/core/SkFontStyle.h"
12 #include "include/core/SkStream.h" // IWYU pragma: keep
13 #include "include/core/SkTypeface.h" // IWYU pragma: keep
18 struct SkFontArguments;
20 SkOrderedFontMgr::SkOrderedFontMgr() {}
21 SkOrderedFontMgr::~SkOrderedFontMgr() {}
23 void SkOrderedFontMgr::append(sk_sp<SkFontMgr> fm) {
24 fList.push_back(std::move(fm));
27 int SkOrderedFontMgr::onCountFamilies() const {
29 for (const auto& fm : fList) {
30 count += fm->countFamilies();
35 void SkOrderedFontMgr::onGetFamilyName(int index, SkString* familyName) const {
36 for (const auto& fm : fList) {
37 const int count = fm->countFamilies();
39 return fm->getFamilyName(index, familyName);
45 SkFontStyleSet* SkOrderedFontMgr::onCreateStyleSet(int index) const {
46 for (const auto& fm : fList) {
47 const int count = fm->countFamilies();
49 return fm->createStyleSet(index);
56 SkFontStyleSet* SkOrderedFontMgr::onMatchFamily(const char familyName[]) const {
57 for (const auto& fm : fList) {
58 if (auto fs = fm->matchFamily(familyName)) {
65 SkTypeface* SkOrderedFontMgr::onMatchFamilyStyle(const char family[],
66 const SkFontStyle& style) const {
67 for (const auto& fm : fList) {
68 if (auto tf = fm->matchFamilyStyle(family, style)) {
75 SkTypeface* SkOrderedFontMgr::onMatchFamilyStyleCharacter(const char familyName[],
76 const SkFontStyle& style,
77 const char* bcp47[], int bcp47Count,
78 SkUnichar uni) const {
79 for (const auto& fm : fList) {
80 if (auto tf = fm->matchFamilyStyleCharacter(familyName, style, bcp47, bcp47Count, uni)) {
87 // All of these are defined to fail by returning null
89 sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromData(sk_sp<SkData>, int ttcIndex) const {
93 sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
98 sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
99 const SkFontArguments&) const {
103 sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromFile(const char path[], int ttcIndex) const {
107 sk_sp<SkTypeface> SkOrderedFontMgr::onLegacyMakeTypeface(const char family[], SkFontStyle) const {