python - 通过 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")
解决方案
推荐阅读
- angular - 检索组件/应用程序上所有注入服务的列表
- php - 如何在 Codeigniter pre_system 挂钩中使用会话
- javascript - 将 JSON 中的字符串数组替换为整数数组
- python - 当 CPU 被过度使用时,弱引用对象不再存在
- c# - 两列中的 OrderBy 记录 ASC
- vagrant - Vagrantfile 未在具有特殊字符的路径中加载
- spring-boot - Spring Boot/Java 将枚举值映射到 RequestParam
- javascript - 如何在我的俄罗斯方块游戏中设置高分 javascript html css
- conv-neural-network - CNN如何处理多张图像
- c++ - 如何在 Windows 上静态构建和包含 wolfssl?