I'd like to print characters with an extended ascii font . I used with success MyFont10.h
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// The custom font files attached to this sketch must be included
// They only occupy memory if the sketch uses them.
#include "MyFont09.h"
#include "MyFont10.h"
#include "MyFont12.h"
// Easily remembered names for the fonts
#define MYFONT9 &myFont9pt8b
#define MYFONT10 &myFont10pt8b
#define MYFONT12 &myFont12pt8b
...
tft.setAttribute(UTF8_ENABLE , true);
tft.setAttribute(CP437_ENABLE, true);
tft.setFont(MYFONT10);
It works fine with this library.
Now I'd like to use Bodmer Library TFT_eSPI.h with the example
I succeed to use the custom fonts and free fonts for example CF_OL24 &Orbitron_Light_24
But I tried to add MyFont10.h but I have an error message while compiling (MyFont10.h:4562:1: error: stray '' in program everywhere).
I modified : User Customs Fonts. h by adding #include <Fonts/Custom/MyFont10.h>
then add in my program : #define MYFONT10 &myFont10pt8b
tft.setFreeFont(MYFONT1O);
It's not working and I don't know what I'm missing.
When you encounter an error you'll see a button on the right side of the orange bar in the Arduino IDE "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a reply here using code tags.
If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.
OK, I see you posted it now. But please don't post errors as PDF files. Some forum members can't or won't download these files. Just use a text editor and save as a .txt file. If you don't have a text editor, get one! This is an essential tool for every programmer. There are many excellent choices of free open source text editors.
It looks like your MyFont10.h is the source of a web page of that file, thus the errors. Please replace the MyFont10.h on your computer with the one you attached in your previous forum reply. That should fix the error.
Now it's compiling but it doesn't display something right.
this one is working with extended ascii demo
#define TEST_TEXT "ßäöü ñâàå" // Text that will be printed on screen in the font
#include <SPI.h>
#include <Adafruit_GFX.h>
// The custom font files attached to this sketch must be included
// They only occupy memory if the sketch uses them.
#include "MyFont09.h"
#include "MyFont10.h"
#include "MyFont12.h"
// Easily remembered names for the fonts
#define MYFONT9 &myFont9pt8b
#define MYFONT10 &myFont10pt8b
#define MYFONT12 &myFont12pt8b
#define TFT_CS 14 //for D32 Pro
#define TFT_DC 27 //for D32 Pro
#define TFT_RST 33 //for D32 Pro
#define TS_CS 12 //for D32 Pro
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
Serial.begin(115200);
tft.begin();
tft.setRotation(1);
tft.setAttribute(UTF8_ENABLE , true);
tft.setAttribute(CP437_ENABLE, true);
}
void loop() {
tft.setTextColor(ILI9341_WHITE); // white characters
tft.fillScreen(ILI9341_BLUE); // Clear screen
//tft.setFont(MYFONT9); // Select the font
tft.setFont(MYFONT10); // Select the font
//tft.setFont(MYFONT12); // Select the font
tft.setCursor(0,0);
tft.println(); // Drop cursor 1 line
tft.println("ÿâäàå¡"); // Print test characters
tft.println(TEST_TEXT);
tft.println(12345);
tft.println("Śś abc ŜŝŞ"); // Test with some out-of-range characters
// (only " abc " will be printed)
tft.println("Hello");
delay(2000);
}
The one I want to work with TFT_espi doesn't display properly.
#include <Adafruit_GFX.h>
#include "MyFont10.h"
//#define MYFONT10 &myFont10pt8b
// Include the TFT library https://github.com/Bodmer/TFT_eSPI
#include "SPI.h"
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
void setup()
{
Serial.begin(115200);
// Initialise the TFT
tft.begin();
tft.setAttribute(UTF8_ENABLE , true);
tft.setAttribute(CP437_ENABLE, true);
}
void loop()
{
tft.setTextColor(ILI9341_WHITE); // white characters
tft.fillScreen(ILI9341_BLUE); // Clear screen
//tft.setFont(MYFONT9); // Select the font
tft.setFreeFont(&myFont10pt8b); // Select the font
//tft.setFont(MYFONT12); // Select the font
tft.setCursor(0,0);
tft.println(); // Drop cursor 1 line
tft.println("ÿâäàå¡"); // Print test characters
// tft.println(TEST_TEXT);
tft.println(12345);
tft.println("Śś abc ŜŝŞ"); // Test with some out-of-range characters
// (only " abc " will be printed)
tft.println("Hello");
delay(2000);
}
Do you think it's not working due to
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); different to
TFT_eSPI tft = TFT_eSPI(); ?
The SQUIX site only produces a 94 letter Font. tilde i.e. char(126) is not correct.
I can generate FreeFonts but it is nicer to use a website like SQUIX.
I have not looked at Bodmer's documentation recently. Does he handle UFT8 Fonts nowadays?
MCUFRIEND_kbv inherits from Adafruit_GFX so I can use Olikraus's u8g2_for_adafruit_gfx.
This means you can use u8g2 fonts e.g. Unicode, Chinese, Greek, ... via UFT8 text.
@bobby75
You do not need to edit the library if you keep the font file local to the sketch, you can adapt the example here.
If you follow the YouTube tutorial (link here) then you can use any contiguous 16 bit UNICODE code point range above the normal ASCII range with the Adafruit "Free Font" format. You will not be able to do that with the stock Adafruit_GFX library, although I did add the capability to a tweaked copy here.
I see nothing wrong with the font file you posted so look for a problem in your own IDE setup and/or sketch.
The SQUIX site will only generate FreeFonts for 0x20-0x7D. The bitmap and glyph is missing for 0x7E (tilde)
If I select the Library: <3.0.0 I can get 0x20-0xFF. Which I can translate into FreeFont format. And output any subset of 0x20-0xFF.
Do you know what this <3.0.0 format is?
Do you know what the >=3.0.0 format is?
<3.0.0 looks like Thiele format but with packed bitmaps (and a special feature)
TFT_eSPI supports 5 font formats already but if I were to add another format it would probably be the one used by LittlevGL as the format and converter tools appear to be well thought out.