1a3e0fd82Sopenharmony_ci/* 2a3e0fd82Sopenharmony_ci * Copyright (c) 2020-2022 Huawei Device Co., Ltd. 3a3e0fd82Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4a3e0fd82Sopenharmony_ci * you may not use this file except in compliance with the License. 5a3e0fd82Sopenharmony_ci * You may obtain a copy of the License at 6a3e0fd82Sopenharmony_ci * 7a3e0fd82Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8a3e0fd82Sopenharmony_ci * 9a3e0fd82Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10a3e0fd82Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11a3e0fd82Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12a3e0fd82Sopenharmony_ci * See the License for the specific language governing permissions and 13a3e0fd82Sopenharmony_ci * limitations under the License. 14a3e0fd82Sopenharmony_ci */ 15a3e0fd82Sopenharmony_ci 16a3e0fd82Sopenharmony_ci#ifndef UI_FONT_BITMAP_H 17a3e0fd82Sopenharmony_ci#define UI_FONT_BITMAP_H 18a3e0fd82Sopenharmony_ci 19a3e0fd82Sopenharmony_ci#include "font/base_font.h" 20a3e0fd82Sopenharmony_ci#include "font/glyphs_manager.h" 21a3e0fd82Sopenharmony_ci#include "font/ui_font_cache.h" 22a3e0fd82Sopenharmony_ci#include "graphic_locker.h" 23a3e0fd82Sopenharmony_ci 24a3e0fd82Sopenharmony_cinamespace OHOS { 25a3e0fd82Sopenharmony_ciclass UIFontBitmap : public BaseFont { 26a3e0fd82Sopenharmony_cipublic: 27a3e0fd82Sopenharmony_ci UIFontBitmap(); 28a3e0fd82Sopenharmony_ci virtual ~UIFontBitmap(); 29a3e0fd82Sopenharmony_ci UIFontBitmap(const UIFontBitmap&) = delete; 30a3e0fd82Sopenharmony_ci UIFontBitmap& operator=(const UIFontBitmap&) noexcept = delete; 31a3e0fd82Sopenharmony_ci bool IsVectorFont() const override; 32a3e0fd82Sopenharmony_ci uint16_t 33a3e0fd82Sopenharmony_ci GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, uint16_t fontId, uint8_t size) const override; 34a3e0fd82Sopenharmony_ci int8_t SetFontPath(const char* path, FontType type) override; 35a3e0fd82Sopenharmony_ci uint16_t GetHeight(uint16_t fontId, uint8_t fontSize = 0) override; 36a3e0fd82Sopenharmony_ci uint16_t GetFontId(const char* ttfName, uint8_t fontSize = 0) const override; 37a3e0fd82Sopenharmony_ci int16_t GetWidth(uint32_t unicode, uint16_t fontId, uint8_t fontSize = 0) override; 38a3e0fd82Sopenharmony_ci uint8_t* GetBitmap(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId, uint8_t fontSize = 0) override; 39a3e0fd82Sopenharmony_ci int8_t GetFontHeader(FontHeader& fontHeader, uint16_t fontId, uint8_t fontSize = 0) override; 40a3e0fd82Sopenharmony_ci int8_t GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId, uint8_t fontSize = 0) override; 41a3e0fd82Sopenharmony_ci int8_t GetGlyphNodeFromFile(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId); 42a3e0fd82Sopenharmony_ci uint8_t GetFontWeight(uint16_t fontId) override; 43a3e0fd82Sopenharmony_ci int8_t GetFontVersion(FontType type, const char* path, char* version, uint8_t len) override; 44a3e0fd82Sopenharmony_ci int8_t SetCurrentLangId(uint8_t langId) override; 45a3e0fd82Sopenharmony_ci UITextLanguageFontParam* GetFontInfo(uint16_t fontId) const override; 46a3e0fd82Sopenharmony_ci void SetFontFileOffset(uint32_t offset) override; 47a3e0fd82Sopenharmony_ci uint16_t GetOffsetPosY(const char* text, uint16_t lineLength, bool& isEmoijLerge, 48a3e0fd82Sopenharmony_ci uint16_t fontId, uint8_t fontSize) override; 49a3e0fd82Sopenharmony_ci uint16_t GetLineMaxHeight(const char* text, uint16_t lineLength, uint16_t fontId, uint8_t fontSize, 50a3e0fd82Sopenharmony_ci uint16_t& letterIndex, SpannableString* spannableString) override; 51a3e0fd82Sopenharmony_ci bool IsEmojiFont(uint16_t fontId) override; 52a3e0fd82Sopenharmony_ci void SetPsramMemory(uintptr_t psramAddr, uint32_t psramLen) override; 53a3e0fd82Sopenharmony_ciprotected: 54a3e0fd82Sopenharmony_ci int8_t GetDynamicFontBitmap(uint32_t unicode, BufferInfo& bufInfo, uint16_t fontId); 55a3e0fd82Sopenharmony_ci uint8_t* GetCacheBitmap(uint16_t fontId, uint32_t unicode); 56a3e0fd82Sopenharmony_ci void PutCacheSpace(uint8_t* addr); 57a3e0fd82Sopenharmony_ci int16_t GetDynamicFontWidth(uint32_t unicode, uint16_t fontId); 58a3e0fd82Sopenharmony_ci uint32_t offset_; 59a3e0fd82Sopenharmony_ci GraphicMutex lock_; 60a3e0fd82Sopenharmony_ci 61a3e0fd82Sopenharmony_ciprivate: 62a3e0fd82Sopenharmony_ci uint8_t* SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId); 63a3e0fd82Sopenharmony_ci int16_t GetWidthInFontId(uint32_t unicode, uint16_t fontId); 64a3e0fd82Sopenharmony_ci#if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT 65a3e0fd82Sopenharmony_ci int8_t GetMultiGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint16_t fontId); 66a3e0fd82Sopenharmony_ci#endif 67a3e0fd82Sopenharmony_ci void CloseFontFd(); 68a3e0fd82Sopenharmony_ci void BitmapCacheInit(); 69a3e0fd82Sopenharmony_ci static constexpr uint8_t FONT_ID_MAX = 0xFF; 70a3e0fd82Sopenharmony_ci static constexpr uint8_t TTF_NAME_LEN_MAX = 128; 71a3e0fd82Sopenharmony_ci GlyphsManager dynamicFont_; 72a3e0fd82Sopenharmony_ci Graphic::Vector<int32_t> dynamicFontFd_; 73a3e0fd82Sopenharmony_ci}; 74a3e0fd82Sopenharmony_ci} // namespce OHOS 75a3e0fd82Sopenharmony_ci#endif // UI_FONT_BITMAP_H 76