# Dotted Font Builder
[![Python](https://img.shields.io/badge/python-3.11-brightgreen)](https://www.python.org)
[![PyPI](https://img.shields.io/pypi/v/dotted-font-builder)](https://pypi.org/project/dotted-font-builder/)
A library that helps create dotted style fonts.
## Installation
```shell
pip install dotted-font-builder
```
## Usage
```python
import datetime
import shutil
from examples import build_dir
from dotted_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 = 12
builder.font_metric.horizontal_layout.ascent = 10
builder.font_metric.horizontal_layout.descent = -2
builder.font_metric.vertical_layout.ascent = 6
builder.font_metric.vertical_layout.descent = -6
builder.font_metric.x_height = 5
builder.font_metric.cap_height = 7
builder.meta_info.version = '1.0.0'
builder.meta_info.created_time = datetime.datetime.fromisoformat('2024-01-01T00:00:00Z')
builder.meta_info.modified_time = builder.meta_info.created_time
builder.meta_info.family_name = 'My Dotted'
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 = ''
builder.meta_info.designer = 'OverflowCat'
builder.meta_info.description = 'A demo dotted font.'
builder.meta_info.copyright_info = 'Copyright (c) OverflowCat'
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/OverflowCat/dotted-font-builder'
builder.meta_info.designer_url = 'https://overflow.cat'
builder.meta_info.license_url = 'https://openfontlicense.org'
builder.meta_info.sample_text = 'Hello World!'
builder.character_mapping.update({
ord('A'): 'CAP_LETTER_A',
})
builder.glyphs.append(Glyph(
name='.notdef',
horizontal_origin=(0, -2),
advance_width=8,
vertical_origin=(-4, 0),
advance_height=12,
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, 1, 1, 1, 1, 1, 1, 1],
],
))
builder.glyphs.append(Glyph(
name='CAP_LETTER_A',
horizontal_origin=(0, -2),
advance_width=8,
vertical_origin=(-4, 0),
advance_height=12,
bitmap=[
[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-dotted.otf'))
builder.save_otf(outputs_dir.joinpath('my-dotted.woff2'), flavor=opentype.Flavor.WOFF2)
builder.save_ttf(outputs_dir.joinpath('my-font.ttf'))
builder.save_bdf(outputs_dir.joinpath('my-font.bdf'))
builder.save_pcf(outputs_dir.joinpath('my-font.pcf'))
if __name__ == '__main__':
main()
```
## Coordinate Systems
Use the same coordinate systems as OpenType.
### Horizontal Layout
![Horizontal Layout](https://freetype.org/freetype2/docs/glyphs/glyph-metrics-3.svg)
### Vertical Layout
![Vertical Layout](https://freetype.org/freetype2/docs/glyphs/glyph-metrics-4.svg)
## Supported Output Formats
| Format | File Extension |
|---|---|
| [OpenType](https://learn.microsoft.com/en-us/typography/opentype/) | `.otf`, `.otc`, `.woff`, `.woff2` |
| [TrueType](https://learn.microsoft.com/en-us/typography/truetype/) | `.ttf`, `.ttc`, `.woff`, `.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](https://github.com/TakWolf/bdffont)
- [PcfFont](https://github.com/TakWolf/pcffont)
## References
- [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
Under the [MIT license](LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "dotted-font-builder",
"maintainer": "OverflowCat",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "font, pixel",
"author": "OverflowCat, TakWolf",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/4d/ce/782b4d3190f7501d0954d943a6033012e3e19104e7ff0f248524b81d1c55/dotted_font_builder-0.0.1.tar.gz",
"platform": null,
"description": "# Dotted Font Builder\n\n[![Python](https://img.shields.io/badge/python-3.11-brightgreen)](https://www.python.org)\n[![PyPI](https://img.shields.io/pypi/v/dotted-font-builder)](https://pypi.org/project/dotted-font-builder/)\n\nA library that helps create dotted style fonts.\n\n## Installation\n\n```shell\npip install dotted-font-builder\n```\n\n## Usage\n\n```python\nimport datetime\nimport shutil\n\nfrom examples import build_dir\nfrom dotted_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 = 12\n builder.font_metric.horizontal_layout.ascent = 10\n builder.font_metric.horizontal_layout.descent = -2\n builder.font_metric.vertical_layout.ascent = 6\n builder.font_metric.vertical_layout.descent = -6\n builder.font_metric.x_height = 5\n builder.font_metric.cap_height = 7\n\n builder.meta_info.version = '1.0.0'\n builder.meta_info.created_time = datetime.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 Dotted'\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 = ''\n builder.meta_info.designer = 'OverflowCat'\n builder.meta_info.description = 'A demo dotted font.'\n builder.meta_info.copyright_info = 'Copyright (c) OverflowCat'\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/OverflowCat/dotted-font-builder'\n builder.meta_info.designer_url = 'https://overflow.cat'\n builder.meta_info.license_url = 'https://openfontlicense.org'\n builder.meta_info.sample_text = 'Hello World!'\n\n builder.character_mapping.update({\n ord('A'): 'CAP_LETTER_A',\n })\n\n builder.glyphs.append(Glyph(\n name='.notdef',\n horizontal_origin=(0, -2),\n advance_width=8,\n vertical_origin=(-4, 0),\n advance_height=12,\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, 1, 1, 1, 1, 1, 1, 1],\n ],\n ))\n builder.glyphs.append(Glyph(\n name='CAP_LETTER_A',\n horizontal_origin=(0, -2),\n advance_width=8,\n vertical_origin=(-4, 0),\n advance_height=12,\n bitmap=[\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-dotted.otf'))\n builder.save_otf(outputs_dir.joinpath('my-dotted.woff2'), flavor=opentype.Flavor.WOFF2)\n builder.save_ttf(outputs_dir.joinpath('my-font.ttf'))\n builder.save_bdf(outputs_dir.joinpath('my-font.bdf'))\n builder.save_pcf(outputs_dir.joinpath('my-font.pcf'))\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![Horizontal Layout](https://freetype.org/freetype2/docs/glyphs/glyph-metrics-3.svg)\n\n### Vertical Layout\n\n![Vertical Layout](https://freetype.org/freetype2/docs/glyphs/glyph-metrics-4.svg)\n\n## Supported Output Formats\n\n| Format | File Extension |\n|---|---|\n| [OpenType](https://learn.microsoft.com/en-us/typography/opentype/) | `.otf`, `.otc`, `.woff`, `.woff2` |\n| [TrueType](https://learn.microsoft.com/en-us/typography/truetype/) | `.ttf`, `.ttc`, `.woff`, `.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](https://github.com/TakWolf/bdffont)\n- [PcfFont](https://github.com/TakWolf/pcffont)\n\n## References\n\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\nUnder the [MIT license](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A library that helps create dotted style fonts.",
"version": "0.0.1",
"project_urls": {
"homepage": "https://github.com/OverflowCat/dotted-font-builder",
"issues": "https://github.com/OverflowCat/dotted-font-builder/issues",
"source": "https://github.com/OverflowCat/dotted-font-builder"
},
"split_keywords": [
"font",
" pixel"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4db58531be68f37148566e64a75c5db06f7eec0019eba8c4aa97383afc808985",
"md5": "30431093faf34948d92e59a1efc87451",
"sha256": "9ba96a1f56fddff7d7d51fa90eb13b06058a4b5e089f449a3af6016d75dfc0b1"
},
"downloads": -1,
"filename": "dotted_font_builder-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "30431093faf34948d92e59a1efc87451",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 14269,
"upload_time": "2024-11-22T11:06:58",
"upload_time_iso_8601": "2024-11-22T11:06:58.395810Z",
"url": "https://files.pythonhosted.org/packages/4d/b5/8531be68f37148566e64a75c5db06f7eec0019eba8c4aa97383afc808985/dotted_font_builder-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4dce782b4d3190f7501d0954d943a6033012e3e19104e7ff0f248524b81d1c55",
"md5": "6f8f2104fd544d5802dfae140bc3b49a",
"sha256": "2c7fceaf38112c930f96a436abca3bc544cf56547925266983502dbefba21e06"
},
"downloads": -1,
"filename": "dotted_font_builder-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6f8f2104fd544d5802dfae140bc3b49a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 19215,
"upload_time": "2024-11-22T11:07:00",
"upload_time_iso_8601": "2024-11-22T11:07:00.538878Z",
"url": "https://files.pythonhosted.org/packages/4d/ce/782b4d3190f7501d0954d943a6033012e3e19104e7ff0f248524b81d1c55/dotted_font_builder-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 11:07:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OverflowCat",
"github_project": "dotted-font-builder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "dotted-font-builder"
}