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 SKFONTSTYLESET_OHOS_H 6 #define SKFONTSTYLESET_OHOS_H 7 8 #include "SkFontMgr.h" 9 10 #include "FontConfig_ohos.h" 11 #include "SkTypeface_ohos.h" 12 13 /*! 14 * \brief To implement SkFontStyleSet for ohos platform 15 */ 16 class SkFontStyleSet_OHOS : public SkFontStyleSet { 17 public: 18 SkFontStyleSet_OHOS(const std::shared_ptr<FontConfig_OHOS>& fontConfig, 19 int index, bool isFallback = false); 20 virtual ~SkFontStyleSet_OHOS() override = default; 21 virtual int count() override; 22 virtual void getStyle(int index, SkFontStyle* style, SkString* styleName) override; 23 virtual SkTypeface* createTypeface(int index) override; 24 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) override; 25 private: 26 std::shared_ptr<FontConfig_OHOS> fontConfig_ = nullptr; // the object of FontConfig_OHOS 27 int styleIndex = 0; // the index of the font style set 28 bool isFallback = false; // the flag of font style set. False for fallback family, true for generic family. 29 int tpCount = -1; // the typeface count in the font style set 30 }; 31 32 #endif /* SKFONTSTYLESET_OHOS_H */ 33