How to display 'ã', 'â', 'ê, 'é' and 'õ' on display TFT 2.4''

Hi, I’m from Brazil and I’m using a 2.4 ‘’ TFT LCD display and the Adafruit_GFX and MCUFRIEND_kbv libraries.

I’m trying to make the characters ‘ã’, ‘â’, ‘é’, ‘ê’, ‘õ’ and ‘ô’ appear on the screen but I can’t. I’ve tried using the print () and write () methods but these characters don’t seem to be part of the extended ASCII table used in these libraries.

Is there a way to add these characters to these libraries so that I can use them?

EDIT:

I attached the finished .ino file and a picture from one of the game screens.

The game consists of phrases in Portuguese and the student must choose the option corresponding to the syntactic function of the term highlighted in the phrase.

Unfortunately if the flash memory used exceeds 19% of the total, the phrases do not appear on the display.

GramaticB__Mega.ino (45.2 KB)

Just a correction, the characters 'é' and 'ô' appear, the characters 'â', 'ã', 'ê' and 'õ' do not appear.

Install "U8g2_for_Adafruit_GFX" library. It will let you use all the U8g2 fonts and display regular UTF-8 text.

The examples are for Adafruit_ILI9341.h but any GFX-style hardware library can be used e.g. MCUFRIEND_kbv.h

Note that the 5x7 system font has several useful text and graphics characters from 128-255 but they are not very standard.

David.

david_prentice: Install "U8g2_for_Adafruit_GFX" library. It will let you use all the U8g2 fonts and display regular UTF-8 text.

The examples are for Adafruit_ILI9341.h but any GFX-style hardware library can be used e.g. MCUFRIEND_kbv.h

Note that the 5x7 system font has several useful text and graphics characters from 128-255 but they are not very standard.

David.

Thanks for answering. I installed the library and these characters are really there but I was only able to use it for the U8g2 library object. The MCUFRIEND library object does not recognize this source. The constructor I use for the MCUFRIEND library I called 'tft' and tried to use the tft.setFont () method but was unsuccessful. I also tried to include the TomThumb.h file that is in the Adafruit_GFX_Library library, in this file it says that there are the characters I need; so I did tft.setFont (& TomThumbs), the font changed but only for the standard characters (0 to 127), the characters from 128 to 255 do not appear on the screen. Sorry but, would you have another way to help me?

The "system" 7x5 font has several special characters e.g. char(0x81) is lowercase u umlaut, 0x9A is uppercase U umlaut.

So you can use these characters with the default 7x5 font either by using escapes or individual characters e.g.

void loop()
{
    tft.fillScreen(TFT_BLACK);
//    u8g2_for_adafruit_gfx.setFont(u8g2_font_unifont_t_extended);  // extended font
    u8g2_for_adafruit_gfx.setFont(u8g2_font_helvR14_tf);  // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
    u8g2_for_adafruit_gfx.setCursor(0, 20);               // start writing at this position
    u8g2_for_adafruit_gfx.print("Hello World");
    u8g2_for_adafruit_gfx.setCursor(0, 40);               // start writing at this position
    u8g2_for_adafruit_gfx.print("Umlaut ÄÖÜ");            // UTF-8 string with german umlaut chars
    u8g2_for_adafruit_gfx.setCursor(0, 60);
    u8g2_for_adafruit_gfx.print("<μȦǀʘ\xB5\xA3ʁμπ>");
    tft.setFont(NULL);
    tft.setTextSize(2);
    tft.setCursor(0, 80);
    tft.print("escapes: \x81\x9A");
    for (int y = 0; y <= 16; y += 16) {
        tft.setCursor(0, 100 + y);
        for(int i = 0; i < 16; i++) {
            tft.print(char(0x80 + y + i));
        }
    }
    tft.setTextSize(1);
    delay(2000);
}

I am a Brit. So I seldom want to use accented characters. But you can mix and match printing with u8g2_for_adafruit_gfx object or regular tft object

Escapes are ok for occasional use. If I was printing a lot of messages I would be much happier using UTF8 strings that I can copy and paste.

David.

david_prentice: The "system" 7x5 font has several special characters e.g. char(0x81) is lowercase u umlaut, 0x9A is uppercase U umlaut.

So you can use these characters with the default 7x5 font either by using escapes or individual characters e.g.

void loop()
{
    tft.fillScreen(TFT_BLACK);
//    u8g2_for_adafruit_gfx.setFont(u8g2_font_unifont_t_extended);  // extended font
    u8g2_for_adafruit_gfx.setFont(u8g2_font_helvR14_tf);  // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
    u8g2_for_adafruit_gfx.setCursor(0, 20);               // start writing at this position
    u8g2_for_adafruit_gfx.print("Hello World");
    u8g2_for_adafruit_gfx.setCursor(0, 40);               // start writing at this position
    u8g2_for_adafruit_gfx.print("Umlaut ÄÖÜ");            // UTF-8 string with german umlaut chars
    u8g2_for_adafruit_gfx.setCursor(0, 60);
    u8g2_for_adafruit_gfx.print("<μȦǀʘ\xB5\xA3ʁμπ>");
    tft.setFont(NULL);
    tft.setTextSize(2);
    tft.setCursor(0, 80);
    tft.print("escapes: \x81\x9A");
    for (int y = 0; y <= 16; y += 16) {
        tft.setCursor(0, 100 + y);
        for(int i = 0; i < 16; i++) {
            tft.print(char(0x80 + y + i));
        }
    }
    tft.setTextSize(1);
    delay(2000);
}

I am a Brit. So I seldom want to use accented characters. But you can mix and match printing with u8g2_for_adafruit_gfx object or regular tft object

Escapes are ok for occasional use. If I was printing a lot of messages I would be much happier using UTF8 strings that I can copy and paste.

David.

Latin languages use the characters I need a lot. I am developing a teaching project for needy schools and all that was needed was to print these characters correctly on the screen. I managed to see my mistake, thank you very much. But two problems arose. The text size is very small and the sentences exceed the screen, there is no line break when it comes to the end when I use the U8g2 library object. I don't know how to start looking inside the U8g2 library files to solve these problems. Can you help me again?

Yes, U8g2 does not handle linefeeds. But it is not difficult to set the cursor position when you need to.

There are three practical choices:

  1. default 7x5 font. Has some accented letters in 0x80-0x9F and some other random places.
  2. use a FreeFont with characters from 0x20 - 0xFF. Has accented letters in 0xC0-0xFF
  3. use U8g2_for_GFX fonts which handle Latin, Arabic, Chinese, …

(1) and (2) requires escape sequences. This makes the text messages difficult to read and maintain.
(3) can just copy-paste regular UTF8 text from PC, websites, … What You See Is What You Get.

You can display the 7x5 and the FreeFonts in x1, x2, x3, … size. The bigger sizes look “blocky” but the 7x5 is not too bad as x2.
Personally, I would use the correct size FreeFont or U8g2 font in the first place.

If you want help, post some sample messages that you would like to display. And what font you think looks the most attractive.

David.

I hadn't seen the complete list of fonts. I found one that had a very good result.

Thank you very much for your help and patience. I'll post the final project here later.