Skip to main content

A library for manipulating '.bdf' format fonts.

Project description

BdfFont

PyPI

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

License

Under the MIT license.

Project details


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)

Uploaded Source

Built Distribution

bdffont-0.0.7-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

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

Hashes for bdffont-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0c01d12644523c67bc84001e82ad40286f324ae0b56ea34dd56f5392c4eae624
MD5 626053b92451d797956f9f63c5a39ebd
BLAKE2b-256 ea6d0ae4e32b5f5e1a3fc403095bc6293f93784554745bc594ff1ffcb45aaf5e

See more details on using hashes here.

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

Hashes for bdffont-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 759a1c2affcf80370a68367a08a3b31cef585a66fc3d821b0b56384486dae9ef
MD5 32af0d67bf3ade465e10fd4a5f381f1b
BLAKE2b-256 9413aa27a27ea5e3ddbb56423d20d468630b80c81c3e844d8893135bf763b6c4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page