This is my version of ttf2gui, modified for my uGUI fork.
Adds UTF8 compatibility and supports the custom font structure used in my uGUI version.
Not compatible with the original!
uGUI is a free open source graphics library for embedded systems.
To display text, it uses bitmap/raster fonts, that are included in application as C-language structs & arrays.
uGUI includes some fonts in itself, but I wanted to use some TrueType fonts.
I didn't find a tool that would convert a .ttf file into C structures used by uGUI easily, so I wrote one using Freetype library.
This is a simple utility to convert TrueType fonts into uGUI compatible structures.
It reads font file, renders each character into bitmap and outputs it as uGUI compatible C structure.
Optionally it can display ascii art sample of font by using UGUI to render pixels as '*' with ansi escape sequences.
Fonts generated with 8BPP show in blue pixels with less then 100% fill.
Please remember to respect font copyrights when converting.
Examples:
./ttf2ugui --font=Luna.ttf --dpi=140 --size=14 --dump
Results are in Luna.c and Luna.h, just compile the .c and include .h in your uGUI application.
./ttf2ugui --font=Luna.ttf --dpi=140 --size=14 --show="aString"
./ttf2ugui --font=Luna.ttf --dpi=140 --size=14 --show="aString" --bpp=8
./ttf2ugui --font=/System/Library/Fonts/Supplemental/Arial.ttf --dpi=140 --size=14
./ttf2ugui --font=C:\Windows\Fonts\Arial.ttf --dpi=140 --size=14
./ttf2ugui --dump --font=arial.ttf --size=14 --chars=32,48-57
./ttf2ugui --dump --font=arial.ttf --size=14 --chars=32,48-57,65-90
./ttf2ugui --dump --font=arial.ttf --size=14 --chars=32-126,1042-1103
./ttf2ugui --dump --font=arial.ttf --size=14 --chars=32-126,169,1042-1103
"--chars" use Unicode or ASCII codes.
To compile, freetype library is needed.
Easiest way to get is to install suitable package for your operating system.
- For FreeBSD, install "print/freetype2".
- For Debian, install libfreetype6-dev with apt-get.
- For MacOS, install freetype with brew.
- For Windows, install cygwin64 and add these packages: make gcc-core libfreetype-devel
There's a precompiled build for Windows (ttf2ugui-win.zip)
Then, just type "make".