Skip to main content

A library for manipulating '.bdf' format fonts.

Project description

BdfFont

PyPI

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

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.8.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for bdffont-0.0.8.tar.gz
Algorithm Hash digest
SHA256 c827b15c0f63ebe767e224a54ded8c0e5e941bd4daa641a92f58320b89a630be
MD5 3d97f315fd7dfed57d0e6f2ce91168cd
BLAKE2b-256 9f78c824af9f0c4c22da3a7b211d6acf4fcf5cc3738dae57d6eb3d860af0f5e6

See more details on using hashes here.

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

Hashes for bdffont-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1a9d95ef172a3237437eaa399625cc50e3089d3883ab2ff32e159ba74a9d243e
MD5 1df8c6210c6d379507b7892940f183d4
BLAKE2b-256 c917168057b5e13e7d2fda7d45f6f10e18ac4129ed021bc0bbf8679dc9132428

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