arduino:custom_fonts_for_ucglib
This is an old revision of the document!
Table of Contents
Custom fonts for Ucglib
This is how I built custom fonts for Ucglib/ Ucglib_Arduino on Linux.
Requirements
Ucglib uses BDF fonts as a source. You will need:
- OTF and/or TTF files of the fonts you want to convert. Check licenses!
- A way to convert BDF files to the C structures used in Ucglib:
bdfconv
, which you will build below.
Building bdfconv
Download the Ucglib repository, head into tools/font/bdfconv
and
$ make
This will build a bdfconv
executable. Put that executable or a symbolic link to it into your bin
directory.
The process
Convert OTF or TTF to BDF
Using otf2bdf
:
$ otf2bdf -v -n -r 72 -p 71 -l '32 48_57 65_90' -c M -o filename.bdf filename.otf
gbdfed
also can import and convert fonts, but the monospace/proportional setting seems to be wonky. fontforge
appears to be another option.
View the result using gbdfed
.
Convert the BDF file to C using bdfconv
$ bdfconv -v -b 2 -f 0 -n fontname -d image.tga -o filename.c filename.bdf
Note: There seems to be an upper limit to the size of the font. What is it?
Add new code to Ucglib
Paste the content of the new file to src/clib/ucg_pixel_font_data.c
Add an extern
entry for the above to src/clib/ucg.h
arduino/custom_fonts_for_ucglib.1542303234.txt.gz · Last modified: 2018/11/15 17:33 by mithat