User Tools

Site Tools


arduino:custom_fonts_for_ucglib

This is an old revision of the document!


Custom fonts for Ucglib

This is how I built custom fonts for Ucglib/ Ucglib_Arduino on Linux.

The basic process involves:

  • Convering the OTF or TTF font to BDF format using otf2bdf, gbdfed, or fontforge.
  • Using `bdconf` to convert the BDF format to C.
  • Adding the new code to the appropriate Ucglib file.

Requirements

Ucglib uses BDF fonts as a source. You will need:

  • OTF and TTF files of the fonts you want to convert. Check licenses!
  • A way to convert these to BDF format: otf2bdf , gbdfed, or possibly fontforge
  • A way to convert BDF files to the C structures used in Ucglib: bdfconv, which you will build below.

Getting otf2bdf and fontforge

Both otf2bdf and 'fontforge are available in many Linux distributions. ==== Building bdfconv ==== You will probably have to build bdfconv yourself. Download the Ucglib repository, move into tools/font/bdfconv and <code shell> $ make </code> 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: <code> $ otf2bdf -v -n -r 72 -p 71 -l '32 48_57 65_90' -c M -o filename.bdf filename.otf </code> gbdfed also can import and convert fonts, but the monospace/proportional setting seems to be wonky. fontforge may be another option. View the result using gbdfed or fontforge. Once the font is in BDF format, you can use fontforge to edit it, which might include removing unused characters or tweaking bitmaps. ==== Convert the BDF file to C using bdfconv ==== <code> $ bdfconv -v -b 2 -f 0 -n fontname -d image.tga -o filename.c filename.bdf </code> Note: There seems to be an upper limit to the size of the font. FIXME What is it? ==== Add new code to Ucglib ==== Paste the content of the new C file to src/clib/ucg_pixel_font_data.c – making sure to remove the redundant <code c> #include “ucg.h” </code> Add an extern entry for the above variable to src/clib/ucg.h''

arduino/custom_fonts_for_ucglib.1569097068.txt.gz · Last modified: 2019/09/21 20:17 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki