Flutter Engine
The Flutter Engine
SkFontMgr_fontations_empty.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2024 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
17
18#include <memory>
19#include <utility>
20
21class SkData;
22class SkString;
23
24
25namespace {
26
27/**
28 * SkFontMgr_Fontations_Empty
29 *
30 * A SkFontMgr with an empty list of fonts, meant as a basic tool for font instantiation from
31 * data in testing, see TestFontMgr in FontToolUtils.
32 */
33class SkFontMgr_Fontations_Empty : public SkFontMgr {
34public:
35 SkFontMgr_Fontations_Empty() = default;
36
37protected:
38 int onCountFamilies() const override { return 0; }
39 void onGetFamilyName(int index, SkString* familyName) const override {}
40 sk_sp<SkFontStyleSet> onCreateStyleSet(int index) const override {
42 }
43 sk_sp<SkFontStyleSet> onMatchFamily(const char familyName[]) const override {
45 }
46 sk_sp<SkTypeface> onMatchFamilyStyle(const char familyName[],
47 const SkFontStyle& fontStyle) const override {
48 return nullptr;
49 }
50 sk_sp<SkTypeface> onMatchFamilyStyleCharacter(const char familyName[],
51 const SkFontStyle&,
52 const char* bcp47[],
53 int bcp47Count,
54 SkUnichar character) const override {
55 return nullptr;
56 }
57 sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const override {
58 return this->makeFromStream(std::make_unique<SkMemoryStream>(std::move(data)), ttcIndex);
59 }
60 sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> stream,
61 int ttcIndex) const override {
62 return this->makeFromStream(std::move(stream),
63 SkFontArguments().setCollectionIndex(ttcIndex));
64 }
65 sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset> stream,
66 const SkFontArguments& args) const override {
68 }
69 sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override {
70 std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(path);
71 return stream ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
72 }
73 sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[],
74 SkFontStyle style) const override {
75 return nullptr;
76 }
77};
78
79} // namespace
80
82 return sk_make_sp<SkFontMgr_Fontations_Empty>();
83}
sk_sp< SkFontMgr > SkFontMgr_New_Fontations_Empty()
int32_t SkUnichar
Definition: SkTypes.h:175
Definition: SkData.h:25
static sk_sp< SkFontStyleSet > CreateEmpty()
Definition: SkFontMgr.cpp:35
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition: SkStream.cpp:922
const char * data() const
Definition: SkString.h:132
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
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