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.character_mapping.update({
ord('A'): 'CAP_LETTER_A',
})
builder.glyphs.append(Glyph(
name='.notdef',
advance_width=8,
offset=(0, -2),
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,
offset=(0, -2),
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.11.tar.gz
(16.7 kB
view hashes)
Built Distribution
Close
Hashes for pixel_font_builder-0.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcd671d17d4bb62c44c8f9486bc9ec5e1a3ea0486761af65c61d377060b1057c |
|
MD5 | e8c6f69baf08e7cbe9ad3d46282e304c |
|
BLAKE2b-256 | 5494303c28cada3b4e4c53944cc43eb4f24730dc87e3e35c2edd9145b9a749e6 |
Close
Hashes for pixel_font_builder-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c32da4db59b64dcd5ef0d07d4759a2cf6457587f4371c26c32233b901a6ada87 |
|
MD5 | 6f9ece5bda8925a01765529a1414afdd |
|
BLAKE2b-256 | dd40e93f599f1c94ca8515a3631282c4353dceb3104a50552a069611c6de3c57 |