1 /* 2 * Copyright (c) 2020-2021 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 UI_MULTI_FONT_MANAGER_H 17 #define UI_MULTI_FONT_MANAGER_H 18 19 #include "graphic_config.h" 20 #include "font/ui_font_header.h" 21 #if ENABLE_MULTI_FONT 22 #include "gfx_utils/heap_base.h" 23 namespace OHOS { 24 class UIMultiFontManager : public HeapBase { 25 public: 26 UIMultiFontManager(const UIMultiFontManager &) = delete; 27 UIMultiFontManager& operator=(const UIMultiFontManager &) = delete; 28 UIMultiFontManager(UIMultiFontManager &&) noexcept = delete; 29 UIMultiFontManager& operator=(UIMultiFontManager &&) noexcept = delete; 30 31 /** 32 * @brief Get the Instance object 33 * 34 * @return UIMultiFontManager* 35 */ 36 static UIMultiFontManager* GetInstance(); 37 void ClearSearchFontList(); 38 int8_t SetSearchFontList(uint16_t fontListId, uint16_t* fontIds, uint8_t size); 39 int32_t GetSearchFontList(uint16_t fontListId, uint16_t** fontIds); 40 void UpdateScript(UITextLanguageFontParam& fonts); 41 bool IsNeedShaping(const char* text, uint8_t& ttfId, uint32_t& script); 42 uint16_t GetShapingFontId(const char* text, uint16_t fontId, uint8_t& ttfId, uint32_t& script); 43 #if ENABLE_SHAPING 44 uint32_t GetScriptByTtfId(uint8_t ttfId); 45 #endif 46 47 private: 48 /** 49 * @brief Construct a new UIMultiFontManager object 50 * 51 */ 52 UIMultiFontManager(); 53 54 /** 55 * @brief Destroy the UIMultiFontManager object 56 * 57 */ 58 ~UIMultiFontManager(); 59 int8_t AddNewFont(uint16_t fontListId, uint16_t* fontIds, int8_t size, uint8_t fontIndex); 60 int8_t UpdateFont(uint16_t fontListId, uint16_t* fontIds, uint8_t size); 61 int8_t IsShapingLetter(uint32_t unicode, uint8_t& ttfId); 62 struct FontIdNode { 63 uint16_t* fontIds = nullptr; 64 uint16_t size = 0; 65 }; 66 static constexpr uint8_t DEFAULT_SHAPING_ID = 1; 67 static constexpr const char *ARABIC_LANG = "Arabic"; 68 static constexpr const char *THAI_LANG = "Thai"; 69 static constexpr const char *MYAN_LANG = "Myanmar"; 70 static constexpr const char *DVCARI_LANG = "Devanagari"; 71 static constexpr const char *HBREW_LANG = "Hebrew"; 72 static constexpr const char *BENGALI_LANG = "Bengali"; 73 uint8_t arbicTtfId_; 74 uint8_t thaiTtfId_; 75 uint8_t myanmarTtfId_; 76 uint8_t devanagariTtfId_; 77 uint8_t hebrewTtfId_; 78 uint8_t bengaliTtfId_; 79 uint8_t topIndex_; 80 uint8_t* fontIdIndex_; 81 FontIdNode fontNodes_[MAX_FONT_SEARCH_NUM]; 82 }; 83 } 84 #endif 85 #endif 86