1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ROSEN_MODULES_TEXGINE_SRC_VARIANT_FONT_STYLE_SET_H 17 #define ROSEN_MODULES_TEXGINE_SRC_VARIANT_FONT_STYLE_SET_H 18 19 #include <memory> 20 21 #include "dynamic_font_style_set.h" 22 #include "texgine_font_style_set.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 class VariantFontStyleSet { 28 public: 29 VariantFontStyleSet() noexcept(true) = default; 30 explicit VariantFontStyleSet(const std::shared_ptr<TexgineFontStyleSet> &tfss) noexcept(true); 31 explicit VariantFontStyleSet(const std::shared_ptr<DynamicFontStyleSet> &dfss) noexcept(true); 32 explicit VariantFontStyleSet(std::shared_ptr<TexgineFontStyleSet> &tfss) noexcept(true); 33 explicit VariantFontStyleSet(std::shared_ptr<DynamicFontStyleSet> &dfss) noexcept(true); 34 explicit VariantFontStyleSet(std::nullptr_t) noexcept(true); 35 36 std::shared_ptr<TexgineFontStyleSet> TryToTexgineFontStyleSet() const noexcept(false); 37 std::shared_ptr<DynamicFontStyleSet> TryToDynamicFontStyleSet() const noexcept(false); 38 39 int Count(); 40 void GetStyle(int index, std::shared_ptr<TexgineFontStyle> style, std::shared_ptr<TexgineString> name); 41 std::shared_ptr<TexgineTypeface> CreateTypeface(int index); 42 std::shared_ptr<TexgineTypeface> MatchStyle(std::shared_ptr<TexgineFontStyle> pattern); 43 private: 44 void CheckPointer(bool nullable = false) const noexcept(false); 45 46 std::shared_ptr<TexgineFontStyleSet> tfss_ = nullptr; 47 std::shared_ptr<DynamicFontStyleSet> dfss_ = nullptr; 48 }; 49 } // namespace TextEngine 50 } // namespace Rosen 51 } // namespace OHOS 52 53 #endif // ROSEN_MODULES_TEXGINE_SRC_VARIANT_FONT_STYLE_SET_H 54