{"id":27364538,"url":"https://github.com/takwolf/bdffont-python","last_synced_at":"2025-09-06T11:44:06.964Z","repository":{"id":161022299,"uuid":"635718976","full_name":"TakWolf/bdffont-python","owner":"TakWolf","description":"A library for manipulating Glyph Bitmap Distribution Format (BDF) Fonts","archived":false,"fork":false,"pushed_at":"2025-07-13T07:45:30.000Z","size":4852,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-13T09:28:02.942Z","etag":null,"topics":["bdf","bitmap-font","bitmap-fonts","font","fonts"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/bdffont/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TakWolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-03T10:03:13.000Z","updated_at":"2025-07-13T07:45:34.000Z","dependencies_parsed_at":"2023-11-14T11:27:03.088Z","dependency_job_id":"16e320ce-8b89-46e9-9c2e-11f13098024c","html_url":"https://github.com/TakWolf/bdffont-python","commit_stats":null,"previous_names":["takwolf/bdffont-python"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/TakWolf/bdffont-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fbdffont-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fbdffont-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fbdffont-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fbdffont-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TakWolf","download_url":"https://codeload.github.com/TakWolf/bdffont-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fbdffont-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273898909,"owners_count":25187732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdf","bitmap-font","bitmap-fonts","font","fonts"],"created_at":"2025-04-13T05:23:23.432Z","updated_at":"2025-09-06T11:44:06.946Z","avatar_url":"https://github.com/TakWolf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BdfFont.Python\n\n[![Python](https://img.shields.io/badge/python-3.10-brightgreen)](https://www.python.org)\n[![PyPI](https://img.shields.io/pypi/v/bdffont)](https://pypi.org/project/bdffont/)\n\nBdfFont is a library for manipulating [Glyph Bitmap Distribution Format (BDF) Fonts](https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format).\n\n## Installation\n\n```shell\npip install bdffont\n```\n\n## Usage\n\n### Create\n\n```python\nimport shutil\nimport statistics\n\nfrom bdffont import BdfFont, BdfGlyph\nfrom examples import build_dir\n\n\ndef main():\n    outputs_dir = build_dir.joinpath('create')\n    if outputs_dir.exists():\n        shutil.rmtree(outputs_dir)\n    outputs_dir.mkdir(parents=True)\n\n    font = BdfFont(\n        point_size=16,\n        resolution=(75, 75),\n        bounding_box=(16, 16, 0, -2),\n    )\n\n    font.glyphs.append(BdfGlyph(\n        name='A',\n        encoding=65,\n        scalable_width=(500, 0),\n        device_width=(8, 0),\n        bounding_box=(8, 16, 0, -2),\n        bitmap=[\n            [0, 0, 0, 0, 0, 0, 0, 0],\n            [0, 0, 0, 0, 0, 0, 0, 0],\n            [0, 0, 0, 0, 0, 0, 0, 0],\n            [0, 0, 0, 0, 0, 0, 0, 0],\n            [0, 0, 0, 1, 1, 0, 0, 0],\n            [0, 0, 1, 0, 0, 1, 0, 0],\n            [0, 0, 1, 0, 0, 1, 0, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 1, 1, 1, 1, 1, 1, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 1, 0, 0, 0, 0, 1, 0],\n            [0, 0, 0, 0, 0, 0, 0, 0],\n            [0, 0, 0, 0, 0, 0, 0, 0],\n        ],\n    ))\n\n    font.properties.foundry = 'Pixel Font Studio'\n    font.properties.family_name = 'My Font'\n    font.properties.weight_name = 'Medium'\n    font.properties.slant = 'R'\n    font.properties.setwidth_name = 'Normal'\n    font.properties.add_style_name = 'Sans Serif'\n    font.properties.pixel_size = font.point_size\n    font.properties.point_size = font.point_size * 10\n    font.properties.resolution_x = font.resolution_x\n    font.properties.resolution_y = font.resolution_y\n    font.properties.spacing = 'P'\n    font.properties.average_width = round(statistics.fmean(glyph.device_width_x * 10 for glyph in font.glyphs))\n    font.properties.charset_registry = 'ISO10646'\n    font.properties.charset_encoding = '1'\n    font.generate_name_as_xlfd()\n\n    font.properties.default_char = -1\n    font.properties.font_ascent = 14\n    font.properties.font_descent = 2\n    font.properties.x_height = 7\n    font.properties.cap_height = 10\n    font.properties.underline_position = -2\n    font.properties.underline_thickness = 1\n\n    font.properties.font_version = '1.0.0'\n    font.properties.copyright = 'Copyright (c) TakWolf'\n\n    font.save(outputs_dir.joinpath('my-font.bdf'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n### Load\n\n```python\nimport shutil\n\nfrom bdffont import BdfFont\nfrom examples import assets_dir, build_dir\n\n\ndef main():\n    outputs_dir = build_dir.joinpath('load')\n    if outputs_dir.exists():\n        shutil.rmtree(outputs_dir)\n    outputs_dir.mkdir(parents=True)\n\n    font = BdfFont.load(assets_dir.joinpath('unifont', 'unifont-16.0.04.bdf'))\n    print(f'name: {font.name}')\n    print(f'size: {font.point_size}')\n    print(f'ascent: {font.properties.font_ascent}')\n    print(f'descent: {font.properties.font_descent}')\n    print()\n    for glyph in font.glyphs:\n        print(f'char: {chr(glyph.encoding)} ({glyph.encoding:04X})')\n        print(f'glyph_name: {glyph.name}')\n        print(f'advance_width: {glyph.device_width_x}')\n        print(f'dimensions: {glyph.dimensions}')\n        print(f'offset: {glyph.offset}')\n        for bitmap_row in glyph.bitmap:\n            text = ''.join('  ' if color == 0 else '██' for color in bitmap_row)\n            print(f'{text}*')\n        print()\n    font.save(outputs_dir.joinpath('unifont-16.0.04.bdf'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n## References\n\n- [X11 - Bitmap Distribution Format - Version 2.1](https://www.x.org/docs/BDF/bdf.pdf)\n- [Adobe - Glyph Bitmap Distribution Format (BDF) Specification - Version 2.2](https://adobe-type-tools.github.io/font-tech-notes/pdfs/5005.BDF_Spec.pdf)\n- [X Logical Font Description Conventions - X Consortium Standard](https://www.x.org/releases/current/doc/xorg-docs/xlfd/xlfd.html)\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakwolf%2Fbdffont-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakwolf%2Fbdffont-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakwolf%2Fbdffont-python/lists"}