【发布时间】:2021-05-16 22:55:30
【问题描述】:
我想在 Google colab 中安装 libraqm 库。我有很多图像可以使用,并在我需要这个特定库的那些上添加表情符号文本。我还尝试将预先构建的 .dll 放在目录中,但没有任何效果。任何答案都会有所帮助。
另外,以这种方式安装 libraqm 并运行代码会导致它崩溃。
!sudo apt install libraqm-dev
我尝试运行的代码示例:
from PIL import Image, ImageDraw, ImageFont
def test(font, out_name):
fnt = ImageFont.truetype(font, size=109, layout_engine=ImageFont.LAYOUT_RAQM)
im = Image.new("RGBA", (600, 600), (100, 100, 100, 100))
draw = ImageDraw.Draw(im)
draw.text((0, 32), "a\u263A", fill="#faa2", embedded_color=True, font=fnt)
draw.text((0, 132), "a\u263A", fill="#faa8", embedded_color=True, font=fnt)
draw.text((0, 232), "a\u263A", fill="#faa", embedded_color=True, font=fnt)
draw.text((0, 332), "\U0001F3AC\U0001F44B\U0001F3FB\U0001F44B\U0001F3FF", fill="white", embedded_color=True, font=fnt)
draw.text((0, 432), "a\u263A", fill="#faa2", font=fnt)
im.show()
im.save(f"testemoji_{out_name}.png")
test(r"C:\Users\Nulano\Downloads\NotoColorEmoji.ttf", "cbdt")
test("seguiemj.ttf", "colr")
【问题讨论】:
标签: python dll python-imaging-library google-colaboratory