A library that helps create pixel style fonts.
Project description
Pixel Font Builder
A library that helps create pixel style fonts.
Installation
pip install pixel-font-builder
Usage
import logging
import os
import shutil
from examples import build_dir
from pixel_font_builder import FontBuilder, StyleName, SerifMode, WidthMode, Glyph, opentype
logging.basicConfig(level=logging.DEBUG)
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_infos.version = '1.0.0'
builder.meta_infos.family_name = 'My Pixel'
builder.meta_infos.style_name = StyleName.REGULAR
builder.meta_infos.serif_mode = SerifMode.SANS_SERIF
builder.meta_infos.width_mode = WidthMode.MONOSPACED
builder.meta_infos.manufacturer = 'Pixel Font Studio'
builder.meta_infos.designer = 'TakWolf'
builder.meta_infos.description = 'A demo pixel font.'
builder.meta_infos.copyright_info = 'Copyright (c) TakWolf'
builder.meta_infos.license_info = 'This Font Software is licensed under the SIL Open Font License, Version 1.1.'
builder.meta_infos.vendor_url = 'https://github.com/TakWolf/pixel-font-builder'
builder.meta_infos.designer_url = 'https://takwolf.com'
builder.meta_infos.license_url = 'https://scripts.sil.org/OFL'
builder.meta_infos.sample_text = 'Hello World!'
builder.horizontal_header.ascent = 10
builder.horizontal_header.descent = -2
builder.horizontal_header.x_height = 5
builder.horizontal_header.cap_height = 7
builder.vertical_header.ascent = 10
builder.vertical_header.descent = -2
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'))
if __name__ == '__main__':
main()
Dependencies
License
Under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pixel_font_builder-0.0.12.tar.gz
(17.0 kB
view details)
Built Distribution
File details
Details for the file pixel_font_builder-0.0.12.tar.gz
.
File metadata
- Download URL: pixel_font_builder-0.0.12.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a86034ed09fe727c25f465129b0a7a7d0767b7b161ba5aa7efe893c8ece9c2d |
|
MD5 | ba377c525855b8f9c88cedfc098418b5 |
|
BLAKE2b-256 | 73ae2710046bae5b57150f766b44c0a9966d0b854e8a8bb48cb15fe9bc4b5a89 |
File details
Details for the file pixel_font_builder-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: pixel_font_builder-0.0.12-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8317710421ee165db84a37660cd46d9be840600159105f849b9328b1062714c1 |
|
MD5 | e65b490f1d6507cc091788002740afcb |
|
BLAKE2b-256 | 89634f63b14c7ec16950ffca66ceef3359009c48be7c87849edbc6a87fc130ef |