blob: bd630d349a1158a98a0df6eb6d5238b16d2a93b2 [file] [log] [blame]
/*
* Copyright 2018 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef TestEmptyTypeface_DEFINED
#define TestEmptyTypeface_DEFINED
#include "SkTypeface.h"
class TestEmptyTypeface : public SkTypeface {
public:
static sk_sp<SkTypeface> Make() { return sk_sp<SkTypeface>(new TestEmptyTypeface); }
protected:
TestEmptyTypeface() : SkTypeface(SkFontStyle(), true) {}
std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override {
return nullptr;
}
void onFilterRec(SkScalerContextRec*) const override {}
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override {
return nullptr;
}
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override {}
virtual int onCharsToGlyphs(const void* chars,
Encoding encoding,
uint16_t glyphs[],
int glyphCount) const override {
if (glyphs && glyphCount > 0) {
sk_bzero(glyphs, glyphCount * sizeof(glyphs[0]));
}
return 0;
}
int onCountGlyphs() const override { return 0; }
int onGetUPEM() const override { return 0; }
class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
public:
bool next(SkTypeface::LocalizedString*) override { return false; }
};
void onGetFamilyName(SkString* familyName) const override { familyName->reset(); }
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override {
return new EmptyLocalizedStrings;
}
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
int coordinateCount) const override {
return 0;
}
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
int parameterCount) const override {
return 0;
}
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { return 0; }
};
#endif // TestEmptyTypeface_DEFINED