DrawSetFont(dw, "字体路径"); 中的【字体路径】不能含有【中文】

测试发现: DrawSetFont(dw, "字体路径"); 中的【字体路径】不能含有【中文】, 只能是英文和数字。

DrawSetFont(dw, "d:\\宋体.ttc"); //不支持中文路径
DrawSetFont(dw, "d:\\st.ttc"); //只能使用英文字符

能过查看 ImageMagick 源代码发现 drawing-wand.c -> DrawSetFont(DrawingWand *wand, const char *font_name), 其中 font_name 是 char * 类型

但是在绘制过程中, 使用到了 FreeType 库, 这个库好像使用的是 unicode 编码或 utf-8 编码

annotate.c -> RenderFreetype() -> ftobjs.c -> FT_Open_Face()

不过,我也尝试过先将【字体路径】转换成 utf-8 传递, 依然没有解决问题:

char szFontPath_utf8[1024];
toUTF8(pszFontPath, szFontPath_utf8, 1024, NULL); //转换成 utf-8 编码
DrawSetFont(dw, pszFontPath);

posted @ 2020-09-17 12:46  personnel  阅读(218)  评论(0编辑  收藏  举报
友情链接:图片批量处理工具 gif动态图制作工具 制作电子相册 图片排版工具 制作淘宝主图视频 MKScript 鼠标键盘自动化脚本语言