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
from bdffont import BdfFont, BdfProperties, BdfGlyph
from examples import outputs_dir
def main():
font = BdfFont(
name='my-font',
point_size=16,
dpi_xy=(75, 75),
bounding_box_size=(16, 16),
bounding_box_offset=(0, -2),
properties=BdfProperties({
'PARAM_1': 1,
'PARAM_2': '2',
}),
comments=[
'This is a comment.',
'This is a comment, too.',
],
)
font.properties.font_version = '1.0.0'
font.properties.font_ascent = 7
font.properties.font_descent = 2
font.properties.x_height = 5
font.properties.cap_height = 7
font.add_glyph(BdfGlyph(
name='A',
code_point=ord('A'),
scalable_width=(500, 0),
device_width=(8, 0),
bounding_box_size=(8, 16),
bounding_box_offset=(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, 'my-font.bdf'), optimize_bitmap=True)
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.7.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file bdffont-0.0.7.tar.gz
.
File metadata
- Download URL: bdffont-0.0.7.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c01d12644523c67bc84001e82ad40286f324ae0b56ea34dd56f5392c4eae624 |
|
MD5 | 626053b92451d797956f9f63c5a39ebd |
|
BLAKE2b-256 | ea6d0ae4e32b5f5e1a3fc403095bc6293f93784554745bc594ff1ffcb45aaf5e |
Provenance
File details
Details for the file bdffont-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: bdffont-0.0.7-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 759a1c2affcf80370a68367a08a3b31cef585a66fc3d821b0b56384486dae9ef |
|
MD5 | 32af0d67bf3ade465e10fd4a5f381f1b |
|
BLAKE2b-256 | 9413aa27a27ea5e3ddbb56423d20d468630b80c81c3e844d8893135bf763b6c4 |