From f9e7e322d7598b7949a67907acb2c8cd81053a25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Thu, 26 Sep 2024 12:26:33 +0000 Subject: [PATCH] Merge #1023 into sdk602patch0626 from refs/changes/1023/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 增加字符替换方法 * refs/changes/1023/head: (1 commits squashed) - 增加字符替换方法 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1023 --- .../uicomponents/UIComponents.cpp | 48 +++++++++++++++++++ .../uicomponents/UIComponents.h | 3 ++ 2 files changed, 51 insertions(+) diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index 53343285e..5c5d51daf 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -1,5 +1,11 @@ #include "uicomponents/UIComponents.h" #include +#include +#include +#include +#include "common/text.h" +#include "common/typed_text.h" +#include "font/ui_font.h" namespace OHOS { @@ -843,4 +849,46 @@ namespace OHOS } return imageArray; } + + void updata_char(char *str_,char *str,uint32_t max_len) + { + strcpy_s(str_,max_len,str); + uint32_t j = 0; + uint32_t letter = 0; + if (str == nullptr) { + return ; + } + while (str[j] != '\0') + { + int i=j; + letter = TypedText::GetUTF8Next(str, j, j); + int len=j-i; + UIFont* fontEngine= UIFont::GetInstance(); + GlyphPathData path; + if(!fontEngine->GetGlyphPathData(letter, 0, path)) + { + printf("********************* letter%d %d %d not exist\r\n",i,j,letter); + char *buf= "□"; + uint16_t buf_len=strlen(buf); + uint16_t offset =0; + int num=len/buf_len; + int mod_num=len%buf_len; + for(int x=0;x