| Name | pixel-font-builder JSON |
| Version |
0.0.42
JSON |
| download |
| home_page | None |
| Summary | A library that helps create pixel style fonts |
| upload_time | 2025-10-23 04:47:54 |
| maintainer | TakWolf |
| docs_url | None |
| author | TakWolf |
| requires_python | >=3.12 |
| license | None |
| keywords |
font
pixel
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# 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.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.character_mapping.update({
65: 'CAP_LETTER_A',
})
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/63/0f/4ca7705e18a8851863679e4d781c26a42b18995d3e5d37d5e28934f58546/pixel_font_builder-0.0.42.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.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.character_mapping.update({\n 65: 'CAP_LETTER_A',\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": null,
"summary": "A library that helps create pixel style fonts",
"version": "0.0.42",
"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": "849ad99139a627aaf00c100f617a2f7ef69712bc2cca38392cbf707802473ed5",
"md5": "202104471cd468091caa74fde7294ef8",
"sha256": "0fa3748456241da7a5cbe73ecbd6eb5f6f9da12d6db278e9543e2dee1e45a9be"
},
"downloads": -1,
"filename": "pixel_font_builder-0.0.42-py3-none-any.whl",
"has_sig": false,
"md5_digest": "202104471cd468091caa74fde7294ef8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 18119,
"upload_time": "2025-10-23T04:47:53",
"upload_time_iso_8601": "2025-10-23T04:47:53.894598Z",
"url": "https://files.pythonhosted.org/packages/84/9a/d99139a627aaf00c100f617a2f7ef69712bc2cca38392cbf707802473ed5/pixel_font_builder-0.0.42-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "630f4ca7705e18a8851863679e4d781c26a42b18995d3e5d37d5e28934f58546",
"md5": "cbd963d28b61c76892fa8b6cf7b1722c",
"sha256": "a20d2d3826aa8f6de820955bf7e994269f885e448eaf7c9f1f00006b6b12081d"
},
"downloads": -1,
"filename": "pixel_font_builder-0.0.42.tar.gz",
"has_sig": false,
"md5_digest": "cbd963d28b61c76892fa8b6cf7b1722c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 12110,
"upload_time": "2025-10-23T04:47:54",
"upload_time_iso_8601": "2025-10-23T04:47:54.832691Z",
"url": "https://files.pythonhosted.org/packages/63/0f/4ca7705e18a8851863679e4d781c26a42b18995d3e5d37d5e28934f58546/pixel_font_builder-0.0.42.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-23 04:47:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TakWolf",
"github_project": "pixel-font-builder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pixel-font-builder"
}