pixel-font-builder


Namepixel-font-builder JSON
Version 0.0.21 PyPI version JSON
download
home_pageNone
SummaryA library that helps create pixel style fonts.
upload_time2024-04-25 18:50:37
maintainerTakWolf
docs_urlNone
authorTakWolf
requires_python>=3.11
licenseMIT License
keywords font pixel
VCS
bugtrack_url
requirements fonttools Brotli bdffont pcffont pytest pypng
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pixel Font Builder

[![Python](https://img.shields.io/badge/python-3.11-brightgreen)](https://www.python.org)
[![PyPI](https://img.shields.io/pypi/v/pixel-font-builder)](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 os
import shutil

from examples import build_dir
from pixel_font_builder import FontBuilder, StyleName, SerifMode, WidthMode, Glyph, opentype


def main():
    outputs_dir = os.path.join(build_dir, 'create')
    if os.path.exists(outputs_dir):
        shutil.rmtree(outputs_dir)
    os.makedirs(outputs_dir)

    builder = FontBuilder(12)

    builder.meta_info.version = '1.0.0'
    builder.meta_info.family_name = 'My Pixel'
    builder.meta_info.style_name = StyleName.REGULAR
    builder.meta_info.serif_mode = SerifMode.SANS_SERIF
    builder.meta_info.width_mode = WidthMode.MONOSPACED
    builder.meta_info.manufacturer = 'Pixel Font Studio'
    builder.meta_info.designer = 'TakWolf'
    builder.meta_info.description = 'A demo 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.meta_info.sample_text = 'Hello World!'

    builder.horizontal_header.ascent = 10
    builder.horizontal_header.descent = -2

    builder.vertical_header.ascent = 6
    builder.vertical_header.descent = -6

    builder.os2_config.x_height = 5
    builder.os2_config.cap_height = 7

    builder.character_mapping.update({
        ord('A'): 'CAP_LETTER_A',
    })

    builder.glyphs.append(Glyph(
        name='.notdef',
        advance_width=8,
        advance_height=12,
        horizontal_origin=(0, -2),
        vertical_origin_y=0,
        data=[
            [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',
        advance_width=8,
        advance_height=12,
        horizontal_origin=(0, -2),
        vertical_origin_y=0,
        data=[
            [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(os.path.join(outputs_dir, 'my-pixel.otf'))
    builder.save_otf(os.path.join(outputs_dir, 'my-pixel.woff2'), flavor=opentype.Flavor.WOFF2)
    builder.save_ttf(os.path.join(outputs_dir, 'my-font.ttf'))
    builder.save_bdf(os.path.join(outputs_dir, 'my-font.bdf'))
    builder.save_pcf(os.path.join(outputs_dir, 'my-font.pcf'))


if __name__ == '__main__':
    main()
```

## Dependencies

- [FontTools](https://github.com/fonttools/fonttools)
- [Brotli](https://github.com/google/brotli)
- [BdfFont](https://github.com/TakWolf/bdffont)
- [PcfFont](https://github.com/TakWolf/pcffont)

## References

- [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": "pixel-font-builder",
    "maintainer": "TakWolf",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "font, pixel",
    "author": "TakWolf",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b2/63/fed2c606414131eccc18e74d087679513f6fca8587533d48c11627eb0929/pixel_font_builder-0.0.21.tar.gz",
    "platform": null,
    "description": "# Pixel 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/pixel-font-builder)](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 os\nimport shutil\n\nfrom examples import build_dir\nfrom pixel_font_builder import FontBuilder, StyleName, SerifMode, WidthMode, Glyph, opentype\n\n\ndef main():\n    outputs_dir = os.path.join(build_dir, 'create')\n    if os.path.exists(outputs_dir):\n        shutil.rmtree(outputs_dir)\n    os.makedirs(outputs_dir)\n\n    builder = FontBuilder(12)\n\n    builder.meta_info.version = '1.0.0'\n    builder.meta_info.family_name = 'My Pixel'\n    builder.meta_info.style_name = StyleName.REGULAR\n    builder.meta_info.serif_mode = SerifMode.SANS_SERIF\n    builder.meta_info.width_mode = WidthMode.MONOSPACED\n    builder.meta_info.manufacturer = 'Pixel Font Studio'\n    builder.meta_info.designer = 'TakWolf'\n    builder.meta_info.description = 'A demo 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    builder.meta_info.sample_text = 'Hello World!'\n\n    builder.horizontal_header.ascent = 10\n    builder.horizontal_header.descent = -2\n\n    builder.vertical_header.ascent = 6\n    builder.vertical_header.descent = -6\n\n    builder.os2_config.x_height = 5\n    builder.os2_config.cap_height = 7\n\n    builder.character_mapping.update({\n        ord('A'): 'CAP_LETTER_A',\n    })\n\n    builder.glyphs.append(Glyph(\n        name='.notdef',\n        advance_width=8,\n        advance_height=12,\n        horizontal_origin=(0, -2),\n        vertical_origin_y=0,\n        data=[\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        advance_width=8,\n        advance_height=12,\n        horizontal_origin=(0, -2),\n        vertical_origin_y=0,\n        data=[\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(os.path.join(outputs_dir, 'my-pixel.otf'))\n    builder.save_otf(os.path.join(outputs_dir, 'my-pixel.woff2'), flavor=opentype.Flavor.WOFF2)\n    builder.save_ttf(os.path.join(outputs_dir, 'my-font.ttf'))\n    builder.save_bdf(os.path.join(outputs_dir, 'my-font.bdf'))\n    builder.save_pcf(os.path.join(outputs_dir, 'my-font.pcf'))\n\n\nif __name__ == '__main__':\n    main()\n```\n\n## Dependencies\n\n- [FontTools](https://github.com/fonttools/fonttools)\n- [Brotli](https://github.com/google/brotli)\n- [BdfFont](https://github.com/TakWolf/bdffont)\n- [PcfFont](https://github.com/TakWolf/pcffont)\n\n## References\n\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 pixel style fonts.",
    "version": "0.0.21",
    "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": "",
            "digests": {
                "blake2b_256": "cb6c1f29d652e18af62159d6307905497387c06bf3185b4e59feb5e566c46029",
                "md5": "f70a5ed1fff8348a72c2f507dbcce3b6",
                "sha256": "16dfc894a396ccb5f31f682df5c123b4083192ae5aee2cd60e70cb5c13289f5f"
            },
            "downloads": -1,
            "filename": "pixel_font_builder-0.0.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f70a5ed1fff8348a72c2f507dbcce3b6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 13219,
            "upload_time": "2024-04-25T18:50:36",
            "upload_time_iso_8601": "2024-04-25T18:50:36.476927Z",
            "url": "https://files.pythonhosted.org/packages/cb/6c/1f29d652e18af62159d6307905497387c06bf3185b4e59feb5e566c46029/pixel_font_builder-0.0.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b263fed2c606414131eccc18e74d087679513f6fca8587533d48c11627eb0929",
                "md5": "4e55a791ae2f25934d1542212fff08f7",
                "sha256": "b4b41227ebc86cfb48cd3a19e73c1480f44e692d934f6e7a5344c3d5bbbad774"
            },
            "downloads": -1,
            "filename": "pixel_font_builder-0.0.21.tar.gz",
            "has_sig": false,
            "md5_digest": "4e55a791ae2f25934d1542212fff08f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 18092,
            "upload_time": "2024-04-25T18:50:37",
            "upload_time_iso_8601": "2024-04-25T18:50:37.554605Z",
            "url": "https://files.pythonhosted.org/packages/b2/63/fed2c606414131eccc18e74d087679513f6fca8587533d48c11627eb0929/pixel_font_builder-0.0.21.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 18:50:37",
    "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.51.0"
                ]
            ]
        },
        {
            "name": "Brotli",
            "specs": [
                [
                    "==",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "bdffont",
            "specs": [
                [
                    "==",
                    "0.0.20"
                ]
            ]
        },
        {
            "name": "pcffont",
            "specs": [
                [
                    "==",
                    "0.0.6"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.1.1"
                ]
            ]
        },
        {
            "name": "pypng",
            "specs": [
                [
                    "==",
                    "0.20220715.0"
                ]
            ]
        }
    ],
    "lcname": "pixel-font-builder"
}
        
Elapsed time: 0.28379s