1
0
mirror of https://gitlab.com/MisterBiggs/bdfparse.git synced 2025-06-16 22:46:40 +00:00

updated docs for new version

This commit is contained in:
Anson 2019-07-16 20:12:48 -07:00
parent 7df856e3d6
commit 295c9207a5

View File

@ -5,20 +5,42 @@ This project takes a .bdf file and turns it into a [NumPy](https://www.numpy.org
## Usage
```python
import numpy as np
import matplotlib.pyplot as plt
from bdfparse import Font
font = parse_chars("9x18.bdf")
matrix = font["A"]
text = "nson"
font = Font('9x18.bdf')
for letter in text:
matrix = np.concatenate((matrix, font[letter]), axis=1)
plt.imshow(matrix)
plt.show()
print(font.word('Hi'))
```
Which outputs:
```python
[[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.
```python
import matplotlib.pyplot as plt
plt.imshow(font.word('Anson'))
```
![Example of code output that reads Anson.](example.png)