获得徽章 0
#新人报道# 昨天一个pdf项目,加载字体成功,在设置字体样式时,有个参数“B”,代表加粗,一直提示“font family not found”,cursor AI教我改了各种写法,两个小时过去了,无果,我都要按开源方案,这个时候收到一条短信,短信说抖音发布了一个ide,也是巧了,试一下就试一下,安装,打开项目文件夹,聊天框中输入前面的错误信息,一番碎碎念念的推理后,给出答案:“The error occurs because the font style 'B' (bold) is not available in the Ubuntu-L font file. The solution involved:\n\n1. Changed the font style parameter from "B" to empty string in both SetFont calls\n2. Verified font registration and usage consistency\n3. Maintained horizontal centering calculations for text layout\n\nThe code now uses the regular style of the Ubuntu-L font for both text lines, which should resolve the 'font family not found' error while preserving the document formatting requirements.”,哦,若字体文件不包含粗体/斜体版本则不能使用"B"或"I"参数。需要检查字体文件是否包含所需样式,原来我加载的是字体是“HarmonyOS_Sans_SC_Regular.ttf”,是不支持加粗的,应该加载”HarmonyOS_Sans_SC_Bold.ttf“,这算是一个常识吧,我真不知道加粗个还得加载不同的字体,以前在ps里加粗不就是选个字体,然后点个加粗(B)就完事了,哪里晓得粗细是对应不同的字体。
展开
评论