Easy printing of 8-bit characters on ILI9341 display

Hafting

Member
The fonts that come with the ILI9341_t3 library are all 7-bit, but all you need for 8-bit printing is an 8-bit font.
The library comes with an "extras" folder, that contain a font converter. It converts ttf fonts to 7bit fonts that works with the ILI9341_t3 library.

All I needed was to change from
#define ENCODING_END 127
to
#define ENCODING_END 255
The converter then produce an 8-bit font, with additional characters in the 128-255 range. I converted DejaVuSerifCondensed-Bold.ttf this way.

My linux pc normally uses utf-8 encoding for files, which is not an 8-bit code. But if I convert a .ino file with 8bit strings to iso8859-1, then it works correctly with the converted font. So I can write char *x="½×½=¼ «æøå»" and get just that with tft.print(x);

An utf8-encoded file can be converted to iso8859-1 like this:
iconv -f UTF-8 -t ISO-8859-1 string-utf8.h > string-iso8859-1.h

Attached an image showing the ILI9341 displaying a 8x16 grid with DejaVu characters in the 128-255 range. The two first rows are empty as the default font encoding don't put any symbols there.

8bittxt.png

After doing this, I discovered an utf-8 enabled version of the ILI9341_t3 library. It is better than this approach, so my suggestion is to merge that.
 
Last edited:
Hello!
Where do you find this constant?
When I change ENCODING_END in /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3/extras/bdf_to_ili9341.c it doesn't make a difference because the file is not being compiled.
I am trying to print special characters in Spanish like ñ, á, ó. But I can't find a way.
Any help is appreciated!
 
Not sure if I am much help on the tools.

Again not sure if this will help, but for example my version of the library github\kurte\ili9341_t3n

Supports both the ILI fonts like the ILI9341_t3 library, but in addition also supports the Adafruit GFX fonts as well.

There are several places to get lots of different fonts... The main one I use for the ILI...

Is: https://github.com/mjs513/ILI9341_fonts
Why, we updated them slightly to allow us to include them in several of the display drivers that we setup to handle these fonts, like the st7735/90 ILI9488, RA8875/76...
We also converted it to be a newer Arduino library (moved things to SRC directory), plus set it up to generate an archive. Why this is nice is that when you build with it, it will only include those files (fonts) that your code actually references, otherwise it will try to link in all of the font files in that directory.

Paul also has a version: https://github.com/paulstoffregen/ILI9341_fonts
That all of the fonts are in top directory.

Plus other forms of fonts like: https://github.com/FrankBoesing/fonts
Which converts google fonts into .c files, but not sure what format, nor have I tried them....
 
Hello!
Where do you find this constant?
When I change ENCODING_END in /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3/extras/bdf_to_ili9341.c it doesn't make a difference because the file is not being compiled.
I am trying to print special characters in Spanish like ñ, á, ó. But I can't find a way.
Any help is appreciated!

bdf_to_ili9341.c can be compiled, but it is NOT a part of the arduino project. It is an utility that you run on your computer. It converts a font file into source code that then can be included into an arduino project – in order to print on an ILI9341 display. Be careful, it is easy to run out of memory if you create a large-size font with many characters.

In the extras directory, you find a Makefile. So, use the command line and go to that directory. I.e.
$*cd /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3/extras

Then, run the make utility to compile the bdf_to_ili9341:
$ make bdf_to_ili9341
It should compile, provided you have "make" and "gcc" installed on your computer. You get a program named bdf_to_ili9341. It can convert a font in bdf format to source code for arduino.

In the same directory, you find a script called ttf_to_ili9341.pl
It uses the utility otf2bdf to create a bdf file from a truetype font. Then, it uses bdf_to_ili9341 to create a .c file containing the font, and a .h file that allows the font to be used. otf2bdf is a separate utility you have to get from the internet.

To use a font (DejaVuSerifCondensedBold, size 22):

#include "font_DejaVuSerifCondensedBold.h"
#include "fonts/font_DejaVuSerifCondensedBold_22.c"
...
tft.setFont(DejaVuSerifCondensedBold_22);
tft.println("Testing ñ, á, ó"); //For this to work, the source code file must be encoded in iso8859-1. utf-8 will NOT work. If you prefer utf-8, use escape codes to encode the non-ascii stuff.
 
Back
Top