提交 2fd31d2f 编写于 作者: O openharmony_ci 提交者: Gitee

!189 字体模块增加失败log信息

Merge pull request !189 from wangtiantian/log
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "font/glyphs_manager.h" #include "font/glyphs_manager.h"
#include "font/ui_font_builder.h" #include "font/ui_font_builder.h"
#include "gfx_utils/file.h" #include "gfx_utils/file.h"
#include "gfx_utils/graphic_log.h"
#include "securec.h" #include "securec.h"
namespace OHOS { namespace OHOS {
...@@ -62,6 +63,7 @@ int8_t GlyphsManager::GlyphNodeCacheInit() ...@@ -62,6 +63,7 @@ int8_t GlyphsManager::GlyphNodeCacheInit()
int32_t ret = read(fp_, indexCache_, size); int32_t ret = read(fp_, indexCache_, size);
if (ret != static_cast<int32_t>(size)) { if (ret != static_cast<int32_t>(size)) {
GRAPHIC_LOGE("GlyphsManager::GlyphNodeCacheInit read failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -137,6 +139,7 @@ GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode) ...@@ -137,6 +139,7 @@ GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode)
offset += key * sizeof(uint16_t); offset += key * sizeof(uint16_t);
idx = *(reinterpret_cast<uint16_t*>(curIndexCache_ + offset)); idx = *(reinterpret_cast<uint16_t*>(curIndexCache_ + offset));
if (idx == 0) { if (idx == 0) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile unicode not found");
return nullptr; return nullptr;
} }
} }
...@@ -144,11 +147,13 @@ GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode) ...@@ -144,11 +147,13 @@ GlyphNode* GlyphsManager::GetNodeFromFile(uint32_t unicode)
offset = curGlyphNodeSectionStart_ + (idx - 1) * sizeof(GlyphNode); offset = curGlyphNodeSectionStart_ + (idx - 1) * sizeof(GlyphNode);
int32_t ret = lseek(fp_, offset, SEEK_SET); int32_t ret = lseek(fp_, offset, SEEK_SET);
if (ret != static_cast<int32_t>(offset)) { if (ret != static_cast<int32_t>(offset)) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile lseek failed");
return nullptr; return nullptr;
} }
GlyphNode* node = GetNodeCacheSpace(unicode); GlyphNode* node = GetNodeCacheSpace(unicode);
ret = read(fp_, node, sizeof(GlyphNode)); ret = read(fp_, node, sizeof(GlyphNode));
if (ret < 0) { if (ret < 0) {
GRAPHIC_LOGE("GlyphsManager::GetNodeFromFile read failed");
return nullptr; return nullptr;
} }
...@@ -164,6 +169,7 @@ void GlyphsManager::SetRamBuffer(uintptr_t ramAddr) ...@@ -164,6 +169,7 @@ void GlyphsManager::SetRamBuffer(uintptr_t ramAddr)
int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
{ {
if (!isRamSet_) { if (!isRamSet_) {
GRAPHIC_LOGE("GlyphsManager::SetFile Ram not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -171,16 +177,19 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) ...@@ -171,16 +177,19 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
start_ = start; start_ = start;
int32_t ret = lseek(fp_, start_, SEEK_SET); int32_t ret = lseek(fp_, start_, SEEK_SET);
if (ret < 0) { if (ret < 0) {
GRAPHIC_LOGE("GlyphsManager::SetFile lseek failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
ret = read(fp_, &binHeader_, sizeof(binHeader_)); ret = read(fp_, &binHeader_, sizeof(binHeader_));
if (ret != sizeof(binHeader_)) { if (ret != sizeof(binHeader_)) {
GRAPHIC_LOGE("GlyphsManager::SetFile read failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (strncmp(binHeader_.fontMagic, FONT_MAGIC_NUMBER, FONT_MAGIC_NUM_LEN) != 0) { if (strncmp(binHeader_.fontMagic, FONT_MAGIC_NUMBER, FONT_MAGIC_NUM_LEN) != 0) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (binHeader_.fontNum > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) { if (binHeader_.fontNum > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) {
GRAPHIC_LOGE("GlyphsManager::SetFile data error, fontNum need less than max fontId");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -195,6 +204,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) ...@@ -195,6 +204,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
ret = read(fp_, fontHeaderCache_, size); ret = read(fp_, fontHeaderCache_, size);
if (ret != size) { if (ret != size) {
GRAPHIC_LOGE("GlyphsManager::SetFile read failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -209,6 +219,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) ...@@ -209,6 +219,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
bitMapSectionStart_ = glyphNodeSectionStart_ + size; bitMapSectionStart_ = glyphNodeSectionStart_ + size;
ret = GlyphNodeCacheInit(); ret = GlyphNodeCacheInit();
if (ret == RET_VALUE_OK) { if (ret == RET_VALUE_OK) {
GRAPHIC_LOGE("GlyphsManager::SetFile GlyphNodeCacheInit failed");
isFileSet_ = true; isFileSet_ = true;
} }
...@@ -220,9 +231,11 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId) ...@@ -220,9 +231,11 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
{ {
uint16_t fontIdx = 0; uint16_t fontIdx = 0;
if (!isFileSet_) { if (!isFileSet_) {
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId file not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (fontId > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) { if (fontId > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) {
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId fontId need less than max fontId");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (fontId_ == fontId) { if (fontId_ == fontId) {
...@@ -249,6 +262,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId) ...@@ -249,6 +262,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
isFontIdSet_ = false; isFontIdSet_ = false;
curFontHeader_ = nullptr; curFontHeader_ = nullptr;
fontId_ = UIFontBuilder::GetInstance()->GetBitmapFontIdMax(); fontId_ = UIFontBuilder::GetInstance()->GetBitmapFontIdMax();
GRAPHIC_LOGE("GlyphsManager::SetCurrentFontId fontId not found");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -271,6 +285,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId) ...@@ -271,6 +285,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
int32_t GlyphsManager::GetRamUsedLen() const int32_t GlyphsManager::GetRamUsedLen() const
{ {
if (!isFileSet_) { if (!isFileSet_) {
GRAPHIC_LOGE("GlyphsManager::GetRamUsedLen file not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
return ramUsedLen_; return ramUsedLen_;
...@@ -279,12 +294,15 @@ int32_t GlyphsManager::GetRamUsedLen() const ...@@ -279,12 +294,15 @@ int32_t GlyphsManager::GetRamUsedLen() const
int8_t GlyphsManager::GetFontVersion(char* version, uint8_t len) const int8_t GlyphsManager::GetFontVersion(char* version, uint8_t len) const
{ {
if (!isFileSet_ || (version == nullptr) || (len > FONT_VERSION_LEN)) { if (!isFileSet_ || (version == nullptr) || (len > FONT_VERSION_LEN)) {
GRAPHIC_LOGE("GlyphsManager::GetFontVersion invalid parameters");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (memset_s(version, len, 0, len) != EOK) { if (memset_s(version, len, 0, len) != EOK) {
GRAPHIC_LOGE("GlyphsManager::GetFontVersion memset_s failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (strcpy_s(version, len, binHeader_.fontVersion) != EOK) { if (strcpy_s(version, len, binHeader_.fontVersion) != EOK) {
GRAPHIC_LOGE("GlyphsManager::GetFontVersion strcpy_s failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
return RET_VALUE_OK; return RET_VALUE_OK;
...@@ -329,10 +347,12 @@ const GlyphNode* GlyphsManager::GetGlyphNode(uint32_t unicode) ...@@ -329,10 +347,12 @@ const GlyphNode* GlyphsManager::GetGlyphNode(uint32_t unicode)
int16_t GlyphsManager::GetFontHeight() const int16_t GlyphsManager::GetFontHeight() const
{ {
if (!isFontIdSet_) { if (!isFontIdSet_) {
GRAPHIC_LOGE("GlyphsManager::GetFontHeight fontId not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (curFontHeader_ == nullptr) { if (curFontHeader_ == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetFontHeight curFontHeader is nullptr");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -344,10 +364,12 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode) ...@@ -344,10 +364,12 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode)
const GlyphNode* node = nullptr; const GlyphNode* node = nullptr;
if (!isFontIdSet_) { if (!isFontIdSet_) {
GRAPHIC_LOGE("GlyphsManager::GetFontWidth fontId not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
node = GetGlyphNode(unicode); node = GetGlyphNode(unicode);
if (node == nullptr) { if (node == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetFontWidth node not found");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
return node->advance; return node->advance;
...@@ -356,14 +378,17 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode) ...@@ -356,14 +378,17 @@ int16_t GlyphsManager::GetFontWidth(uint32_t unicode)
int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap) int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap)
{ {
if (bitmap == nullptr) { if (bitmap == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap invalid parameter");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (!isFontIdSet_) { if (!isFontIdSet_) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap fontId not set");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
const GlyphNode* node = GetGlyphNode(unicode); const GlyphNode* node = GetGlyphNode(unicode);
if (node == nullptr) { if (node == nullptr) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap node not found");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -371,11 +396,13 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap) ...@@ -371,11 +396,13 @@ int8_t GlyphsManager::GetBitmap(uint32_t unicode, uint8_t* bitmap)
uint32_t size = node->kernOff - node->dataOff; uint32_t size = node->kernOff - node->dataOff;
int32_t ret = lseek(fp_, offset, SEEK_SET); int32_t ret = lseek(fp_, offset, SEEK_SET);
if (ret != static_cast<int32_t>(offset)) { if (ret != static_cast<int32_t>(offset)) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap lseek failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
int32_t readSize = read(fp_, bitmap, size); int32_t readSize = read(fp_, bitmap, size);
if (readSize != static_cast<int32_t>(size)) { if (readSize != static_cast<int32_t>(size)) {
GRAPHIC_LOGE("GlyphsManager::GetBitmap read failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "font/ui_font_adaptor.h" #include "font/ui_font_adaptor.h"
#include "font/ui_font_builder.h" #include "font/ui_font_builder.h"
#include "gfx_utils/file.h" #include "gfx_utils/file.h"
#include "gfx_utils/graphic_log.h"
#include "graphic_config.h" #include "graphic_config.h"
#if ENABLE_MULTI_FONT #if ENABLE_MULTI_FONT
#include "font/ui_multi_font_manager.h" #include "font/ui_multi_font_manager.h"
...@@ -68,6 +69,7 @@ uint8_t UIFontBitmap::GetFontWeight(uint8_t fontId) ...@@ -68,6 +69,7 @@ uint8_t UIFontBitmap::GetFontWeight(uint8_t fontId)
{ {
UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId); UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
if (fontParam == nullptr) { if (fontParam == nullptr) {
GRAPHIC_LOGE("UIFontBitmap::GetFontWeigh invalid fontId");
return 0; return 0;
} }
return fontParam->fontWeight; return fontParam->fontWeight;
...@@ -76,6 +78,7 @@ uint8_t UIFontBitmap::GetFontWeight(uint8_t fontId) ...@@ -76,6 +78,7 @@ uint8_t UIFontBitmap::GetFontWeight(uint8_t fontId)
int8_t UIFontBitmap::SetFontPath(const char* dpath, const char* spath) int8_t UIFontBitmap::SetFontPath(const char* dpath, const char* spath)
{ {
if (dpath == nullptr) { if (dpath == nullptr) {
GRAPHIC_LOGE("UIFontBitmap::SetFontPath invalid parameter");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
#ifdef _WIN32 #ifdef _WIN32
...@@ -84,12 +87,14 @@ int8_t UIFontBitmap::SetFontPath(const char* dpath, const char* spath) ...@@ -84,12 +87,14 @@ int8_t UIFontBitmap::SetFontPath(const char* dpath, const char* spath)
dynamicFontFd_ = open(dpath, O_RDONLY); dynamicFontFd_ = open(dpath, O_RDONLY);
#endif #endif
if (dynamicFontFd_ < 0) { if (dynamicFontFd_ < 0) {
GRAPHIC_LOGE("UIFontBitmap::SetFontPath file Open failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
dynamicFont_.SetRamBuffer(GetRamAddr()); dynamicFont_.SetRamBuffer(GetRamAddr());
uint32_t start = 0; uint32_t start = 0;
int32_t ret = dynamicFont_.SetFile(dynamicFontFd_, start); int32_t ret = dynamicFont_.SetFile(dynamicFontFd_, start);
if (ret == INVALID_RET_VALUE) { if (ret == INVALID_RET_VALUE) {
GRAPHIC_LOGE("GlyphsManager::SetFile failed");
close(dynamicFontFd_); close(dynamicFontFd_);
dynamicFontFd_ = -1; dynamicFontFd_ = -1;
return ret; return ret;
...@@ -168,6 +173,7 @@ int8_t UIFontBitmap::GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode) ...@@ -168,6 +173,7 @@ int8_t UIFontBitmap::GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode)
glyphNode = *node; glyphNode = *node;
return RET_VALUE_OK; return RET_VALUE_OK;
} }
GRAPHIC_LOGE("UIFontBitmap::GetGlyphNode get glyphNode failed");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -191,7 +197,6 @@ UITextLanguageFontParam* UIFontBitmap::GetFontInfo(uint8_t fontId) const ...@@ -191,7 +197,6 @@ UITextLanguageFontParam* UIFontBitmap::GetFontInfo(uint8_t fontId) const
return UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId); return UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
} }
uint32_t UIFontBitmap::GetBitmapRamUsed() uint32_t UIFontBitmap::GetBitmapRamUsed()
{ {
return bitmapRamUsed_; return bitmapRamUsed_;
...@@ -221,6 +226,7 @@ uint8_t* UIFontBitmap::GetCacheBitmap(uint8_t fontId, uint32_t unicode) ...@@ -221,6 +226,7 @@ uint8_t* UIFontBitmap::GetCacheBitmap(uint8_t fontId, uint32_t unicode)
if (bitmapCache_ != nullptr) { if (bitmapCache_ != nullptr) {
return bitmapCache_->GetBitmap(fontId, unicode); return bitmapCache_->GetBitmap(fontId, unicode);
} }
GRAPHIC_LOGE("UIFontBitmap::GetCacheBitmap invalid bitmapCache");
return nullptr; return nullptr;
} }
...@@ -229,6 +235,7 @@ uint8_t* UIFontBitmap::GetCacheSpace(uint8_t fontId, uint32_t unicode, uint32_t ...@@ -229,6 +235,7 @@ uint8_t* UIFontBitmap::GetCacheSpace(uint8_t fontId, uint32_t unicode, uint32_t
if (bitmapCache_ != nullptr) { if (bitmapCache_ != nullptr) {
return bitmapCache_->GetSpace(fontId, unicode, size); return bitmapCache_->GetSpace(fontId, unicode, size);
} }
GRAPHIC_LOGE("UIFontBitmap::GetCacheSpace invalid bitmapCache");
return nullptr; return nullptr;
} }
...@@ -237,6 +244,7 @@ void UIFontBitmap::PutCacheSpace(uint8_t* addr) ...@@ -237,6 +244,7 @@ void UIFontBitmap::PutCacheSpace(uint8_t* addr)
if (bitmapCache_ != nullptr) { if (bitmapCache_ != nullptr) {
bitmapCache_->PutSpace(addr); bitmapCache_->PutSpace(addr);
} }
GRAPHIC_LOGE("UIFontBitmap::PutCacheSpace invalid bitmapCache");
} }
int8_t UIFontBitmap::SetDynamicFontId(uint8_t fontId) int8_t UIFontBitmap::SetDynamicFontId(uint8_t fontId)
...@@ -256,6 +264,7 @@ int16_t UIFontBitmap::GetDynamicFontWidth(uint32_t unicode, uint8_t fontId) ...@@ -256,6 +264,7 @@ int16_t UIFontBitmap::GetDynamicFontWidth(uint32_t unicode, uint8_t fontId)
uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId) uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId)
{ {
if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) { if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) {
GRAPHIC_LOGE("UIFontBitmap::GetWidthInFontId fontId and unicode not match");
return nullptr; return nullptr;
} }
if (fontId != GetBaseFontId()) { if (fontId != GetBaseFontId()) {
...@@ -291,6 +300,7 @@ uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint ...@@ -291,6 +300,7 @@ uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint
int16_t UIFontBitmap::GetWidthInFontId(uint32_t unicode, uint8_t fontId) int16_t UIFontBitmap::GetWidthInFontId(uint32_t unicode, uint8_t fontId)
{ {
if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) { if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) {
GRAPHIC_LOGE("UIFontBitmap::GetWidthInFontId fontId and unicode not match");
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (fontId != GetBaseFontId()) { if (fontId != GetBaseFontId()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册