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