{"id":26600953,"url":"https://github.com/takwolf/kbitfont","last_synced_at":"2025-03-23T18:36:15.466Z","repository":{"id":280755403,"uuid":"943019055","full_name":"TakWolf/kbitfont","owner":"TakWolf","description":"A library for parsing Bits'N'Picas native save format files ('.kbits' and '.kbitx')","archived":false,"fork":false,"pushed_at":"2025-03-20T09:41:32.000Z","size":147,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T10:34:43.254Z","etag":null,"topics":["bitmap-font","bitmap-fonts","bitsnpicas","font","fonts","kbits","kbitx"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/kbitfont/","language":"Java","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}},"created_at":"2025-03-05T03:38:59.000Z","updated_at":"2025-03-20T09:41:36.000Z","dependencies_parsed_at":"2025-03-20T10:38:42.737Z","dependency_job_id":null,"html_url":"https://github.com/TakWolf/kbitfont","commit_stats":null,"previous_names":["takwolf/kbitfont"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fkbitfont","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fkbitfont/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fkbitfont/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakWolf%2Fkbitfont/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TakWolf","download_url":"https://codeload.github.com/TakWolf/kbitfont/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245152445,"owners_count":20569393,"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","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":["bitmap-font","bitmap-fonts","bitsnpicas","font","fonts","kbits","kbitx"],"created_at":"2025-03-23T18:36:13.248Z","updated_at":"2025-03-23T18:36:15.442Z","avatar_url":"https://github.com/TakWolf.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KbitFont\n\n[![Python](https://img.shields.io/badge/python-3.10-brightgreen)](https://www.python.org)\n[![PyPI](https://img.shields.io/pypi/v/kbitfont)](https://pypi.org/project/kbitfont/)\n\nKbitFont is a library for parsing [Bits'N'Picas](https://github.com/kreativekorp/bitsnpicas) native save format files (`.kbits` and `.kbitx`).\n\n## Installation\n\n```shell\npip install kbitfont\n```\n\n## Usage\n\n### Create\n\n```python\nimport shutil\n\nfrom examples import build_dir\nfrom kbitfont import KbitFont, KbitGlyph\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 = KbitFont()\n    font.props.em_ascent = 14\n    font.props.em_descent = 2\n    font.props.line_ascent = 14\n    font.props.line_descent = 2\n    font.props.x_height = 7\n    font.props.cap_height = 10\n\n    font.names.version = '1.0.0'\n    font.names.family = 'My Font'\n    font.names.style = 'Regular'\n    font.names.manufacturer = 'Pixel Font Studio'\n    font.names.designer = 'TakWolf'\n    font.names.description = 'A pixel font'\n    font.names.copyright = 'Copyright (c) TakWolf'\n    font.names.license_description = 'This Font Software is licensed under the SIL Open Font License, Version 1.1'\n    font.names.vendor_url = 'https://github.com/TakWolf/kbitfont'\n    font.names.designer_url = 'https://takwolf.com'\n    font.names.license_url = 'https://openfontlicense.org'\n\n    font.characters[65] = KbitGlyph(\n        x=0,\n        y=14,\n        advance=8,\n        bitmap=[\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00],\n            [0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\n        ],\n    )\n\n    font.named_glyphs['.notdef'] = KbitGlyph(\n        x=0,\n        y=14,\n        advance=8,\n        bitmap=[\n            [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],\n            [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],\n        ],\n    )\n\n    font.save_kbits(outputs_dir.joinpath('my-font.kbits'))\n    font.save_kbitx(outputs_dir.joinpath('my-font.kbitx'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n### Load Kbits\n\n```python\nimport shutil\n\nfrom examples import assets_dir, build_dir\nfrom kbitfont import KbitFont\n\n\ndef main():\n    outputs_dir = build_dir.joinpath('load_kbits')\n    if outputs_dir.exists():\n        shutil.rmtree(outputs_dir)\n    outputs_dir.mkdir(parents=True)\n\n    font = KbitFont.load_kbits(assets_dir.joinpath('macintosh', 'Athens.kbits'))\n    print(f'name: {font.names.family}')\n    print(f'size: {font.props.em_height}')\n    print(f'ascent: {font.props.line_ascent}')\n    print(f'descent: {font.props.line_descent}')\n    print()\n    for code_point, glyph in sorted(font.characters.items()):\n        print(f'char: {chr(code_point)} ({code_point:04X})')\n        print(f'xy: {(glyph.x, glyph.y)}')\n        print(f'dimensions: {glyph.dimensions}')\n        print(f'advance: {glyph.advance}')\n        for bitmap_row in glyph.bitmap:\n            text = ''.join('  ' if color \u003c= 127 else '██' for color in bitmap_row)\n            print(f'{text}*')\n        print()\n    font.save_kbits(outputs_dir.joinpath('Athens.kbits'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n### Load Kbitx\n\n```python\nimport shutil\n\nfrom examples import assets_dir, build_dir\nfrom kbitfont import KbitFont\n\n\ndef main():\n    outputs_dir = build_dir.joinpath('load_kbitx')\n    if outputs_dir.exists():\n        shutil.rmtree(outputs_dir)\n    outputs_dir.mkdir(parents=True)\n\n    font = KbitFont.load_kbitx(assets_dir.joinpath('macintosh', 'Athens.kbitx'))\n    print(f'name: {font.names.family}')\n    print(f'size: {font.props.em_height}')\n    print(f'ascent: {font.props.line_ascent}')\n    print(f'descent: {font.props.line_descent}')\n    print()\n    for code_point, glyph in sorted(font.characters.items()):\n        print(f'char: {chr(code_point)} ({code_point:04X})')\n        print(f'xy: {(glyph.x, glyph.y)}')\n        print(f'dimensions: {glyph.dimensions}')\n        print(f'advance: {glyph.advance}')\n        for bitmap_row in glyph.bitmap:\n            text = ''.join('  ' if color \u003c= 127 else '██' for color in bitmap_row)\n            print(f'{text}*')\n        print()\n    font.save_kbitx(outputs_dir.joinpath('Athens.kbitx'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n## Specifications\n\n### Font Struct\n\n- [Font.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/Font.java)\n- [BitmapFont.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/BitmapFont.java)\n\n### Kbits\n\n- [KbitsBitmapFontImporter.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/importer/KbitsBitmapFontImporter.java)\n- [KbitsBitmapFontExporter.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/exporter/KbitsBitmapFontExporter.java)\n\n### Kbitx\n\n- [KbitxBitmapFontImporter.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/importer/KbitxBitmapFontImporter.java)\n- [KbitxBitmapFontExporter.java](bitsnpicas-spec/bitsnpicas/src/main/java/com/kreative/bitsnpicas/exporter/KbitxBitmapFontExporter.java)\n\n## Dependencies\n\n- [lxml](https://github.com/lxml/lxml)\n\n## License\n\nUnder the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakwolf%2Fkbitfont","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakwolf%2Fkbitfont","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakwolf%2Fkbitfont/lists"}