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 hashes)