Spaces:
Sleeping
Sleeping
jk commited on
Commit ·
5493b18
1
Parent(s): ca8a804
Add .bdf file compatability
Browse filesFiles changed (8)
- font_output.pngDeleted
- fonts/test.pbmAdded
- fonts/test.pilAdded
- generate_text.py+10-7
- output/font_output.bmpAdded
- output.bmp → output/output.bmpRenamed
- pilfont.pyAdded+57
- simulator.py+1-1
12344 unmodified lines91011121314151617181920from bdfparser import Fontfont = Font("fonts/test.bdf")print(4 unmodified lines# =================================ac = font.draw("Hello!")ac_8x8 = ac * 8from PIL import Imageim_ac = Image.frombytes("RGBA", (ac_8x8.width(), ac_8x8.height()), ac_8x8.tobytes("RGBA"))im_ac.save("font_output.png", "PNG")1234564 unmodified lines11121314151617181920212223from bdfparser import Fontfrom PIL import Image, ImageFont, ImageDrawfont = Font("fonts/test.bdf")print(4 unmodified lines# =================================new_image = Image.new("RGB", (50, 50))draw = ImageDraw.Draw(new_image)# use a bitmap fontfont = ImageFont.load_path("fonts/test.pil")draw.text((10, 10), "Romanplatz", font=font)new_image.save("output/font_output.bmp")
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#!/usr/bin/env python## The Python Imaging Library# $Id$## PIL raster font compiler## history:# 1997-08-25 fl created# 2002-03-10 fl use "from PIL import"#
from __future__ import print_function
import globimport sys
# driversfrom PIL import BdfFontFilefrom PIL import PcfFontFile
VERSION = "0.4"
if len(sys.argv) <= 1: print("PILFONT", VERSION, "-- PIL font compiler.") print() print("Usage: pilfont fontfiles...") print() print("Convert given font files to the PIL raster font format.") print("This version of pilfont supports X BDF and PCF fonts.") sys.exit(1)
files = []for f in sys.argv[1:]: files = files + glob.glob(f)
for f in files:
print(f + "...", end=' ')
try:
fp = open(f, "rb")
try: p = PcfFontFile.PcfFontFile(fp) except SyntaxError: fp.seek(0) p = BdfFontFile.BdfFontFile(fp)
p.save(f)
except (SyntaxError, IOError): print("failed")
else: print("OK")80 unmodified lines8182838480 unmodified linesfor index, color in enumerate(list_of_pixels):draw_new_pixel(get_new_coordinates(get_coordinates_from_index(index)), color)new_image.save("output.bmp")80 unmodified lines8182838480 unmodified linesfor index, color in enumerate(list_of_pixels):draw_new_pixel(get_new_coordinates(get_coordinates_from_index(index)), color)new_image.save("output/output.bmp")
font_output.pngDeleted
fonts/test.pbmAdded
fonts/test.pilAdded
generate_text.py+10-7
output/font_output.bmpAdded

output.bmp → output/output.bmpRenamed


pilfont.pyAdded+57
simulator.py+1-1