A library for manipulating '.bdf' format fonts.
Project description
BdfFont
BdfFont is a library for manipulating .bdf
format fonts.
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.8.tar.gz
(11.3 kB
view details)
Built Distribution
File details
Details for the file bdffont-0.0.8.tar.gz
.
File metadata
- Download URL: bdffont-0.0.8.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c827b15c0f63ebe767e224a54ded8c0e5e941bd4daa641a92f58320b89a630be |
|
MD5 | 3d97f315fd7dfed57d0e6f2ce91168cd |
|
BLAKE2b-256 | 9f78c824af9f0c4c22da3a7b211d6acf4fcf5cc3738dae57d6eb3d860af0f5e6 |
Provenance
File details
Details for the file bdffont-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: bdffont-0.0.8-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 | 1a9d95ef172a3237437eaa399625cc50e3089d3883ab2ff32e159ba74a9d243e |
|
MD5 | 1df8c6210c6d379507b7892940f183d4 |
|
BLAKE2b-256 | c917168057b5e13e7d2fda7d45f6f10e18ac4129ed021bc0bbf8679dc9132428 |