为什么魔杖在文本输出中忽略了我的Unicode字符?

huangapple go评论97阅读模式
英文:

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')

这将产生:

为什么魔杖在文本输出中忽略了我的Unicode字符?

我正在使用 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:

为什么魔杖在文本输出中忽略了我的Unicode字符?

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')

为什么魔杖在文本输出中忽略了我的Unicode字符?

huangapple
  • 本文由 发表于 2023年3月23日 12:23:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75819230.html
  • wand
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定