我正在开发一个在8x8矩阵显示器上显示文本的项目,但是我不知道在我的BeagleBone上是否有手头上可用的.ttf文件。
根据这里的示例,我应该可以使用font = ImageFont.load_default()
来代替加载.ttf文件,但是,这显然没有指定字体的尺寸!有什么方法可以做到这一点吗?或者,您确定我可以在我的BBB版本Ubuntu 14.04.1上找到.ttf字体的地方吗?
import Image
import ImageDraw
import ImageFont
# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new('1', (width, height))
# Load default font.
font = ImageFont.load_default()
# Alternatively load a TTF font.
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8)
# Write two lines of text.
draw.text((x, top), 'Hello', font=font, fill=255)
draw.text((x, top+20), 'World!', font=font, fill=255)