未验证 提交 807b529d 编写于 作者: O openharmony_ci 提交者: Gitee

!654 修改彩色字符判断逻辑 增加searchList多字体查询

Merge pull request !654 from pssea/OpenHarmony-2.2-Beta2
......@@ -455,9 +455,16 @@ bool TypedText::IsEmojiBase(uint32_t codePoint)
}
}
bool TypedText::IsColourWord(uint32_t fontId)
bool TypedText::IsColourWord(uint32_t codePoint, uint8_t fontId, uint8_t fontSize)
{
uint8_t weight = UIFont::GetInstance()->GetFontWeight(fontId);
GlyphNode glyphNode;
int8_t ret = UIFont::GetInstance()->GetGlyphNode(codePoint, glyphNode, fontId, fontSize);
if (ret != RET_VALUE_OK) {
GRAPHIC_LOGE("Failed to get glyphNode for color word");
return false;
}
uint8_t weight = UIFont::GetInstance()->GetFontWeight(glyphNode.fontId);
return (weight >= 16); // 16: rgb565->16 rgba8888->32 font with rgba
}
} // namespace OHOS
......@@ -90,7 +90,7 @@ public:
static bool IsEmojiModifier(uint32_t codePoint);
static bool IsEmojiBase(uint32_t codePoint);
static bool IsColourWord(uint32_t fontId);
static bool IsColourWord(uint32_t codePoint, uint8_t fontId, uint8_t fontSize);
private:
static bool GetWrapPoint(const char* text, uint32_t& breakPoint);
......
......@@ -42,7 +42,7 @@ uint16_t DrawLabel::DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInf
uint16_t retOffsetY = 0; // ret value elipse offsetY
bool isEmoijLerge = true;
uint16_t offsetPosY = 0;
offsetPosY = fontEngine->GetOffsetPosY(labelLine.text, labelLine.lineLength, isEmoijLerge, labelLine.fontId,
offsetPosY = fontEngine->GetOffsetPosY(labelLine.text, labelLine.lineLength, isEmoijLerge, labelLine.fontId,
labelLine.fontSize);
uint8_t maxLetterSize = GetLineMaxLetterSize(labelLine.text, labelLine.lineLength, labelLine.fontId,
labelLine.fontSize, letterIndex, labelLine.sizeSpans);
......@@ -86,7 +86,7 @@ uint16_t DrawLabel::DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInf
labelLine.style.lineSpace_,
havebackgroundColor,
backgroundColor};
if (TypedText::IsColourWord(letterInfo.fontId)) {
if (TypedText::IsColourWord(letter, fontId, fontSize)) {
if (!isEmoijLerge) {
letterInfo.offsetY = offsetPosY;
}
......@@ -118,7 +118,7 @@ uint8_t DrawLabel::GetLineMaxLetterSize(const char* text, uint16_t lineLength, u
uint8_t maxLetterSize = fontSize;
while (i < lineLength) {
unicode = TypedText::GetUTF8Next(text, i, i);
if (TypedText::IsColourWord(fontId)) {
if (TypedText::IsColourWord(unicode, fontId, fontSize)) {
letterIndex++;
continue;
}
......
......@@ -100,6 +100,31 @@ uint8_t* UIFont::GetBitmap(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontI
return nullptr;
}
int8_t UIFont::GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId, uint8_t fontSize)
{
int8_t result = instance_->GetGlyphNode(unicode, glyphNode, fontId, fontSize);
if (result == RET_VALUE_OK) {
return result;
}
#if ENABLE_MULTI_FONT
uint8_t* searchLists = nullptr;
int8_t listSize = UIMultiFontManager::GetInstance()->GetSearchFontList(fontId, &searchLists);
if ((searchLists == nullptr) || (listSize == 0)) {
return INVALID_RET_VALUE;
}
int8_t currentIndex = 0;
do {
result = instance_->GetGlyphNode(unicode, glyphNode, searchLists[currentIndex], fontSize);
if (result == RET_VALUE_OK) {
return result;
}
currentIndex++;
} while ((currentIndex < listSize) && (searchLists != nullptr));
#endif
return INVALID_RET_VALUE;
}
uint16_t UIFont::GetWidth(uint32_t unicode, uint8_t fontId, uint8_t fontSize, uint8_t shapingId)
{
int16_t result;
......
......@@ -151,30 +151,29 @@ int8_t UIFontBitmap::GetFontHeader(FontHeader& fontHeader, uint8_t fontId, uint8
#if ENABLE_MULTI_FONT
int8_t UIFontBitmap::GetMultiGlyphNode( uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId)
{
if (TypedText::IsColourWord(fontId)) {
int8_t ret;
uint8_t* searchLists = nullptr;
//uint8_t baseId = GetBaseFontId();
int8_t listSize = UIMultiFontManager::GetInstance()->GetSearchFontList(fontId, &searchLists);
int8_t currentIndex = 0;
if ((searchLists == nullptr) || (listSize == 0)) {
return INVALID_RET_VALUE;
}
do {
ret = GetGlyphNode(unicode, glyphNode, searchLists[currentIndex]);
if (ret != INVALID_RET_VALUE) {
return ret;
}
// switch to next search List
currentIndex++;
} while ((currentIndex < listSize) && (searchLists != nullptr));
return INVALID_RET_VALUE;
} else {
return GetGlyphNode(unicode, glyphNode, fontId);
int8_t ret = GetGlyphNode(unicode, glyphNode, fontId);
if (ret == RET_VALUE_OK) {
return ret;
}
uint8_t* searchLists = nullptr;
int8_t listSize = UIMultiFontManager::GetInstance()->GetSearchFontList(fontId, &searchLists);
int8_t currentIndex = 0;
if ((searchLists == nullptr) || (listSize == 0)) {
return INVALID_RET_VALUE;
}
do {
ret = GetGlyphNode(unicode, glyphNode, searchLists[currentIndex]);
if (ret != INVALID_RET_VALUE) {
return ret;
}
// switch to next search List
currentIndex++;
} while ((currentIndex < listSize) && (searchLists != nullptr));
return INVALID_RET_VALUE;
}
#endif
int8_t UIFontBitmap::GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId, uint8_t fontSize)
{
const GlyphNode* node = dynamicFont_.GetGlyphNode(unicode, fontId);
......@@ -332,7 +331,8 @@ uint16_t UIFontBitmap::GetOffsetPosY(const char *text, uint16_t lineLength,
uint8_t ret = GetGlyphNode(unicode, glyphNode, fontId, fontSize);
#endif
if (ret == RET_VALUE_OK) {
if (TypedText::IsColourWord(fontId)) {
uint8_t weight = GetFontWeight(glyphNode.fontId);
if (weight >= 16) { // 16: bit rgb565 rgba8888
emoijMaxNode = glyphNode.rows > emoijMaxNode.rows ? glyphNode : emoijMaxNode;
emojiNum++;
} else {
......
......@@ -341,7 +341,7 @@ int16_t UIFontVector::GetWidth(uint32_t unicode, uint8_t fontId, uint8_t fontSiz
FaceInfo faceInfo = {};
int8_t ret = INVALID_RET_VALUE;
if (TypedText::IsColourWord(fontId)) {
if (TypedText::IsColourWord(unicode, fontId, fontSize)) {
ret = LoadGlyphIntoFace(fontId, unicode, faceInfo.face);
......@@ -695,7 +695,8 @@ uint16_t UIFontVector::GetOffsetPosY(const char *text, uint16_t lineLength, bool
unicode = TypedText::GetUTF8Next(text, i, i);
uint8_t ret = GetGlyphNode(unicode, glyphNode, fontId, fontSize);
if (ret == RET_VALUE_OK) {
if (TypedText::IsColourWord(fontId)) {
uint8_t weight = GetFontWeight(glyphNode.fontId);
if (weight >= 16) { // 16: bit rgb565 rgba8888
emojiMaxNode = glyphNode.rows > emojiMaxNode.rows ? glyphNode : emojiMaxNode;
emojiNum++;
} else {
......@@ -740,7 +741,7 @@ uint16_t UIFontVector::GetLineMaxHeight(const char *text, uint16_t lineLength, u
uint16_t maxHeight = GetHeight(fontId, fontSize);
while (i < lineLength) {
unicode = TypedText::GetUTF8Next(text, i, i);
TypedText::IsColourWord(fontId) ? emojiNum++ : textNum++;
TypedText::IsColourWord(unicode, fontId, fontSize) ? emojiNum++ : textNum++;
loopNum++;
if (sizeSpans != nullptr && sizeSpans[letterIndex].isSizeSpan) {
uint16_t spannableHeight = 0;
......
......@@ -130,12 +130,12 @@ uint32_t UILineBreakEngine::GetNextLineAndWidth(const char* text, uint8_t fontId
preIndex = byteIdx;
continue;
}
if (isAllCanBreak || IsBreakPos(unicode, fontId, state)) {
if (!TypedText::IsColourWord(fontId)) {
if (isAllCanBreak || IsBreakPos(unicode, fontId, fontSize, state)) {
if (!TypedText::IsColourWord(unicode, fontId, fontSize)) {
state = LINE_BREAK_STATE_START;
}
// Accumulates the status value from the current character.
IsBreakPos(unicode, fontId, state);
IsBreakPos(unicode, fontId, fontSize, state);
lastIndex = preIndex;
lastWidth = curWidth;
}
......@@ -185,9 +185,9 @@ int16_t UILineBreakEngine::GetLetterWidth(uint32_t unicode, uint16_t& letterInde
}
}
bool UILineBreakEngine::IsBreakPos(uint32_t unicode, uint8_t fontId, int32_t& state)
bool UILineBreakEngine::IsBreakPos(uint32_t unicode, uint8_t fontId, uint8_t fontSize, int32_t& state)
{
if (TypedText::IsColourWord(fontId)) {
if (TypedText::IsColourWord(unicode, fontId, fontSize)) {
return true;
}
if ((unicode > TypedText::MAX_UINT16_HIGH_SCOPE) || (stateTbl_ == nullptr) || (lineBreakTrie_ == nullptr)) {
......
......@@ -118,7 +118,7 @@ public:
uint16_t& letterIndex,
SizeSpan* sizeSpans,
uint16_t len = 0xFFFF);
bool IsBreakPos(uint32_t unicode, uint8_t fontId, int32_t& state);
bool IsBreakPos(uint32_t unicode, uint8_t fontId, uint8_t fontSize, int32_t& state);
private:
UILineBreakEngine()
......
......@@ -113,6 +113,8 @@ public:
*/
uint8_t* GetBitmap(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId, uint8_t fontSize, uint8_t shapingFont);
int8_t GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId, uint8_t fontSize);
/**
* @brief Indicates whether the current font library is a vector font library.
* @return uint8_t: 0 BitmapFont 1 VectorFont
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册