A tool for converting fonts to NICO Game Framework format fonts.
Project description
NICO Font Tool - Python
A tool for converting fonts to NICO Game Framework format fonts.
This is the Python version. The Nim version see: nico-font-tool.
Installation
pip install nico-font-tool
Usage
import logging
import os
import nico_font_tool
from examples import fonts_dir, outputs_dir
logging.basicConfig(level=logging.DEBUG)
def convert_font(
font_file_name: str,
outputs_name: str,
font_size: int = None,
glyph_offset_x: int = 0,
glyph_offset_y: int = 0,
glyph_adjust_width: int = 0,
glyph_adjust_height: int = 0,
):
font_file_path = os.path.join(fonts_dir, font_file_name)
sheet_data, alphabet = nico_font_tool.create_sheet(
font_file_path,
font_size,
glyph_offset_x,
glyph_offset_y,
glyph_adjust_width,
glyph_adjust_height,
)
palette_outputs_dir = os.path.join(outputs_dir, 'palette')
if not os.path.exists(palette_outputs_dir):
os.makedirs(palette_outputs_dir)
nico_font_tool.save_palette_png(sheet_data, palette_outputs_dir, outputs_name)
nico_font_tool.save_dat_file(alphabet, palette_outputs_dir, outputs_name)
rgba_outputs_dir = os.path.join(outputs_dir, 'rgba')
if not os.path.exists(rgba_outputs_dir):
os.makedirs(rgba_outputs_dir)
nico_font_tool.save_rgba_png(sheet_data, rgba_outputs_dir, outputs_name)
nico_font_tool.save_dat_file(alphabet, rgba_outputs_dir, outputs_name)
def main():
convert_font(
font_file_name='quan/quan.ttf',
outputs_name='quan',
font_size=8,
glyph_adjust_width=-1,
)
convert_font(
font_file_name='fusion-pixel-monospaced/fusion-pixel-monospaced.otf',
outputs_name='fusion-pixel-monospaced',
font_size=12,
glyph_offset_y=-1,
glyph_adjust_width=-1,
glyph_adjust_height=-1,
)
convert_font(
font_file_name='fusion-pixel-proportional/fusion-pixel-proportional.otf',
outputs_name='fusion-pixel-proportional',
font_size=12,
glyph_offset_y=-1,
glyph_adjust_width=-1,
glyph_adjust_height=-1,
)
convert_font(
font_file_name='galmuri/Galmuri9.ttf',
outputs_name='galmuri9',
font_size=10,
glyph_offset_y=1,
glyph_adjust_width=-1,
glyph_adjust_height=1,
)
convert_font(
font_file_name='galmuri/Galmuri9.bdf',
outputs_name='galmuri9-bdf',
glyph_adjust_width=-1,
)
convert_font(
font_file_name='unifont/unifont-15.0.01.ttf',
outputs_name='unifont',
font_size=16,
glyph_adjust_width=-1,
)
convert_font(
font_file_name='unifont/unifont-15.0.01.bdf',
outputs_name='unifont-bdf',
glyph_adjust_width=-1,
)
convert_font(
font_file_name='roboto/Roboto-Regular.ttf',
outputs_name='roboto',
font_size=24,
)
if __name__ == '__main__':
main()
License
Under the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nico-font-tool-0.0.1.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file nico-font-tool-0.0.1.tar.gz
.
File metadata
- Download URL: nico-font-tool-0.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79648266f2b4fbc5b3567480e37d5f70055f1d4f0f4b9bd600e0bd8f653410b1 |
|
MD5 | ad535b63749bf0e838189248ff7b9e83 |
|
BLAKE2b-256 | 5989b158085863b58db7ca39085036f795532eedba7e7573a58178d9145570eb |
Provenance
File details
Details for the file nico_font_tool-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: nico_font_tool-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b0762f176ec6713004f26b21a45d08b5428bd218e9618d2e587a97256c1117 |
|
MD5 | b5e44e6e0714c2f40c5842c644d55b3b |
|
BLAKE2b-256 | 169e3245cf0d68ca643d2631e3b18ad48679721bfde371eafeb3fd252bdf41d6 |