英文:
Why is wand ignoring my unicode characters in text output?
问题
当我使用诸如≛、★等字符时,wand 在文本输出中忽略它们。例如:
#!/usr/bin/python3
import os
import wand
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.fill_color = Color('black')
draw.font_size = 20
draw.text (20, 100, 'A')
draw.text (60, 100, '≛')
draw.text (100, 100, '▴')
draw.text (140, 100, 'Z')
with Image(width=200, height=200, background=Color('yellow')) as img:
draw(img)
img.save(filename='example.png')
这将产生:
我正在使用 macOS 13.2.1 的 python 3.9.2,以及通过 homebrew 安装的 imagemagick。
英文:
When I use characters such as ≛, ★, etc., wand ignores them in text output. For example:
#!/usr/bin/python3
import os
import wand
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.fill_color = Color('black')
draw.font_size = 20
draw.text (20, 100, 'A')
draw.text (60, 100, '≛')
draw.text (100, 100, '▴')
draw.text (140, 100, 'Z')
with Image(width=200, height=200, background=Color('yellow')) as img:
draw(img)
img.save(filename='example.png')
This yields:
I'm using macOS 13.2.1's python 3.9.2, and imagemagick via homebrew.
答案1
得分: 1
from wand.image import Image
from wand.drawing import Drawing
with Drawing() as draw:
draw.fill_color = 'black'
draw.font_size = 20
draw.font_family = 'DejaVu Sans' # <---- Or with draw.font
draw.text(20, 100, 'A')
draw.text(60, 100, '≛')
draw.text(100, 100, '▴')
draw.text(140, 100, 'Z')
with Image(width=200, height=200, background='yellow') as img:
draw(img)
img.save(filename='example.png')
英文:
Be sure to define a typeface that includes unicode characters.
from wand.image import Image
from wand.drawing import Drawing
with Drawing() as draw:
draw.fill_color = 'black'
draw.font_size = 20
draw.font_family = 'DejaVu Sans' # <---- Or with draw.font
draw.text(20, 100, 'A')
draw.text(60, 100, '≛')
draw.text(100, 100, '▴')
draw.text(140, 100, 'Z')
with Image(width=200, height=200, background='yellow') as img:
draw(img)
img.save(filename='example.png')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论