Debian Codegraph @

tools/fonts/TestEmptyTypeface.h

raw
1 /*
2 * Copyright 2018 The Android Open Source Project
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
8 #ifndef TestEmptyTypeface_DEFINED
9 #define TestEmptyTypeface_DEFINED
10
11 #include "include/core/SkStream.h"
12 #include "include/core/SkTypeface.h"
13 #include "src/core/SkAdvancedTypefaceMetrics.h"
14 #include "src/core/SkScalerContext.h"
15
16 class TestEmptyTypeface : public SkTypeface {
17 public:
18 static sk_sp<SkTypeface> Make() { return sk_sp<SkTypeface>(new TestEmptyTypeface); }
19
20 protected:
21 TestEmptyTypeface() : SkTypeface(SkFontStyle(), true) {}
22
23 std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; }
24 sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
25 return sk_ref_sp(this);
26 }
27 std::unique_ptr<SkScalerContext> onCreateScalerContext(
28 const SkScalerContextEffects& effects, const SkDescriptor* desc) const override
29 {
30 return SkScalerContext::MakeEmpty(*const_cast<TestEmptyTypeface*>(this), effects, desc);
31 }
32 void onFilterRec(SkScalerContextRec*) const override {}
33 std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override {
34 return nullptr;
35 }
36 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override {}
37 void onCharsToGlyphs(SkSpan<const SkUnichar>, SkSpan<SkGlyphID> glyphs) const override {
38 sk_bzero(glyphs.data(), glyphs.size_bytes());
39 }
40 int onCountGlyphs() const override { return 0; }
41 void getPostScriptGlyphNames(SkString*) const override {}
42 void getGlyphToUnicodeMap(SkSpan<SkUnichar>) const override {}
43 int onGetUPEM() const override { return 0; }
44 class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
45 public:
46 bool next(SkTypeface::LocalizedString*) override { return false; }
47 };
48 void onGetFamilyName(SkString* familyName) const override { familyName->reset(); }
49 bool onGetPostScriptName(SkString*) const override { return false; }
50 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override {
51 return new EmptyLocalizedStrings;
52 }
53 bool onGlyphMaskNeedsCurrentColor() const override { return false; }
54 int onGetVariationDesignPosition(
55 SkSpan<SkFontArguments::VariationPosition::Coordinate>) const override {
56 return 0;
57 }
58 int onGetVariationDesignParameters(SkSpan<SkFontParameters::Variation::Axis>) const override {
59 return 0;
60 }
61 int onGetTableTags(SkSpan<SkFontTableTag>) const override { return 0; }
62 size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { return 0; }
63 };
64
65 #endif // TestEmptyTypeface_DEFINED