# 文字的處理

``````import cadquery as cq

t1 = (cq.Workplane()
.text(
'Hello, World',
fontsize = 10,
distance = 5,
font = 'Arial Black'
)
)

t2 = (cq.Workplane()
.text(
'哈囉！世界！',
fontsize = 10,
distance = 5,
fontPath = r'C:\Windows\Fonts\SourceHanSansTC-Bold.otf'
)
.translate((0, 10, 0))
)
``````

``````import cadquery as cq

t1 = (cq.Workplane()
.box(100, 20, 10)
.text(
'Hello, World',
fontsize = 12,
distance = 5,
font = 'Arial Black'
)
)
``````

`Workplane` 沒有 2D 概念的文字處理方法，不過可以建立 3D 的文字實體，透過 `wires` 方法取得構成文字的線，然後進一步處理，例如，來個扭來扭去的文字：

``````import cadquery as cq

path = (cq.Workplane('XZ')
)

t = (cq.Workplane()
.text(
'Hi',
fontsize = 12,
distance = 1,
font = 'Arial Black'
)
.wires('<Z')
.toPending()
.sweep(path)
)
``````

``````import cadquery as cq

t = 'Orz'
fontsize = 12
height = 2
font = 'Arial Black'
offset = 2

t = (cq.Workplane()
.text(t, fontsize = fontsize, distance = height, font = font)
)

# 取得 XY 上的文字面
faces = t.faces('<Z').vals()
# 對於每個文字面的外圍線 offset
wires = [wire
# 對於每個文字面
for face in faces
# 取得外圍的線進行 offset
for wire in face.outerWire().offset2D(offset)
]

# 將這些線化為面進行聯集
unioned = Face.makeFromWires(wires[0])
for i in range(1, len(wires)):
unioned = unioned.fuse(Face.makeFromWires(wires[i])).clean()

tag = (cq.Workplane()
# 建立輪廓並擠出