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
from examples import build_dir, outputs_dir
from examples.utils import fs_util
from pixel_font_builder import FontBuilder, Glyph, StyleName, SerifMode, WidthMode, opentype
logging.basicConfig(level=logging.DEBUG)
def main():
fs_util.delete_dir(build_dir)
fs_util.make_dirs_if_not_exists(outputs_dir)
font_builder = FontBuilder(
size=12,
ascent=10,
descent=-2,
x_height=5,
cap_height=7,
)
font_builder.character_mapping = {
ord('A'): 'CAP_LETTER_A',
}
font_builder.add_glyph(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],
],
))
font_builder.add_glyph(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],
],
))
font_builder.meta_infos.version = '1.0.0'
font_builder.meta_infos.family_name = 'Demo Pixel'
font_builder.meta_infos.style_name = StyleName.REGULAR
font_builder.meta_infos.serif_mode = SerifMode.SANS_SERIF
font_builder.meta_infos.width_mode = WidthMode.MONOSPACED
font_builder.meta_infos.manufacturer = 'TakWolf Studio'
font_builder.meta_infos.designer = 'TakWolf'
font_builder.meta_infos.description = 'A demo pixel font.'
font_builder.meta_infos.copyright_info = 'Copyright (c) TakWolf'
font_builder.meta_infos.license_info = 'This Font Software is licensed under the SIL Open Font License, Version 1.1.'
font_builder.meta_infos.vendor_url = 'https://github.com/TakWolf/pixel-font-builder'
font_builder.meta_infos.designer_url = 'https://takwolf.com'
font_builder.meta_infos.license_url = 'https://scripts.sil.org/OFL'
font_builder.save_otf(os.path.join(outputs_dir, 'demo.otf'))
font_builder.save_otf(os.path.join(outputs_dir, 'demo.woff2'), flavor=opentype.Flavor.WOFF2)
font_builder.save_ttf(os.path.join(outputs_dir, 'demo.ttf'))
font_builder.save_bdf(os.path.join(outputs_dir, 'demo.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
Built Distribution
Close
Hashes for pixel_font_builder-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c3ae9fee40b520fa5bf7a3cba705d5846b9bf7a61fc7e422afa1c519a5f71c9 |
|
MD5 | 76e3f6b0b1df4ef444d3bad279cc29c8 |
|
BLAKE2b-256 | 442547977f8c7aa71cdc57f7d32ef0d47ee8c0f8a05d35861160b4be876f43a5 |