1 // Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SKTYPEFACE_OHOS_H 6 #define SKTYPEFACE_OHOS_H 7 8 #include "SkFontHost_FreeType_common.h" 9 #include "SkFontStyle.h" 10 #include "SkStream.h" 11 12 #include "FontInfo_ohos.h" 13 14 /*! 15 * \brief The implementation of SkTypeface for ohos platform 16 */ 17 class SkTypeface_OHOS : public SkTypeface_FreeType { 18 public: 19 SkTypeface_OHOS(const SkString& specifiedName, FontInfo& info); 20 explicit SkTypeface_OHOS(FontInfo& info); 21 virtual ~SkTypeface_OHOS() override = default; 22 const FontInfo* getFontInfo() const; 23 protected: 24 virtual std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override; 25 virtual std::unique_ptr<SkFontData> onMakeFontData() const override; 26 virtual void onGetFontDescriptor(SkFontDescriptor* descriptor, bool* isLocal) const override; 27 virtual void onGetFamilyName(SkString* familyName) const override; 28 virtual sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override; 29 private: 30 SkString specifiedName; // specified family name which is defined in the configuration file 31 std::unique_ptr<FontInfo> fontInfo; // the font information of this typeface 32 }; 33 34 #endif /* SKTYPEFACE_OHOS_H */ 35