处理器:HI3716M
SDK:Hi3716XV100R001C00SPC0A2
问题描述:在海思HI3716 DMO板上跑SDK/sample/higo下的样例,发现不能显示linux下的UTF-8编码格式的汉字,windows下字体可以正常显示,由于有关底层的东西都打包做成的动态库,所以我这边没法看见,以前是我主函数里面的代码,如果有可能的话,我希望能在应用就能解决这个问题:
声明:我要实现的是在TV上显示UTF-8的字体,不用转GB2312
HI_S32 main(HI_S32 argc, HI_CHAR* argv[])
{
HI_S32 s32Ret = 0;
HI_HANDLE hFont = HIGO_INVALID_HANDLE;
HIGO_LAYER_INFO_S stLayerInfo = {0};
HI_HANDLE hLayer = HIGO_INVALID_HANDLE;
HI_HANDLE hLayerSurface;
HI_RECT rc = {0};
HI_CHAR szText[] = "涔变竷鍏碂"; //这是在linux下的UTF-8编码格式
HIGO_LAYER_E eLayerID = HIGO_LAYER_HD_0; s32Ret = Display_Init();//初始化display
if (HI_SUCCESS != s32Ret)
{
Printf("failed to init display!
");
return 0;
}
s32Ret = HI_GO_Init();//初始化higo
if (HI_SUCCESS != s32Ret)
{
Printf("failed to init higo! ret = 0x%x !
", s32Ret);
return 0;
} HI_GO_GetLayerDefaultParam(eLayerID, &stLayerInfo); //根据图层ID获取相应图层(SD,HD)创建时的默认参数
stLayerInfo.PixelFormat = HIGO_PF_8888;
s32Ret = HI_GO_CreateLayer(&stLayerInfo, &hLayer);//创建图层
if (HI_SUCCESS != s32Ret)
{
Printf("failed to create the layer sd 0, ret = 0x%x !
", s32Ret);
goto RET;
} s32Ret = HI_GO_GetLayerSurface(hLayer, &hLayerSurface);//获取图层的surface
if (HI_SUCCESS != s32Ret)
{
Printf("failed to get layer surface! s32Ret = 0x%x
", s32Ret);
goto RET;
} HI_GO_FillRect(hLayerSurface, NULL, 0xFF000000, HIGO_COMPOPT_NONE);//矩形填充
s32Ret = HI_GO_CreateText("./res/simhei.ttf", NULL, &hFont);// 创建文本输出对象
if (HI_SUCCESS != s32Ret)
{
Printf("failed to create the font:./res/simhei.ttf !
");
goto RET;
} HI_GO_SetTextColor(hFont, 0xffff0000);//设置文本颜 {MOD}
rc.x = 200;
rc.y = 100;
rc.w = 400;
rc.h = 30; HI_GO_DrawRect(hLayerSurface, &rc, 0xffffffff);//画矩形 s32Ret = HI_GO_TextOutEx(hFont, hLayerSurface, szText, &rc, HIGO_LAYOUT_RIGHT);//在指定的区域文本输出
if (HI_SUCCESS != s32Ret)
{
Printf("failed to text out char!
");
goto RET;
} HI_GO_RefreshLayer(hLayer, NULL);//刷新图层 getchar(); RET:
if (HIGO_INVALID_HANDLE != hLayer)
{
HI_GO_DestroyLayer(hLayer);
} if (HIGO_INVALID_HANDLE != hFont)
{
HI_GO_DestroyText(hFont);
}
HI_GO_Deinit(); Display_DeInit();
return HI_SUCCESS;
}
求助:如何在TV上正常显示UFT-8编码格式的字体?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>