1
0
mirror of https://gitlab.com/MisterBiggs/bdfparse.git synced 2025-06-15 05:56:39 +00:00
2019-07-18 19:47:20 -07:00
2019-07-18 19:46:37 -07:00
2019-07-12 16:47:01 -07:00
2019-07-12 16:47:01 -07:00
2019-07-15 23:00:40 -07:00
2019-07-16 20:12:48 -07:00
2019-07-18 19:47:20 -07:00

.bdf to NumPy

This project takes a .bdf file and turns it into a NumPy Array with an intended use with LED matrix displays. My LED Stock Ticker uses this package. A good list of .bdf files can be found here

Usage

from bdfparse import Font

font = Font('9x18.bdf')

print(font.word('Hi'))

Which outputs:

[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0]
 [0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0]
 [0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]

Or you can use matplotlib to make the output a bit prettier.

import matplotlib.pyplot as plt

plt.imshow(font.word('Anson'))

Example of code output that reads Anson.

Description
https://pypi.org/project/bdfparse/ A package for reading .bdf files into NumPy arrays.
Readme MIT 115 KiB
Languages
Python 100%