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_TEXGINE_DRAWING_TEXGINE_FONT_MANAGER_H 17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_MANAGER_H 18 19 #include <memory> 20 21 #include "drawing.h" 22 23 #include "texgine_font_style.h" 24 #include "texgine_font_style_set.h" 25 #include "texgine_typeface.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 namespace TextEngine { 30 class TexgineFontManager { 31 public: 32 TexgineFontManager(); 33 34 /* 35 * @brief Get default font manager 36 */ 37 static std::shared_ptr<TexgineFontManager> RefDefault(); 38 39 /* 40 * @brief Get the font manager 41 */ 42 std::shared_ptr<RSFontMgr> GetFontMgr() const; 43 44 void SetFontMgr(const std::shared_ptr<RSFontMgr> mgr); 45 46 /* 47 * @brief Use the system fallback to find a typeface for the given character. 48 * @param familyName The family names of user setting 49 * style The font style of user setting 50 * bcp47[] is a combination of ISO 639, 15924, and 3166-1 codes, 51 * so it is fine to just pass a ISO 639 here 52 * bcp47Count The length of bcp47[] 53 * character The character what you want to match typeface 54 * @return Will return nullptr if no family can be found 55 */ 56 std::shared_ptr<TexgineTypeface> MatchFamilyStyleCharacter(const std::string &familyName, 57 const TexgineFontStyle &style, const char* bcp47[], int bcp47Count, int32_t character); 58 59 /* 60 * @brief Get the font style set 61 * @param familyName The family names of user setting 62 * @return Never return nullptr, will return an empty set if the name is NULL 63 */ 64 std::shared_ptr<TexgineFontStyleSet> MatchFamily(const std::string &familyName); 65 66 std::shared_ptr<TexgineTypeface> MatchFamilyStyle(const std::string &familyName, 67 const TexgineFontStyle &style); 68 69 private: 70 std::shared_ptr<RSFontMgr> fontMgr_ = nullptr; 71 }; 72 } // namespace TextEngine 73 } // namespace Rosen 74 } // namespace OHOS 75 76 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_MANAGER_H 77