forked from mozman/ezdxf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusing_all_text_styles.py
33 lines (26 loc) · 1019 Bytes
/
using_all_text_styles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright (c) 2019-2022 Manfred Moitzi
# License: MIT License
import pathlib
import ezdxf
from ezdxf.tools.standards import styles
CWD = pathlib.Path("~/Desktop/Outbox").expanduser()
if not CWD.exists():
CWD = pathlib.Path(".")
# ------------------------------------------------------------------------------
# This example creates TEXT entities for all text styles predefined by ezdxf.
#
# tutorial for TEXT: https://ezdxf.mozman.at/docs/tutorials/text.html
# ------------------------------------------------------------------------------
# The predefined text styles only exists if setup is TRUE and the open source
# fonts are installed on your system, see the folder "/fonts" in the repository.
doc = ezdxf.new("R12", setup=True)
msp = doc.modelspace()
y = 0
height = 0.5
line_height = 1.5
for style, font in styles():
msp.add_text(
style, dxfattribs={"style": style, "height": height}
).set_placement((0, y))
y += height * line_height
doc.saveas(CWD / "using_all_text_styles.dxf")