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

import bdffont
from bdffont import BdfGlyph
from examples import assets_dir, outputs_dir


def main():
    font = bdffont.load_bdf(os.path.join(assets_dir, 'example.bdf'))
    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=(8, 16, 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, 'example-output.bdf'))


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

Uploaded Source

Built Distribution

bdffont-0.0.5-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file bdffont-0.0.5.tar.gz.

File metadata

  • Download URL: bdffont-0.0.5.tar.gz
  • Upload date:
  • Size: 10.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.5.tar.gz
Algorithm Hash digest
SHA256 d5655e2ce070a51b4444ad07a8838a37813fe6944c3d8954b45a0c58aba2402a
MD5 4be6b9fd248c2803d9cef185a6b5d6cc
BLAKE2b-256 a274deffc81377d3b6d226b10af0805c2301f3be5a3c3cb5a3cb5c2dacb37e6e

See more details on using hashes here.

Provenance

File details

Details for the file bdffont-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: bdffont-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 deb2b959d6dd0481e503cbc4b1efb669ebc740571a6bf0f02e516ff677085b74
MD5 a2718eeaa64e8f08a097d3f43b1f5fb8
BLAKE2b-256 b79e11caf930b826bc3cb3eda5f84df6118c2a8c52839e24d7766bacccb46795

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