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 SkTestEmptyTypeface_DEFINED 9 #define SkTestEmptyTypeface_DEFINED 10 11 #include "SkTypeface.h" 12 13 class SkTestEmptyTypeface : public SkTypeface { 14 public: Make()15 static sk_sp<SkTypeface> Make() { return sk_sp<SkTypeface>(new SkTestEmptyTypeface); } 16 protected: SkTestEmptyTypeface()17 SkTestEmptyTypeface() : SkTypeface(SkFontStyle(), true) { } 18 onOpenStream(int * ttcIndex)19 std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; } onMakeClone(const SkFontArguments & args)20 sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override { 21 return sk_ref_sp(this); 22 } onCreateScalerContext(const SkScalerContextEffects &,const SkDescriptor *)23 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, 24 const SkDescriptor*) const override { 25 return nullptr; 26 } onFilterRec(SkScalerContextRec *)27 void onFilterRec(SkScalerContextRec*) const override { } onGetAdvancedMetrics()28 std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override { 29 return nullptr; 30 } onGetFontDescriptor(SkFontDescriptor *,bool *)31 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { } onCharsToGlyphs(const void * chars,Encoding encoding,uint16_t glyphs[],int glyphCount)32 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, 33 uint16_t glyphs[], int glyphCount) const override { 34 if (glyphs && glyphCount > 0) { 35 sk_bzero(glyphs, glyphCount * sizeof(glyphs[0])); 36 } 37 return 0; 38 } onCountGlyphs()39 int onCountGlyphs() const override { return 0; } onGetUPEM()40 int onGetUPEM() const override { return 0; } 41 class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings { 42 public: next(SkTypeface::LocalizedString *)43 bool next(SkTypeface::LocalizedString*) override { return false; } 44 }; onGetFamilyName(SkString * familyName)45 void onGetFamilyName(SkString* familyName) const override { 46 familyName->reset(); 47 } onCreateFamilyNameIterator()48 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override { 49 return new EmptyLocalizedStrings; 50 } onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],int coordinateCount)51 int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], 52 int coordinateCount) const override 53 { 54 return 0; 55 } onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],int parameterCount)56 int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], 57 int parameterCount) const override 58 { 59 return 0; 60 } onGetTableTags(SkFontTableTag tags[])61 int onGetTableTags(SkFontTableTag tags[]) const override { return 0; } onGetTableData(SkFontTableTag,size_t,size_t,void *)62 size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { 63 return 0; 64 } 65 }; 66 67 68 #endif // SkTestEmptyTypeface_DEFINED 69