Pixel Font Builder
A library that helps create pixel style fonts.
Installation
pip install pixel-font-builder
Usage
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() -> None:
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='LATIN_CAPITAL_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[0x0041] = 'LATIN_CAPITAL_LETTER_A'
builder.save_otf(outputs_dir.joinpath('my-font.otf'))
builder.save_otf_woff(outputs_dir.joinpath('my-font.otf.woff'))
builder.save_otf_woff2(outputs_dir.joinpath('my-font.otf.woff2'))
builder.save_ttf(outputs_dir.joinpath('my-font.ttf'))
builder.save_ttf_woff(outputs_dir.joinpath('my-font.ttf.woff'))
builder.save_ttf_woff2(outputs_dir.joinpath('my-font.ttf.woff2'))
builder.save_ms_bitmap_ttf(outputs_dir.joinpath('my-font.ms.bitmap.ttf'))
builder.save_otb(outputs_dir.joinpath('my-font.otb'))
builder.save_dfont(outputs_dir.joinpath('my-font.dfont'))
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.outline_painter = opentype.SquareDotOutlinePainter()
builder.save_otf(outputs_dir.joinpath('my-font-square_dot.otf'))
builder.save_otf_woff(outputs_dir.joinpath('my-font-square_dot.otf.woff'))
builder.save_otf_woff2(outputs_dir.joinpath('my-font-square_dot.otf.woff2'))
builder.save_ttf(outputs_dir.joinpath('my-font-square_dot.ttf'))
builder.save_ttf_woff(outputs_dir.joinpath('my-font-square_dot.ttf.woff'))
builder.save_ttf_woff2(outputs_dir.joinpath('my-font-square_dot.ttf.woff2'))
builder.meta_info.family_name = 'My Font CircleDot'
builder.opentype_config.outline_painter = opentype.CircleDotOutlinePainter()
builder.save_otf(outputs_dir.joinpath('my-font-circle_dot.otf'))
builder.save_otf_woff(outputs_dir.joinpath('my-font-circle_dot.otf.woff'))
builder.save_otf_woff2(outputs_dir.joinpath('my-font-circle_dot.otf.woff2'))
builder.save_ttf(outputs_dir.joinpath('my-font-circle_dot.ttf'))
builder.save_ttf_woff(outputs_dir.joinpath('my-font-circle_dot.ttf.woff'))
builder.save_ttf_woff2(outputs_dir.joinpath('my-font-circle_dot.ttf.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 | .otf, .otc |
| TrueType | .ttf, .ttc |
| WOFF File Format 1.0 | .otf.woff, .ttf.woff |
| WOFF File Format 2.0 | .otf.woff2, .ttf.woff2 |
| Microsoft Bitmap Only SFNT | .ms.bitmap.ttf |
| X11 OpenType Bitmap | .otb |
| Macintosh Datafork TrueType | .dfont |
| Glyph Bitmap Distribution Format | .bdf |
| Portable Compiled Format | .pcf |
Dependencies
References
- Microsoft - OpenType Specification
- FreeType Glyph Conventions - Glyph Metrics
- OpenType Feature File Specification
- FontForge - Several formats for bitmap only sfnts
License
Metadata
Release files for pixel-font-builder 0.0.61
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pixel_font_builder-0.0.61.tar.gz | 24.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pixel_font_builder-0.0.61-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.4 kB
Release files / pixel_font_builder-0.0.61.tar.gz
| Download URL | pixel_font_builder-0.0.61.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfef58b24fe99c5eb378ad2c9fe4f7d83880950f706d96ed03bdcbd46814bdfd
|
|
BLAKE2b-256 checksum How to use checksums |
cf58b17686cebb848aa9224a3a248445cd6afc3090b27183dc295330c50fa894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pixel_font_builder-0.0.61-py3-none-any.whl
| Download URL | pixel_font_builder-0.0.61-py3-none-any.whl |
|---|---|
| Size | 41.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27a891c73b42a0c654a67568e6c2448ca036a50622f5fc6a3b530218d8e2cfa2
|
|
BLAKE2b-256 checksum How to use checksums |
ed17ff40693b91b874c0084913c579de9ae79966839a16271a354afdcdbe1815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pixel-font-builder 0.0.61
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.