python默认字体大小_python – 如何设置PIL加载的默认字体的大小,使其适合我的8×8矩阵?...
我正在努力在8×8矩陣顯示器上顯示文本,而且我沒有在我的BeagleBone上知道的.ttf文件.
根據(jù)示例here,我應(yīng)該能夠說font = ImageFont.load_default()而不是加載.ttf,但是,這顯然不是指定字體的尺寸!有什么辦法嗎?或者,是否有一個(gè)地方你知道我可以在我的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)
總結(jié)
以上是生活随笔為你收集整理的python默认字体大小_python – 如何设置PIL加载的默认字体的大小,使其适合我的8×8矩阵?...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【IT之家开箱】当璀璨星河融入“水滴”:
- 下一篇: 分析师:搭载M3芯片的MacBook A