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_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://scripts.sil.org/OFL'
builder.meta_info.sample_text = 'Hello World!'
builder.horizontal_header.ascent = 10
builder.horizontal_header.descent = -2
builder.vertical_header.ascent = 10
builder.vertical_header.descent = -2
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'))
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.15.tar.gz
(17.1 kB
view hashes)
Built Distribution
Close
Hashes for pixel_font_builder-0.0.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d909db9c9937a27c319a367a694817146b31e86b6a24357d060b37a790b3be7b |
|
MD5 | cbab9ff9f66a2c27faf8458c3def3145 |
|
BLAKE2b-256 | ad8cf36385d5a45ada7d2c97d4bfa4f660fac563129df461e02ad25aae1dbb13 |
Close
Hashes for pixel_font_builder-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4d8ac2480780e461279511611108dd4588759b42595de74dda5653c6833038 |
|
MD5 | c50819f0e535290ec05463c801dfe416 |
|
BLAKE2b-256 | 8cce37a08d8c2a534ff0cfb761fcc55b56c7ab59115ea1c6122a3475c7c5c8a2 |