将自定义字体与ezdxf一起使用

问题描述

我想使用ezdxf在dxf上编写带有自定义ttf的文本。

我尝试使用doc.styles.new('custom_font',dxfattribs={'font' : 'myFont.ttf'})来加载ttf文件(该文件与脚本位于同一文件夹中),但是它不起作用。

我的代码

import ezdxf

doc = ezdxf.new('R12',setup=True)
msp = doc.modelspace()

doc.styles.new('custom_style',dxfattribs={'font': 'myFont.ttf'})

text_to_export = ex.text_to_export.text()

msp.add_text(text_to_export,dxfattribs={
                  'style': "custom_style",'height': 0.35}
             ).set_pos((2,6),align='LEFT')

doc.saveas("text.dxf")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)