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: Make()18 static sk_sp<SkTypeface> Make() { return sk_sp<SkTypeface>(new TestEmptyTypeface); } 19 20 protected: TestEmptyTypeface()21 TestEmptyTypeface() : SkTypeface(SkFontStyle(), true) {} 22 onOpenStream(int * ttcIndex)23 std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; } onMakeClone(const SkFontArguments & args)24 sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override { 25 return sk_ref_sp(this); 26 } onCreateScalerContext(const SkScalerContextEffects & effects,const SkDescriptor * desc)27 std::unique_ptr<SkScalerContext> onCreateScalerContext( 28 const SkScalerContextEffects& effects, const SkDescriptor* desc) const override 29 { 30 return SkScalerContext::MakeEmpty( 31 sk_ref_sp(const_cast<TestEmptyTypeface*>(this)), effects, desc); 32 } onFilterRec(SkScalerContextRec *)33 void onFilterRec(SkScalerContextRec*) const override {} onGetAdvancedMetrics()34 std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override { 35 return nullptr; 36 } onGetFontDescriptor(SkFontDescriptor *,bool *)37 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override {} onCharsToGlyphs(const SkUnichar * chars,int count,SkGlyphID glyphs[])38 void onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const override { 39 sk_bzero(glyphs, count * sizeof(glyphs[0])); 40 } onCountGlyphs()41 int onCountGlyphs() const override { return 0; } getPostScriptGlyphNames(SkString *)42 void getPostScriptGlyphNames(SkString*) const override {} getGlyphToUnicodeMap(SkUnichar *)43 void getGlyphToUnicodeMap(SkUnichar*) const override {} onGetUPEM()44 int onGetUPEM() const override { return 0; } 45 class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings { 46 public: next(SkTypeface::LocalizedString *)47 bool next(SkTypeface::LocalizedString*) override { return false; } 48 }; onGetFamilyName(SkString * familyName)49 void onGetFamilyName(SkString* familyName) const override { familyName->reset(); } onGetPostScriptName(SkString *)50 bool onGetPostScriptName(SkString*) const override { return false; } onCreateFamilyNameIterator()51 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override { 52 return new EmptyLocalizedStrings; 53 } onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],int coordinateCount)54 int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], 55 int coordinateCount) const override { 56 return 0; 57 } onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],int parameterCount)58 int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], 59 int parameterCount) const override { 60 return 0; 61 } onGetTableTags(SkFontTableTag tags[])62 int onGetTableTags(SkFontTableTag tags[]) const override { return 0; } onGetTableData(SkFontTableTag,size_t,size_t,void *)63 size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { return 0; } 64 }; 65 66 #endif // TestEmptyTypeface_DEFINED 67