A library for manipulating '.bdf' format fonts.
Project description
BdfFont
BdfFont is a library for manipulating .bdf
format fonts, written in Python.
Installation
pip install bdffont
Usage
import os
import bdffont
from bdffont import BdfGlyph
from examples import assets_dir, outputs_dir
def main():
font = bdffont.load_bdf(os.path.join(assets_dir, 'example.bdf'))
font.properties.set_font_version('1.0.0')
font.properties.set_font_ascent(7)
font.properties.set_font_descent(2)
font.properties.set_x_height(5)
font.properties.set_cap_height(7)
font.add_glyph(BdfGlyph(
name='A',
code_point=ord('A'),
s_width=(500, 0),
d_width=(8, 0),
bbx=(8, 16, 0, -2),
bitmap=[
[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, 1, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
],
))
font.save(os.path.join(outputs_dir, 'example-output.bdf'))
if __name__ == '__main__':
main()
References
- X11 - Bitmap Distribution Format - Version 2.1
- Adobe - Glyph Bitmap Distribution Format (BDF) Specification - Version 2.2
License
Under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bdffont-0.0.2.tar.gz
(8.8 kB
view details)
Built Distribution
File details
Details for the file bdffont-0.0.2.tar.gz
.
File metadata
- Download URL: bdffont-0.0.2.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f021b3fbea9a811500141c31d2b01f5cadbede681591e25713de957166b73a7 |
|
MD5 | 330860ff5b41edac6892231c4248a594 |
|
BLAKE2b-256 | f2ef9a1e0ff92dfcc12f4136fcab203474995841ca44baec6fc476282bffe80b |
Provenance
File details
Details for the file bdffont-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: bdffont-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f702cf51eba88612c5fe38d4810c1c8a11646ec78a585ccec69acda49ea17c02 |
|
MD5 | 947999b032be4b0a5bb22bb442ac2fad |
|
BLAKE2b-256 | 351a572e9860d96e5e350c11c1792395d4d981b4b9c0dbe0cba566b04c0458cf |