1 /*
2 * Copyright (c) 2020-2022 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 #include "common/typed_text.h"
17 #include "font/ui_font.h"
18 #include "font/ui_font_adaptor.h"
19 #include "gfx_utils/graphic_log.h"
20 #include "gfx_utils/mem_api.h"
21 #include "gfx_utils/transform.h"
22 #if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT
23 #include "font/ui_multi_font_manager.h"
24 #endif
25
26 namespace OHOS {
27 #ifndef _FONT_TOOL
GetTextSize(const char * text,uint16_t fontId,uint8_t fontSize,int16_t letterSpace,int16_t lineHeight,int16_t maxWidth,int8_t lineSpace,SizeSpan * sizeSpans)28 Point TypedText::GetTextSize(const char* text, uint16_t fontId, uint8_t fontSize, int16_t letterSpace,
29 int16_t lineHeight, int16_t maxWidth, int8_t lineSpace, SizeSpan* sizeSpans)
30 {
31 Point size{0, 0};
32
33 if (text == nullptr) {
34 GRAPHIC_LOGE("TypedText::GetTextSize invalid parameter");
35 return size;
36 }
37
38 uint32_t lineBegin = 0;
39 uint32_t newLineBegin = 0;
40 uint16_t letterHeight = UIFont::GetInstance()->GetHeight(fontId, fontSize);
41 bool hasLineHeight = (lineHeight != 0);
42 uint16_t curLineHeight;
43 uint16_t letterIndex = 0;
44 int16_t curLetterHeight = 0;
45 while (text[lineBegin] != '\0') {
46 int16_t lineWidth = maxWidth;
47 newLineBegin += UIFontAdaptor::GetNextLineAndWidth(&text[lineBegin], fontId, fontSize, letterSpace, lineWidth,
48 curLetterHeight, letterIndex, sizeSpans);
49 if (!hasLineHeight) {
50 curLineHeight = curLetterHeight + lineSpace;
51 } else {
52 curLineHeight = lineHeight;
53 }
54
55 if (newLineBegin == lineBegin) {
56 break;
57 }
58 size.y += curLineHeight;
59 size.x = MATH_MAX(lineWidth, size.x);
60 lineBegin = newLineBegin;
61 }
62
63 if ((lineBegin != 0) && ((text[lineBegin - 1] == '\n') || (text[lineBegin - 1] == '\r'))) {
64 if (!hasLineHeight) {
65 size.y += letterHeight + lineSpace;
66 } else {
67 size.y += lineHeight;
68 }
69 }
70
71 if (!hasLineHeight) {
72 if (size.y == 0) {
73 size.y = letterHeight;
74 } else {
75 size.y -= lineSpace;
76 }
77 } else {
78 if (size.y == 0) {
79 size.y = lineHeight;
80 }
81 }
82 size.y += EXTRA_HEIGHT;
83 return size;
84 }
85
GetArcTextRect(const char * text,uint16_t fontId,uint8_t fontSize,const Point & arcCenter,int16_t letterSpace,TextOrientation orientation,const ArcTextInfo & arcTextInfo)86 Rect TypedText::GetArcTextRect(const char* text,
87 uint16_t fontId,
88 uint8_t fontSize,
89 const Point& arcCenter,
90 int16_t letterSpace,
91 TextOrientation orientation,
92 const ArcTextInfo& arcTextInfo)
93 {
94 if ((text == nullptr) || (arcTextInfo.lineStart == arcTextInfo.lineEnd) || (arcTextInfo.radius == 0)) {
95 GRAPHIC_LOGE("TypedText::GetArcTextRect invalid parameter\n");
96 return Rect();
97 }
98
99 uint16_t letterHeight = UIFont::GetInstance()->GetHeight(fontId, fontSize);
100 bool xorFlag = (orientation == TextOrientation::INSIDE) ^ (arcTextInfo.direct == TEXT_DIRECT_LTR);
101 float posX = 0;
102 float posY = 0;
103 uint32_t i = arcTextInfo.lineStart;
104 float angle = arcTextInfo.startAngle;
105 Rect rect;
106 Rect rectLetter;
107 TransformMap transform;
108 while (i < arcTextInfo.lineEnd) {
109 uint32_t tmp = i;
110 uint32_t letter = GetUTF8Next(text, tmp, i);
111 if (letter == 0) {
112 continue;
113 }
114 if ((letter == '\r') || (letter == '\n')) {
115 break;
116 }
117 uint16_t letterWidth = UIFont::GetInstance()->GetWidth(letter, fontId, fontSize, 0);
118 if (tmp == arcTextInfo.lineStart) {
119 angle += xorFlag ? GetAngleForArcLen(static_cast<float>(letterWidth), letterHeight, arcTextInfo.radius,
120 arcTextInfo.direct, orientation)
121 : 0;
122 GetArcLetterPos(arcCenter, arcTextInfo.radius, angle, posX, posY);
123 rect.SetPosition(MATH_ROUND(posX), MATH_ROUND(posY));
124 }
125 rectLetter.SetPosition(MATH_ROUND(posX), MATH_ROUND(posY));
126 rectLetter.Resize(letterWidth, letterHeight);
127 transform.SetTransMapRect(rectLetter);
128
129 uint16_t arcLen = letterWidth + letterSpace;
130 if (arcLen == 0) {
131 continue;
132 }
133 float incrementAngle = GetAngleForArcLen(static_cast<float>(arcLen), letterHeight, arcTextInfo.radius,
134 arcTextInfo.direct, orientation);
135 float rotateAngle =
136 (orientation == TextOrientation::INSIDE) ? angle : (angle - SEMICIRCLE_IN_DEGREE);
137 // 2: letterWidth's half
138 float fineTuningAngle = incrementAngle * (static_cast<float>(letterWidth) / (2 * arcLen));
139 rotateAngle += (xorFlag ? -fineTuningAngle : fineTuningAngle);
140
141 transform.Rotate(MATH_ROUND(rotateAngle), Vector2<float>(0, 0));
142 rect.Join(rect, transform.GetBoxRect());
143
144 angle += incrementAngle;
145 GetArcLetterPos(arcCenter, arcTextInfo.radius, angle, posX, posY);
146 }
147 return rect;
148 }
149
GetAngleForArcLen(float len,uint16_t height,uint16_t radius,UITextLanguageDirect direct,TextOrientation orientation)150 float TypedText::GetAngleForArcLen(float len,
151 uint16_t height,
152 uint16_t radius,
153 UITextLanguageDirect direct,
154 TextOrientation orientation)
155 {
156 if (radius == 0) {
157 return 0;
158 }
159 float realRadius =
160 static_cast<float>((orientation == TextOrientation::OUTSIDE) ? (radius + height) : radius);
161 float angle = static_cast<float>(len * SEMICIRCLE_IN_DEGREE) / (UI_PI * realRadius);
162 return (direct == TEXT_DIRECT_LTR) ? angle : -angle;
163 }
164
GetArcLetterPos(const Point & arcCenter,uint16_t radius,float angle,float & posX,float & posY)165 void TypedText::GetArcLetterPos(const Point& arcCenter, uint16_t radius, float angle, float& posX, float& posY)
166 {
167 posX = arcCenter.x + (static_cast<float>(radius) * Sin(angle));
168 posY = arcCenter.y - (static_cast<float>(radius) * Sin(angle + QUARTER_IN_DEGREE));
169 }
170
GetNextLine(const char * text,uint16_t fontId,uint8_t fontSize,int16_t letterSpace,int16_t maxWidth)171 uint32_t TypedText::GetNextLine(const char* text, uint16_t fontId, uint8_t fontSize, int16_t letterSpace,
172 int16_t maxWidth)
173 {
174 uint32_t index = 0;
175 if ((text == nullptr) || (GetWrapPoint(text, index) &&
176 (TypedText::GetTextWidth(text, fontId, fontSize, index, letterSpace) <= maxWidth))) {
177 return index;
178 }
179 uint32_t lastBreakPos = 0;
180 uint32_t tmp = 0;
181 while (true) {
182 int16_t curW = TypedText::GetTextWidth(text, fontId, fontSize, index, letterSpace);
183 if (curW > maxWidth) {
184 index = lastBreakPos;
185 if (lastBreakPos == 0) {
186 curW = 0;
187 uint32_t i = 0;
188 while (text[i] != '\0') {
189 tmp = i;
190 uint32_t letter = TypedText::GetUTF8Next(text, tmp, i);
191 uint16_t letterWidth = UIFont::GetInstance()->GetWidth(letter, fontId, fontSize, 0);
192 curW += letterWidth;
193 if (letterWidth > 0) {
194 curW += letterSpace;
195 }
196 if (curW > maxWidth) {
197 index = lastBreakPos;
198 return index;
199 }
200 lastBreakPos = i;
201 }
202 }
203 break;
204 }
205 if ((index > 0) && (index < strlen(text)) && ((text[index - 1] == '\r') || (text[index - 1] == '\n'))) {
206 break;
207 }
208 lastBreakPos = index;
209 if (text[index] == '\0') {
210 break;
211 }
212 if (GetWrapPoint(text + index, tmp) &&
213 (TypedText::GetTextWidth(text, fontId, fontSize, index + tmp, letterSpace) <= maxWidth)) {
214 return index + tmp;
215 }
216 index += tmp;
217 if (lastBreakPos == index) {
218 break;
219 }
220 }
221 return index;
222 }
223
GetWrapPoint(const char * text,uint32_t & breakPoint)224 bool TypedText::GetWrapPoint(const char* text, uint32_t& breakPoint)
225 {
226 breakPoint = 0;
227 uint32_t j = 0;
228 if (text == nullptr) {
229 return true;
230 }
231
232 while (text[breakPoint] != '\0') {
233 uint32_t letter = GetUTF8Next(text, breakPoint, j);
234 breakPoint = j;
235 if ((letter == ' ') || (letter == '.') || (letter == ',') || (letter == '!') || (letter == '=')
236 || (letter == '?')) {
237 return false;
238 }
239 if (letter == '\n') {
240 return true;
241 }
242 if ((letter == '\r') && (GetUTF8Next(text, breakPoint, j) == '\n')) {
243 breakPoint = j;
244 return true;
245 }
246 }
247 return false;
248 }
249
GetTextWidth(const char * text,uint16_t fontId,uint8_t fontSize,uint16_t length,int16_t letterSpace)250 int16_t TypedText::GetTextWidth(const char* text, uint16_t fontId, uint8_t fontSize, uint16_t length,
251 int16_t letterSpace)
252 {
253 if ((text == nullptr) || (length == 0) || (length > strlen(text))) {
254 GRAPHIC_LOGE("TypedText::GetTextWidth invalid parameter\n");
255 return 0;
256 }
257
258 uint32_t i = 0;
259 uint16_t width = 0;
260
261 while (i < length) {
262 uint32_t letter = GetUTF8Next(text, i, i);
263 if ((letter == 0) || (letter == '\n') || (letter == '\r')) {
264 continue;
265 }
266 uint16_t charWidth = UIFont::GetInstance()->GetWidth(letter, fontId, fontSize, 0);
267 width += charWidth + letterSpace;
268 }
269 if (width > 0) {
270 width -= letterSpace;
271 }
272 return width;
273 }
274 #endif // _FONT_TOOL
275
GetUTF8OneCharacterSize(const char * str)276 uint8_t TypedText::GetUTF8OneCharacterSize(const char* str)
277 {
278 if (str == nullptr) {
279 return 0;
280 }
281 if ((str[0] & 0x80) == 0) {
282 return 1;
283 } else if ((str[0] & 0xE0) == 0xC0) {
284 return 2; // 2: 2 bytes
285 } else if ((str[0] & 0xF0) == 0xE0) {
286 return 3; // 3: 3 bytes
287 } else if ((str[0] & 0xF8) == 0xF0) {
288 return 4; // 4: 4 bytes
289 }
290 return 0;
291 }
292
GetUTF8Next(const char * text,uint32_t i,uint32_t & j)293 uint32_t TypedText::GetUTF8Next(const char* text, uint32_t i, uint32_t& j)
294 {
295 uint32_t unicode = 0;
296 if (text == nullptr) {
297 GRAPHIC_LOGE("text invalid parameter");
298 return 0;
299 }
300
301 j = i;
302 uint8_t lettetSize = GetUTF8OneCharacterSize(text + i);
303 switch (lettetSize) {
304 case 1:
305 unicode = text[j];
306 break;
307 case 2: // 2: letter size
308 unicode = static_cast<uint32_t>(text[j] & 0x1F) << UTF8_TO_UNICODE_SHIFT1;
309 j++;
310 if ((text[j] & 0xC0) != 0x80) {
311 return 0;
312 }
313 unicode += (text[j] & 0x3F);
314 break;
315 case 3: // 3: letter size
316 unicode = static_cast<uint32_t>(text[j] & 0x0F) << UTF8_TO_UNICODE_SHIFT2;
317 unicode += static_cast<uint32_t>(text[++j] & 0x3F) << UTF8_TO_UNICODE_SHIFT1;
318 unicode += (text[++j] & 0x3F);
319 break;
320 case 4: // 4: letter size
321 unicode = static_cast<uint32_t>(text[j] & 0x07) << UTF8_TO_UNICODE_SHIFT3;
322 unicode += static_cast<uint32_t>(text[++j] & 0x3F) << UTF8_TO_UNICODE_SHIFT2;
323 unicode += static_cast<uint32_t>(text[++j] & 0x3F) << UTF8_TO_UNICODE_SHIFT1;
324 unicode += text[++j] & 0x3F;
325 break;
326 default:
327 break;
328 }
329 j++;
330 return unicode;
331 }
332
GetByteIndexFromUTF8Id(const char * text,uint32_t utf8Id)333 uint32_t TypedText::GetByteIndexFromUTF8Id(const char* text, uint32_t utf8Id)
334 {
335 if (text == nullptr) {
336 GRAPHIC_LOGE("TypedText::GetByteIndexFromUTF8Id text invalid parameter\n");
337 return 0;
338 }
339 uint32_t byteIndex = 0;
340 for (uint32_t i = 0; i < utf8Id; i++) {
341 byteIndex += GetUTF8OneCharacterSize(&text[byteIndex]);
342 }
343
344 return byteIndex;
345 }
346
GetUTF8CharacterSize(const char * text,uint32_t byteIndex)347 uint32_t TypedText::GetUTF8CharacterSize(const char* text, uint32_t byteIndex)
348 {
349 uint32_t i = 0;
350 uint32_t size = 0;
351
352 if (text == nullptr) {
353 GRAPHIC_LOGE("TypedText::GetUTF8CharacterSize text invalid parameter\n");
354 return 0;
355 }
356 while ((i < byteIndex) && (text[i] != '\0')) {
357 GetUTF8Next(text, i, i);
358 size++;
359 }
360
361 return size;
362 }
363
Utf8ToUtf16(const char * utf8Str,uint16_t * utf16Str,uint32_t len)364 void TypedText::Utf8ToUtf16(const char* utf8Str, uint16_t* utf16Str, uint32_t len)
365 {
366 if ((utf8Str == nullptr) || (utf16Str == nullptr)) {
367 GRAPHIC_LOGE("utf8Str or u16Str is null");
368 return;
369 }
370
371 uint32_t i = 0;
372 uint32_t cnt = 0;
373 while (utf8Str[i] != '\0') {
374 uint32_t unicode = GetUTF8Next(utf8Str, i, i);
375 if (cnt < len) {
376 if (unicode <= MAX_UINT16_LOW_SCOPE) {
377 utf16Str[cnt] = (unicode & MAX_UINT16_LOW_SCOPE);
378 } else if (unicode <= MAX_UINT16_HIGH_SCOPE) {
379 if (cnt + 1 < len) {
380 utf16Str[cnt] = static_cast<uint16_t>(UTF16_LOW_PARAM + (unicode & UTF16_LOW_MASK)); // low
381 cnt++;
382 utf16Str[cnt] = static_cast<uint16_t>(UTF16_HIGH_PARAM1 + (unicode >> UTF16_HIGH_SHIFT) -
383 UTF16_HIGH_PARAM2); // high
384 }
385 } else {
386 GRAPHIC_LOGE("Invalid unicode");
387 return;
388 }
389 cnt++;
390 }
391 }
392 }
393
Utf16ToUtf32Word(const uint16_t * src,uint32_t & des)394 int32_t TypedText::Utf16ToUtf32Word(const uint16_t* src, uint32_t& des)
395 {
396 if (!src) {
397 return -1; // invalid
398 }
399
400 uint16_t w1 = src[0];
401 uint16_t flag = w1 & UTF16_MASK;
402 if (flag == UTF16_LOW_PARAM) {
403 uint16_t w2 = src[1];
404 flag = w2 & UTF16_MASK;
405 if (flag == UTF16_HIGH_PARAM1) {
406 des = (w1 & UTF16_LOW_MASK) + (((w2 & UTF16_LOW_MASK) + UTF16_HIGH_PARAM2) << UTF16_HIGH_SHIFT);
407 return 2; // 2 : used length
408 }
409 return -1;
410 } else if (flag == UTF16_HIGH_PARAM1) {
411 uint16_t w2 = src[1];
412 flag = w2 & UTF16_MASK;
413 if (flag == UTF16_LOW_PARAM) {
414 des = (w2 & UTF16_LOW_MASK) + (((w1 & UTF16_LOW_MASK) + UTF16_HIGH_PARAM2) << UTF16_HIGH_SHIFT);
415 return 2; // 2 : used length
416 }
417 return -1;
418 } else {
419 des = w1;
420 return 1;
421 }
422 }
423
Utf16ToUtf32(const uint16_t * utf16Str,uint32_t * utf32Str,uint32_t len)424 uint16_t TypedText::Utf16ToUtf32(const uint16_t* utf16Str, uint32_t* utf32Str, uint32_t len)
425 {
426 if (!utf16Str || (!utf32Str)) {
427 return 0;
428 }
429
430 uint16_t utf32Len = 0;
431 while (len > 0) {
432 uint32_t tmp;
433 int32_t length = Utf16ToUtf32Word(utf16Str, tmp);
434 if (length == -1) {
435 utf32Str = nullptr;
436 return 0;
437 }
438 len -= length;
439 if (utf32Str) {
440 (*utf32Str) = tmp;
441 ++utf32Str;
442 ++utf32Len;
443 }
444 utf16Str += length;
445 }
446 return utf32Len;
447 }
448
GetUtf16Cnt(const char * utf8Str)449 uint32_t TypedText::GetUtf16Cnt(const char* utf8Str)
450 {
451 if (utf8Str == nullptr) {
452 GRAPHIC_LOGE("text invalid parameter");
453 return 0;
454 }
455 uint32_t len = 0;
456 uint32_t i = 0;
457
458 while (utf8Str[i] != '\0') {
459 uint32_t unicode = GetUTF8Next(utf8Str, i, i);
460 if (unicode <= MAX_UINT16_LOW_SCOPE) {
461 len++;
462 } else if (unicode <= MAX_UINT16_HIGH_SCOPE) {
463 len += 2; // 2: low and high, two uint16_t numbers
464 } else {
465 GRAPHIC_LOGE("Invalid unicode");
466 return 0;
467 }
468 }
469 return len;
470 }
471
IsEmoji(uint32_t codePoint)472 bool TypedText::IsEmoji(uint32_t codePoint)
473 {
474 // Miscellaneous symbols and symbol fonts
475 return (codePoint >= 0x2600 && codePoint <= 0x27BF) || codePoint == 0x303D || codePoint == 0x2049 ||
476 codePoint == 0x203C || (codePoint >= 0x2000 && codePoint <= 0x200F) ||
477 (codePoint >= 0x2028 && codePoint <= 0x202F) || codePoint == 0x205F ||
478 // Area occupied by punctuation, Alphabetic symbol
479 (codePoint >= 0x2065 && codePoint <= 0x206F) || (codePoint >= 0x2100 && codePoint <= 0x214F) ||
480 // Various technical symbols, Arrow A
481 (codePoint >= 0x2300 && codePoint <= 0x23FF) || (codePoint >= 0x2B00 && codePoint <= 0x2BFF) ||
482 // Arrow B,Chinese symbols
483 (codePoint >= 0x2900 && codePoint <= 0x297F) || (codePoint >= 0x3200 && codePoint <= 0x32FF) ||
484 // High and low substitution reserved area, Private reserved area
485 (codePoint >= 0xD800 && codePoint <= 0xDFFF) || (codePoint >= 0xE000 && codePoint <= 0xF8FF) ||
486 // Mutation selector, Plane above the second plane,char can't be saved, all can be transferred
487 (codePoint >= 0xFE00 && codePoint <= 0xFE0F) || codePoint >= 0x10000;
488 }
489
IsEmojiModifier(uint32_t codePoint)490 bool TypedText::IsEmojiModifier(uint32_t codePoint)
491 {
492 return (codePoint >= 0x1F3FB && codePoint <= 0x1F3FF);
493 }
494
495 // Based on Emoji_Modifier_Base from
IsEmojiBase(uint32_t codePoint)496 bool TypedText::IsEmojiBase(uint32_t codePoint)
497 {
498 if (codePoint >= 0x261D && codePoint <= 0x270D) {
499 return (codePoint == 0x261D || codePoint == 0x26F9 || (codePoint >= 0x270A && codePoint <= 0x270D));
500 } else if (codePoint >= 0x1F385 && codePoint <= 0x1F93E) {
501 return (codePoint == 0x1F385 || (codePoint >= 0x1F3C3 && codePoint <= 0x1F3C4) ||
502 (codePoint >= 0x1F3CA && codePoint <= 0x1F3CB) || (codePoint >= 0x1F442 && codePoint <= 0x1F443) ||
503 (codePoint >= 0x1F446 && codePoint <= 0x1F450) || (codePoint >= 0x1F466 && codePoint <= 0x1F469) ||
504 codePoint == 0x1F46E || (codePoint >= 0x1F470 && codePoint <= 0x1F478) || codePoint == 0x1F47C ||
505 (codePoint >= 0x1F481 && codePoint <= 0x1F483) || (codePoint >= 0x1F485 && codePoint <= 0x1F487) ||
506 codePoint == 0x1F4AA || codePoint == 0x1F575 || codePoint == 0x1F57A || codePoint == 0x1F590 ||
507 (codePoint >= 0x1F595 && codePoint <= 0x1F596) || (codePoint >= 0x1F645 && codePoint <= 0x1F647) ||
508 (codePoint >= 0x1F64B && codePoint <= 0x1F64F) || codePoint == 0x1F6A3 ||
509 (codePoint >= 0x1F6B4 && codePoint <= 0x1F6B6) || codePoint == 0x1F6C0 ||
510 (codePoint >= 0x1F918 && codePoint <= 0x1F91E) || codePoint == 0x1F926 || codePoint == 0x1F930 ||
511 (codePoint >= 0x1F933 && codePoint <= 0x1F939) || (codePoint >= 0x1F93B && codePoint <= 0x1F93E));
512 } else {
513 return false;
514 }
515 }
516
IsColourWord(uint32_t codePoint,uint16_t fontId,uint8_t fontSize)517 bool TypedText::IsColourWord(uint32_t codePoint, uint16_t fontId, uint8_t fontSize)
518 {
519 bool hasColor = false;
520 uint8_t weight = UIFont::GetInstance()->GetFontWeight(fontId);
521 if (weight >= 16) { // 16: rgb565->16 rgba8888->32 font with rgba
522 hasColor = true;
523 } else {
524 #if defined(ENABLE_MULTI_FONT) && ENABLE_MULTI_FONT
525 uint16_t* searchLists = nullptr;
526 int8_t listSize = UIMultiFontManager::GetInstance()->GetSearchFontList(fontId, &searchLists);
527 if ((listSize > 0) && (searchLists != nullptr)) {
528 int8_t currentIndex = 0;
529 do {
530 weight = UIFont::GetInstance()->GetFontWeight(searchLists[currentIndex]);
531 if (weight >= 16) { // 16: rgb565->16 rgba8888->32 font with rgba
532 hasColor = true;
533 break;
534 }
535 currentIndex++;
536 } while ((currentIndex < listSize) && (searchLists != nullptr));
537 }
538 #endif
539 }
540 if (!hasColor) {
541 return false;
542 }
543 GlyphNode glyphNode;
544 int8_t ret = UIFont::GetInstance()->GetGlyphNode(codePoint, glyphNode, fontId, fontSize);
545 if (ret != RET_VALUE_OK) {
546 GRAPHIC_LOGE("Failed to get glyphNode for color word");
547 return false;
548 }
549
550 weight = UIFont::GetInstance()->GetFontWeight(glyphNode.fontId);
551 return (weight >= 16); // 16: rgb565->16 rgba8888->32 font with rgba
552 }
553 } // namespace OHOS
554