Skip to content

Text-to-font asset pipeline: extract chars from text/XML and produce distributable fonts with fontgen.

License

Notifications You must be signed in to change notification settings

code-jammed/txt2fnt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

txt2fnt

A tool to convert text files to bitmap font files using fontgen.exe All text files under in/text/ are processed to extract unique characters, which are then used to generate bitmap fonts. For xml files, only the text content is considered, any tags or attributes are ignored. Some characters are always included like ASCII letters and digits, may support additional config later.

manually download dependencies before running

folder: _tools_

  1. fontgen.exe and its dependencies (Fontgen V1.1.0)

folder: _tools_\ttf

  1. Place your desired TTF font files in the _tools_/ttf/ folder.

Building a Windows EXE

You can create a standalone Windows EXE using PyInstaller. A helper script is provided: build_exe.ps1.

Quick steps:

  1. Install PyInstaller in your active Python environment: python -m pip install pyinstaller.
  2. Run the build script from the repo root in PowerShell: ./build_exe.ps1.

Notes:

  • By default this build script does not bundle any extra data; if you need fontgen.exe included, add _tools_/fontgen to $addDataArgs in build_exe.ps1 or pass --add-data flags to PyInstaller. TTF files under _tools_/ttf are not bundled by default and must be provided externally (for example, place them next to the EXE).
  • On Windows use the same architecture of Python that matches the native fontgen binaries.

Unit tests

python test/util/read_xml_txt.py -v

txt2fnt supported arguments

-ttf <ttf_file_name> : Specify TTF filename (in _tools_/ttf/ with/without extension name) to use for font generation -o <output_name> : Custom output name for the .fnt and .png file (no extension) --output-name : (Alias for -o) -fs : Specify font size (default 23) --font-size : (Alias for -fs)

Example usage

python txt2fnt.py -ttf ChironHeiHK-Text-R-400.ttf -o noto_sans_cjk_regular -fs 32

About

Text-to-font asset pipeline: extract chars from text/XML and produce distributable fonts with fontgen.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published