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.vertical_header.ascent = 10
builder.vertical_header.descent = -2
builder.properties.x_height = 5
builder.properties.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.14.tar.gz
(17.1 kB
view hashes)
Built Distribution
Close
Hashes for pixel_font_builder-0.0.14.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5de36c96ffd14eae5ee64ed02143d46047a5f2c12626f34fc2cb49b8682a7586 |
|
MD5 | d61737144d6a6e8a3666ec41bebcd707 |
|
BLAKE2b-256 | 8740e18a0b3ecfcf534fd21d5afee1ec06ad6103026179fedc2792b59d193ccf |
Close
Hashes for pixel_font_builder-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 220b9d54236d755b7a991d548828581f48abb4f892c725ddc7fdb3cf45a64fd7 |
|
MD5 | b6d62a1d3e870b1a0766062d5fc906b2 |
|
BLAKE2b-256 | df5ac81449f0271e8f9acd9a49ca85d9dc335d5af3d9833ee95f7f8891459b9b |