TestEmptyTypeface.h 2.6 KB

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