From 7adb95f4f2fa7783d2257948aaedb1cdb2dd4412 Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Thu, 16 Sep 2021 15:38:24 +0800 Subject: [PATCH] IssueNo:https://gitee.com/openharmony/graphic_ui/issues/I4AC8W Description:fix glyphNode problem Sig:graphic Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- frameworks/font/glyphs_manager.cpp | 11 +++++++---- frameworks/font/glyphs_manager.h | 2 +- frameworks/font/ui_font_bitmap.cpp | 6 +++--- interfaces/innerkits/font/ui_font_bitmap.h | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/frameworks/font/glyphs_manager.cpp b/frameworks/font/glyphs_manager.cpp index 49cc55a..b0aedf7 100755 --- a/frameworks/font/glyphs_manager.cpp +++ b/frameworks/font/glyphs_manager.cpp @@ -374,7 +374,7 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode) return node->advance; } -int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode) +int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontId) { if (bitmap == nullptr) { GRAPHIC_LOGE("GlyphsManager::GetBitmap invalid parameter"); @@ -384,9 +384,9 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* gl GRAPHIC_LOGE("GlyphsManager::GetBitmap fontId not set"); return INVALID_RET_VALUE; } - - const GlyphNode* node = glyphNode; - if (glyphNode == nullptr) { + const GlyphNode* node = GetGlyphNode(unicode); + while ((fontId != 0) && (node != nullptr) && (node->reserve != fontId)) { + SetCurrentFontId(fontId); node = GetGlyphNode(unicode); } if (node == nullptr) { @@ -394,6 +394,9 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* gl return INVALID_RET_VALUE; } + if ((fontId != 0) && (fontId_ != fontId)) { + SetCurrentFontId(fontId); + } uint32_t offset = curBitMapSectionStart_ + node->dataOff; uint32_t size = node->kernOff - node->dataOff; int32_t ret = lseek(fp_, offset, SEEK_SET); diff --git a/frameworks/font/glyphs_manager.h b/frameworks/font/glyphs_manager.h index 65d4fae..1583a54 100755 --- a/frameworks/font/glyphs_manager.h +++ b/frameworks/font/glyphs_manager.h @@ -41,7 +41,7 @@ public: const GlyphNode* GetGlyphNode(uint32_t unicode); - int8_t GetBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode = nullptr); + int8_t GetBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontId = 0); void SetRamBuffer(uintptr_t ramAddr); diff --git a/frameworks/font/ui_font_bitmap.cpp b/frameworks/font/ui_font_bitmap.cpp index 6a9f8b4..7b7dd7d 100644 --- a/frameworks/font/ui_font_bitmap.cpp +++ b/frameworks/font/ui_font_bitmap.cpp @@ -215,9 +215,9 @@ uint32_t UIFontBitmap::GetRamUsedLen(uint32_t textManagerRamUsed, uint32_t langF return dynamicFontRamUsed_ + textManagerRamUsed + bitmapRamUsed_ + langFontRamUsed; } -int8_t UIFontBitmap::GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode) +int8_t UIFontBitmap::GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontId) { - return dynamicFont_.GetBitmap(unicode, bitmap, glyphNode); + return dynamicFont_.GetBitmap(unicode, bitmap, fontId); } uint8_t* UIFontBitmap::GetCacheBitmap(uint8_t fontId, uint32_t unicode) @@ -289,7 +289,7 @@ uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint } uint32_t bitmapSize = glyphNode.kernOff - glyphNode.dataOff; bitmap = bitmapCache_->GetSpace(fontId, unicode, bitmapSize); - ret = dynamicFont_.GetBitmap(unicode, bitmap, &glyphNode); + ret = dynamicFont_.GetBitmap(unicode, bitmap, fontId); if (ret == RET_VALUE_OK) { return bitmap; } diff --git a/interfaces/innerkits/font/ui_font_bitmap.h b/interfaces/innerkits/font/ui_font_bitmap.h index 8aca8b0..e010ccc 100644 --- a/interfaces/innerkits/font/ui_font_bitmap.h +++ b/interfaces/innerkits/font/ui_font_bitmap.h @@ -47,7 +47,7 @@ protected: uint32_t GetBitmapRamUsed(); uint32_t GetDynamicFontRamUsed(); uint32_t GetRamUsedLen(uint32_t textManagerRamUsed, uint32_t langFontRamUsed); - int8_t GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, GlyphNode* glyphNode = nullptr); + int8_t GetDynamicFontBitmap(uint32_t unicode, uint8_t* bitmap, uint8_t fontId = 0); uint8_t* GetCacheBitmap(uint8_t fontId, uint32_t unicode); uint8_t* GetCacheSpace(uint8_t fontId, uint32_t unicode, uint32_t size); void PutCacheSpace(uint8_t* addr); -- GitLab