# Pixel Font Builder
[](https://www.python.org)
[](https://pypi.org/project/pixel-font-builder/)
A library that helps create pixel style fonts.
## Installation
```shell
pip install pixel-font-builder
```
## Usage
```python
import shutil
from datetime import datetime
from examples import build_dir
from pixel_font_builder import FontBuilder, WeightName, SerifStyle, SlantStyle, WidthStyle, Glyph, opentype
def main():
outputs_dir = build_dir.joinpath('create')
if outputs_dir.exists():
shutil.rmtree(outputs_dir)
outputs_dir.mkdir(parents=True)
builder = FontBuilder()
builder.font_metric.font_size = 16
builder.font_metric.horizontal_layout.ascent = 14
builder.font_metric.horizontal_layout.descent = -2
builder.font_metric.vertical_layout.ascent = 8
builder.font_metric.vertical_layout.descent = -8
builder.font_metric.x_height = 7
builder.font_metric.cap_height = 10
builder.font_metric.underline_position = -2
builder.font_metric.underline_thickness = 1
builder.font_metric.strikeout_position = 6
builder.font_metric.strikeout_thickness = 1
builder.meta_info.version = '1.0.0'
builder.meta_info.created_time = datetime.fromisoformat('2024-01-01T00:00:00Z')
builder.meta_info.modified_time = builder.meta_info.created_time
builder.meta_info.family_name = 'My Font'
builder.meta_info.weight_name = WeightName.REGULAR
builder.meta_info.serif_style = SerifStyle.SANS_SERIF
builder.meta_info.slant_style = SlantStyle.NORMAL
builder.meta_info.width_style = WidthStyle.MONOSPACED
builder.meta_info.manufacturer = 'Pixel Font Studio'
builder.meta_info.designer = 'TakWolf'
builder.meta_info.description = 'A pixel font'
builder.meta_info.copyright_info = 'Copyright (c) TakWolf'
builder.meta_info.license_info = 'This Font Software is licensed under the SIL Open Font License, Version 1.1'
builder.meta_info.vendor_url = 'https://github.com/TakWolf/pixel-font-builder'
builder.meta_info.designer_url = 'https://takwolf.com'
builder.meta_info.license_url = 'https://openfontlicense.org'
builder.character_mapping.update({
65: 'CAP_LETTER_A',
})
builder.glyphs.append(Glyph(
name='.notdef',
horizontal_offset=(0, -2),
advance_width=8,
vertical_offset=(-4, 0),
advance_height=16,
bitmap=[
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1],
],
))
builder.glyphs.append(Glyph(
name='CAP_LETTER_A',
horizontal_offset=(0, -2),
advance_width=8,
vertical_offset=(-4, 0),
advance_height=16,
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],
],
))
builder.save_otf(outputs_dir.joinpath('my-font.otf'))
builder.save_otf(outputs_dir.joinpath('my-font.otf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_otf(outputs_dir.joinpath('my-font.otf.woff2'), flavor=opentype.Flavor.WOFF2)
builder.save_ttf(outputs_dir.joinpath('my-font.ttf'))
builder.save_ttf(outputs_dir.joinpath('my-font.ttf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_ttf(outputs_dir.joinpath('my-font.ttf.woff2'), flavor=opentype.Flavor.WOFF2)
builder.save_bdf(outputs_dir.joinpath('my-font.bdf'))
builder.save_pcf(outputs_dir.joinpath('my-font.pcf'))
builder.meta_info.family_name = 'My Font SquareDot'
builder.opentype_config.outlines_painter = opentype.SquareDotOutlinesPainter()
builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf'))
builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf.woff2'), flavor=opentype.Flavor.WOFF2)
builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf'))
builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf.woff2'), flavor=opentype.Flavor.WOFF2)
builder.meta_info.family_name = 'My Font CircleDot'
builder.opentype_config.outlines_painter = opentype.CircleDotOutlinesPainter()
builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf'))
builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf.woff2'), flavor=opentype.Flavor.WOFF2)
builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf'))
builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf.woff'), flavor=opentype.Flavor.WOFF)
builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf.woff2'), flavor=opentype.Flavor.WOFF2)
if __name__ == '__main__':
main()
```
## Coordinate Systems
Use the same coordinate systems as OpenType.
### Horizontal Layout

### Vertical Layout

## Supported Output Formats
| Format | File Extension |
|---|---|
| [OpenType](https://learn.microsoft.com/en-us/typography/opentype/) | `.otf`, `.otc` |
| [TrueType](https://learn.microsoft.com/en-us/typography/truetype/) | `.ttf`, `.ttc` |
| [WOFF File Format 1.0](https://www.w3.org/TR/WOFF/) | `.otf.woff`, `.ttf.woff` |
| [WOFF File Format 2.0](https://www.w3.org/TR/WOFF2/) | `.otf.woff2`, `.ttf.woff2` |
| [Glyph Bitmap Distribution Format](https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format) | `.bdf` |
| [Portable Compiled Format](https://en.wikipedia.org/wiki/Portable_Compiled_Format) | `.pcf` |
## Dependencies
- [FontTools](https://github.com/fonttools/fonttools)
- [BdfFont.Python](https://github.com/TakWolf/bdffont-python)
- [PcfFont.Python](https://github.com/TakWolf/pcffont-python)
## References
- [Microsoft - OpenType Specification](https://learn.microsoft.com/en-us/typography/opentype/spec/)
- [FreeType Glyph Conventions - Glyph Metrics](https://freetype.org/freetype2/docs/glyphs/glyphs-3.html)
- [OpenType Feature File Specification](https://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileSpecification.html)
## License
[MIT License](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "pixel-font-builder",
"maintainer": "TakWolf",
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "font, pixel",
"author": "TakWolf",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/62/42/451c1416a7ec3c97156f5b572736c12f50b50086c3e1d2d8fcc87c217a57/pixel_font_builder-0.0.38.tar.gz",
"platform": null,
"description": "# Pixel Font Builder\n\n[](https://www.python.org)\n[](https://pypi.org/project/pixel-font-builder/)\n\nA library that helps create pixel style fonts.\n\n## Installation\n\n```shell\npip install pixel-font-builder\n```\n\n## Usage\n\n```python\nimport shutil\nfrom datetime import datetime\n\nfrom examples import build_dir\nfrom pixel_font_builder import FontBuilder, WeightName, SerifStyle, SlantStyle, WidthStyle, Glyph, opentype\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 builder = FontBuilder()\n builder.font_metric.font_size = 16\n builder.font_metric.horizontal_layout.ascent = 14\n builder.font_metric.horizontal_layout.descent = -2\n builder.font_metric.vertical_layout.ascent = 8\n builder.font_metric.vertical_layout.descent = -8\n builder.font_metric.x_height = 7\n builder.font_metric.cap_height = 10\n builder.font_metric.underline_position = -2\n builder.font_metric.underline_thickness = 1\n builder.font_metric.strikeout_position = 6\n builder.font_metric.strikeout_thickness = 1\n\n builder.meta_info.version = '1.0.0'\n builder.meta_info.created_time = datetime.fromisoformat('2024-01-01T00:00:00Z')\n builder.meta_info.modified_time = builder.meta_info.created_time\n builder.meta_info.family_name = 'My Font'\n builder.meta_info.weight_name = WeightName.REGULAR\n builder.meta_info.serif_style = SerifStyle.SANS_SERIF\n builder.meta_info.slant_style = SlantStyle.NORMAL\n builder.meta_info.width_style = WidthStyle.MONOSPACED\n builder.meta_info.manufacturer = 'Pixel Font Studio'\n builder.meta_info.designer = 'TakWolf'\n builder.meta_info.description = 'A pixel font'\n builder.meta_info.copyright_info = 'Copyright (c) TakWolf'\n builder.meta_info.license_info = 'This Font Software is licensed under the SIL Open Font License, Version 1.1'\n builder.meta_info.vendor_url = 'https://github.com/TakWolf/pixel-font-builder'\n builder.meta_info.designer_url = 'https://takwolf.com'\n builder.meta_info.license_url = 'https://openfontlicense.org'\n\n builder.character_mapping.update({\n 65: 'CAP_LETTER_A',\n })\n\n builder.glyphs.append(Glyph(\n name='.notdef',\n horizontal_offset=(0, -2),\n advance_width=8,\n vertical_offset=(-4, 0),\n advance_height=16,\n bitmap=[\n [1, 1, 1, 1, 1, 1, 1, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 1],\n [1, 1, 1, 1, 1, 1, 1, 1],\n ],\n ))\n builder.glyphs.append(Glyph(\n name='CAP_LETTER_A',\n horizontal_offset=(0, -2),\n advance_width=8,\n vertical_offset=(-4, 0),\n advance_height=16,\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 builder.save_otf(outputs_dir.joinpath('my-font.otf'))\n builder.save_otf(outputs_dir.joinpath('my-font.otf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_otf(outputs_dir.joinpath('my-font.otf.woff2'), flavor=opentype.Flavor.WOFF2)\n builder.save_ttf(outputs_dir.joinpath('my-font.ttf'))\n builder.save_ttf(outputs_dir.joinpath('my-font.ttf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_ttf(outputs_dir.joinpath('my-font.ttf.woff2'), flavor=opentype.Flavor.WOFF2)\n builder.save_bdf(outputs_dir.joinpath('my-font.bdf'))\n builder.save_pcf(outputs_dir.joinpath('my-font.pcf'))\n\n builder.meta_info.family_name = 'My Font SquareDot'\n builder.opentype_config.outlines_painter = opentype.SquareDotOutlinesPainter()\n builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf'))\n builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf.woff2'), flavor=opentype.Flavor.WOFF2)\n builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf'))\n builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf.woff2'), flavor=opentype.Flavor.WOFF2)\n\n builder.meta_info.family_name = 'My Font CircleDot'\n builder.opentype_config.outlines_painter = opentype.CircleDotOutlinesPainter()\n builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf'))\n builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf.woff2'), flavor=opentype.Flavor.WOFF2)\n builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf'))\n builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf.woff'), flavor=opentype.Flavor.WOFF)\n builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf.woff2'), flavor=opentype.Flavor.WOFF2)\n\n\nif __name__ == '__main__':\n main()\n```\n\n## Coordinate Systems\n\nUse the same coordinate systems as OpenType.\n\n### Horizontal Layout\n\n\n\n### Vertical Layout\n\n\n\n## Supported Output Formats\n\n| Format | File Extension |\n|---|---|\n| [OpenType](https://learn.microsoft.com/en-us/typography/opentype/) | `.otf`, `.otc` |\n| [TrueType](https://learn.microsoft.com/en-us/typography/truetype/) | `.ttf`, `.ttc` |\n| [WOFF File Format 1.0](https://www.w3.org/TR/WOFF/) | `.otf.woff`, `.ttf.woff` |\n| [WOFF File Format 2.0](https://www.w3.org/TR/WOFF2/) | `.otf.woff2`, `.ttf.woff2` |\n| [Glyph Bitmap Distribution Format](https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format) | `.bdf` |\n| [Portable Compiled Format](https://en.wikipedia.org/wiki/Portable_Compiled_Format) | `.pcf` |\n\n## Dependencies\n\n- [FontTools](https://github.com/fonttools/fonttools)\n- [BdfFont.Python](https://github.com/TakWolf/bdffont-python)\n- [PcfFont.Python](https://github.com/TakWolf/pcffont-python)\n\n## References\n\n- [Microsoft - OpenType Specification](https://learn.microsoft.com/en-us/typography/opentype/spec/)\n- [FreeType Glyph Conventions - Glyph Metrics](https://freetype.org/freetype2/docs/glyphs/glyphs-3.html)\n- [OpenType Feature File Specification](https://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileSpecification.html)\n\n## License\n\n[MIT License](LICENSE)\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A library that helps create pixel style fonts",
"version": "0.0.38",
"project_urls": {
"homepage": "https://github.com/TakWolf/pixel-font-builder",
"issues": "https://github.com/TakWolf/pixel-font-builder/issues",
"source": "https://github.com/TakWolf/pixel-font-builder"
},
"split_keywords": [
"font",
" pixel"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "18e33d9794a9378ffab66afb2891cbb977f6568096251d03c12097c164c89e16",
"md5": "ca48aa8a9d397371a0ee05269d21bc15",
"sha256": "152c303825f883e22b717e060397e958c1729d603ad8029d806dfcc4b833d72f"
},
"downloads": -1,
"filename": "pixel_font_builder-0.0.38-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ca48aa8a9d397371a0ee05269d21bc15",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 18224,
"upload_time": "2025-08-07T14:30:57",
"upload_time_iso_8601": "2025-08-07T14:30:57.044248Z",
"url": "https://files.pythonhosted.org/packages/18/e3/3d9794a9378ffab66afb2891cbb977f6568096251d03c12097c164c89e16/pixel_font_builder-0.0.38-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6242451c1416a7ec3c97156f5b572736c12f50b50086c3e1d2d8fcc87c217a57",
"md5": "88e15d3c9f50f2625d24658ba67da1e9",
"sha256": "07ae89c6467e4d74c98d5e72723528debf030a9dbd8ef95aa8af3979994ad6ff"
},
"downloads": -1,
"filename": "pixel_font_builder-0.0.38.tar.gz",
"has_sig": false,
"md5_digest": "88e15d3c9f50f2625d24658ba67da1e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 21024,
"upload_time": "2025-08-07T14:30:58",
"upload_time_iso_8601": "2025-08-07T14:30:58.131160Z",
"url": "https://files.pythonhosted.org/packages/62/42/451c1416a7ec3c97156f5b572736c12f50b50086c3e1d2d8fcc87c217a57/pixel_font_builder-0.0.38.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-07 14:30:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TakWolf",
"github_project": "pixel-font-builder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "fonttools",
"specs": [
[
"==",
"4.59.0"
]
]
},
{
"name": "bdffont",
"specs": [
[
"==",
"0.0.32"
]
]
},
{
"name": "pcffont",
"specs": [
[
"==",
"0.0.21"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"8.4.1"
]
]
},
{
"name": "pypng",
"specs": [
[
"==",
"0.20220715.0"
]
]
}
],
"lcname": "pixel-font-builder"
}