Ich arbeite an der Anzeige von Text auf einem 8x8-Matrix-Display und ich habe keine .ttf-Datei zur Hand, die ich auf meinem BeagleBone kenne.Wie kann ich die Größe der von PIL geladenen Standardschriftart so einstellen, dass sie auf meine 8x8 Matrix passt?
Nach einem Beispiel here, ich sollte sagen können font = ImageFont.load_default()
anstatt eine .ttf zu laden, aber dies ist eindeutig nicht die Abmessungen der Schriftart angeben! Irgendeine Möglichkeit, dies zu tun? Alternativ, gibt es einen Ort, den Sie kennen für sicher Ich kann eine. TTF-Schriftart auf meiner BBB-Version von Ubuntu 14.04.1 finden?
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)
Sie können BDF-Format konvertieren Schriften pilformat mit [** _Das Hilfsprogramm pilfont _ **] (http://effbot.org/imagingbook/pilfont.htm). Es ist ein Skript im Verzeichnis/Python/Scripts. Ich habe eine 8x8 BDF-Schriftart gefunden, die Sie von [hier] herunterladen können (https://beej.us/c64bdf/) – martineau