📜  pil 格式多行文本 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:20.599000             🧑  作者: Mango

代码示例1
import textwrap
lines = textwrap.wrap(text, width=40)
y_text = h
for line in lines:
    width, height = font.getsize(line)
    draw.text(((w - width) / 2, y_text), line, font=font, fill=FOREGROUND)
    y_text += height