Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: How do i add the default adafruit font to the tgx graphics library?

  1. #1
    Junior Member
    Join Date
    Sep 2022
    Posts
    6

    How do i add the default adafruit font to the tgx graphics library?

    How can I convert this default adafruit font to a format that works with this library? https://github.com/vindar/tgx
    Im using vscode with platformio and using teensy 4.1.

    This is the format of the font i want:

    glcdfont.c
    Code:
    // This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
    // See gfxfont.h for newer custom bitmap font info.
    
    #ifndef FONT5X7_H
    #define FONT5X7_H
    
    #ifdef __AVR__
    #include <avr/io.h>
    #include <avr/pgmspace.h>
    #elif defined(ESP8266)
    #include <pgmspace.h>
    #elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
    // PROGMEM is defefind for T4 to place data in specific memory section
    #undef PROGMEM
    #define PROGMEM
    #else
    #define PROGMEM
    #endif
    
    // Standard ASCII 5x7 font
    
    static const unsigned char font[] PROGMEM = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B,
        0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C,
        0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
        0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24,
        0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E,
        0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F,
        0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C,
        0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F,
        0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89,
        0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94,
        0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08,
        0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10,
        0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06,
        0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F,
        0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14,
        0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49,
        0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41,
        0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08,
        0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08,
        0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,
        0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49,
        0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F,
        0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41,
        0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49,
        0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00,
        0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41,
        0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59,
        0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E,
        0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49,
        0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73,
        0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40,
        0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40,
        0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E,
        0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51,
        0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32,
        0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20,
        0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14,
        0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
        0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41,
        0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40,
        0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28,
        0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28,
        0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18,
        0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D,
        0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,
        0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08,
        0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24,
        0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48,
        0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40,
        0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C,
        0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64,
        0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00,
        0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C,
        0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40,
        0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41,
        0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
        0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E,
        0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54,
        0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00,
        0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11,
        0x12, 0x7D, // A-umlaut
        0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54,
        0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49,
        0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
        0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42,
        0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42,
        0x3D, // O-umlaut
        0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E,
        0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6,
        0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00,
        0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40,
        0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D,
        0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48,
        0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
        0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00,
        0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A,
        0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old
                                                  // code
        0xAA, 0x55, 0xAA, 0x55, 0xAA,             // 50% block
        0xFF, 0x55, 0xFF, 0x55, 0xFF,             // 75% block
        0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14,
        0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10,
        0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00,
        0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17,
        0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00,
        0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10,
        0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF,
        0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00,
        0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F,
        0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17,
        0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14,
        0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17,
        0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10,
        0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00,
        0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0,
        0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10,
        0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
        0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44,
        0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
        0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55,
        0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E,
        0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C,
        0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D,
        0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D,
        0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A,
        0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44,
        0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0,
        0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36,
        0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00,
        0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F,
        0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C,
        0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
    };
    
    // allow clean compilation with [-Wunused-const-variable=] and [-Wall]
    static inline void avoid_unused_const_variable_compiler_warning(void) {
      (void)font;
    }
    
    #endif // FONT5X7_H

    And this is how other fonts look like in tgx for example arial:
    font_tgx_Arial.cpp

    Code:
    #include "font_tgx_Arial.h"
    
    static const unsigned char font_tgx_Arial_8_data[] = {
    0x00,0x00,0x18,0x03,0x00,0x16,0x44,0x06,0x62,0xA4,
    0xD0,0x0B,0x00,0x34,0x15,0xF8,0x53,0xF1,0x40,0x0B,
    0x27,0xB1,0xCA,0xA8,0x74,0x15,0x53,0x84,0x13,0x00,
    0x51,0x89,0x12,0x83,0x40,0x16,0x81,0x48,0x8C,0x0D,
    0x00,0x38,0xC8,0x48,0x61,0x44,0x68,0x8E,0x80,0x02,
    0x62,0x94,0xC0,0x07,0x47,0x20,0x96,0x42,0x10,0x07,
    0x47,0x22,0x16,0x12,0x40,0x06,0x82,0x21,0x39,0x28,
    0x0A,0xA0,0xB4,0x11,0xF8,0x20,0x02,0x6F,0x1C,0xC0,
    0x06,0x21,0x23,0x80,0x02,0x28,0x1A,0x07,0x00,0x1C,
    0x1A,0x51,0x00,0x0B,0x00,0x31,0xD9,0x13,0x80,0x07,
    0x00,0x30,0x9A,0xD9,0x0B,0x00,0x31,0xC8,0xC0,0x42,
    0x10,0x87,0xC0,0x0B,0x00,0x31,0xC8,0x82,0x34,0x05,
    0x13,0x80,0x0B,0x00,0x30,0x43,0x42,0x92,0x7E,0x04,
    0x0B,0x00,0x31,0xE4,0x20,0xF4,0x05,0x13,0x80,0x0B,
    0x00,0x31,0xC8,0xA0,0xF4,0xC4,0xE0,0x0B,0x00,0x33,
    0xF0,0x28,0x24,0xA0,0x0B,0x00,0x31,0xD1,0x13,0xA6,
    0x27,0x00,0x0B,0x00,0x31,0xD3,0x13,0xC1,0x44,0xE0,
    0x02,0xC0,0x1B,0x44,0x03,0x07,0x1B,0x49,0x80,0x0A,
    0xA0,0xB0,0x27,0x20,0x70,0x20,0x0A,0x61,0x33,0xE0,
    0x3E,0x0A,0xA0,0xB2,0x07,0x02,0x72,0x00,0x0B,0x00,
    0x31,0xC8,0x82,0x14,0x10,0x01,0x00,0x15,0x47,0x58,
    0x7C,0x30,0x44,0xD5,0x26,0xC5,0x12,0xA6,0x93,0x61,
    0x01,0x1F,0xC0,0x0F,0x00,0x40,0x44,0x94,0x22,0x3E,
    0x88,0x20,0x0D,0x00,0x3B,0xE8,0x85,0xFC,0xC2,0xF8,
    0x0D,0x00,0x38,0xE2,0x35,0x01,0x11,0xC0,0x0D,0x00,
    0x3B,0xC4,0x55,0x0A,0x27,0x80,0x0B,0x00,0x33,0xF1,
    0x07,0xE6,0x0F,0x80,0x0B,0x00,0x33,0xF1,0x07,0xAA,
    0x00,0x0F,0x00,0x40,0xE1,0x12,0x0A,0x02,0x3A,0x09,
    0x10,0xE0,0x0D,0x00,0x3C,0xC2,0xFE,0xA1,0x03,0x00,
    0x16,0xD0,0x09,0x00,0x2D,0x8C,0x49,0x80,0x0D,0x00,
    0x3A,0x14,0x49,0x16,0x34,0x88,0x90,0x80,0x0B,0x00,
    0x36,0xC1,0xF0,0x0F,0x00,0x42,0x0C,0x63,0x9A,0xB1,
    0x24,0x0D,0x00,0x3A,0x16,0x31,0x4C,0x4A,0x8D,0x08,
    0x0F,0x00,0x40,0xE1,0x15,0x41,0x22,0x1C,0x0B,0x00,
    0x33,0xD3,0x17,0xA6,0x00,0x0F,0x00,0x40,0xE1,0x14,
    0xC1,0x4D,0x22,0x1F,0x0D,0x00,0x3B,0xE8,0x85,0xF2,
    0x48,0x89,0x08,0x0D,0x00,0x39,0xE4,0x28,0x0C,0x06,
    0x02,0x84,0xF0,0x0B,0x00,0x33,0xFA,0x40,0x0D,0x00,
    0x3E,0xC2,0x78,0x0F,0x00,0x44,0x41,0x84,0x50,0x52,
    0x04,0x00,0x17,0x18,0x52,0x10,0xA2,0x8C,0x25,0x28,
    0x51,0x50,0x41,0x00,0x0D,0x00,0x3A,0x18,0x4A,0x0C,
    0x84,0x90,0x80,0x0F,0x00,0x42,0x0C,0x22,0x14,0xA1,
    0x00,0x0D,0x00,0x39,0xF0,0x50,0x24,0x10,0x41,0xF8,
    0x05,0x47,0x1B,0xD9,0x30,0x07,0x00,0x1C,0x4A,0x50,
    0x40,0x05,0x47,0x1B,0xD4,0xB0,0x0A,0x82,0x28,0x90,
    0xA4,0x40,0x0C,0x27,0x33,0xF0,0x04,0x43,0x22,0x20,
    0x0A,0xC0,0x31,0xC8,0x9E,0x8A,0x6E,0x80,0x0B,0x00,
    0x34,0x41,0x66,0x62,0x2C,0xAC,0x0A,0xC0,0x31,0xC8,
    0xC4,0x11,0x38,0x0B,0x00,0x34,0x04,0xD4,0xE2,0x29,
    0x9A,0x0A,0xC0,0x31,0xC8,0xBE,0x82,0x27,0x00,0x07,
    0x00,0x20,0x93,0xDA,0x0B,0x07,0x31,0xA9,0xC4,0x53,
    0x34,0x17,0x80,0x0B,0x00,0x34,0x41,0x66,0x6A,0x20,
    0x03,0x00,0x12,0x64,0x05,0x5F,0x11,0x1A,0xA0,0x09,
    0x00,0x2C,0x42,0x54,0xC7,0x29,0x20,0x03,0x00,0x16,
    0xD0,0x0E,0xC0,0x42,0xF3,0x4D,0x49,0x0A,0xC0,0x33,
    0xD7,0x10,0x0A,0xC0,0x31,0xD5,0x13,0x80,0x0B,0x07,
    0x32,0xCC,0xC4,0x59,0x5A,0x20,0x0B,0x07,0x31,0xA9,
    0xC4,0x53,0x36,0x02,0x06,0xC0,0x22,0xB5,0x40,0x0A,
    0xC0,0x31,0xC8,0x98,0x12,0x27,0x00,0x07,0x18,0x1C,
    0x27,0xA4,0x60,0x0A,0xC0,0x35,0x45,0x33,0x40,0x0A,
    0xC0,0x34,0x46,0x15,0x04,0x12,0xC0,0x52,0x22,0x94,
    0xC2,0xAA,0x08,0x80,0x0A,0xC0,0x32,0x25,0x41,0x0A,
    0x44,0x0B,0x07,0x34,0x46,0x15,0x24,0x20,0x0A,0xC0,
    0x33,0xE1,0x41,0x08,0x7C,0x07,0x47,0x20,0xCA,0x4A,
    0x42,0x03,0x47,0x16,0xE6,0x07,0x4F,0x22,0x4A,0x1A,
    0x48,0x0A,0x42,0x33,0xAB,0x00,};
    /* font data size: 656 bytes */
    
    static const unsigned char font_tgx_Arial_8_index[] = {
    0x00,0x00,0x30,0x1C,
    0x0B,0x04,0xC1,0xC0,0x9C,0x31,0x0D,0x43,0xB1,0x04,
    0x46,0x13,0x05,0x01,0x50,0x57,0x17,0x46,0x31,0xA0,
    0x71,0x1E,0x88,0x22,0x2C,0x93,0x26,0x8A,0x22,0xA8,
    0xAE,0x2C,0xCB,0xA2,0xFC,0xC6,0x33,0xCD,0xF3,0xA0,
    0xF0,0x3E,0x10,0x04,0x21,0x0F,0x46,0x92,0x04,0x91,
    0x2A,0x4D,0x13,0x95,0x05,0x4A,0x54,0x95,0x95,0x89,
    0x6B,0x5D,0x57,0xA5,0xFD,0x88,0x65,0x19,0xD6,0x95,
    0xAE,0x6C,0xDB,0x96,0xF9,0xC4,0x72,0x1C,0xC7,0x51,
    0xDC,0x78,0xDE,0xB7,0xCD,0xF8,0x80,0x60,0x88,0x32,
    0x11,0x86,0x61,0xD8,0x8E,0x28,0x8B,0xA3,0x68,0xFA,
    0x43,0x92,0xE5,0x19,0x5E,0x5D,0x99,0xA6,0xD9,0xD2,
    0x7B,0xA0,0x68,0x5A,0x2C,
    };
    /* font index size: 119 bytes */
    
    const ILI9341_t3_font_t font_tgx_Arial_8 = {
    	font_tgx_Arial_8_index,
    	0,
    	font_tgx_Arial_8_data,
    	1,
    	0,
    	32,
    	126,
    	0,
    	0,
    	10,
    	4,
    	4,
    	2,
    	4,
    	4,
    	11,
    	8
    };
    font_tgx_Arial.h
    Code:
    #ifndef _font_tgx_Arial_H_
    #define _font_tgx_Arial_H_
    
    #include "tgx.h"
    
    //#ifdef __cplusplus
    //extern "C" {
    //#endif
    
    extern const ILI9341_t3_font_t font_tgx_Arial_8;
    
    //#ifdef __cplusplus
    //} // extern "C"
    //#endif
    
    #endif

  2. #2
    Hi,

    The TGX library has native support for ILI9341_t3 and Adafruit GFX font format (GFXFont). However, the default 'classic' 6x8 Adafruit font given in glcdfont.h is strangely not in Adafruit GFXFont format for some (probably historical) reasons so it need to be converted. Here it is converted to GFXFont:

    classicGFXfont.h
    Code:
    #ifndef _CLASSICGFXFONT_H_
    #define _CLASSICGFXFONT_H_
    
    
    #include "tgx.h"
    
    
    // the 'classic' Adafruit GFX font converted to the new Adafruit font format. 
    extern const GFXfont classicGFXfont;
    
    #endif
    and classicGFXfont.cpp
    Code:
    #include "classicGFXfont.h"
    
    static const uint8_t classicGFXFontBitmaps[1280] PROGMEM = {
    	0, 0, 0, 0, 0, 119, 235, 253, 197, 192, 119, 235, 248, 237, 192, 2,
    	191, 255, 184, 128, 1, 29, 255, 184, 128, 114, 191, 95, 145, 192, 35, 191,
    	255, 145, 192, 0, 8, 231, 16, 0, 255, 247, 24, 239, 255, 0, 8, 165,
    	16, 0, 255, 247, 90, 239, 255, 1, 198, 218, 81, 0, 116, 98, 226, 124,
    	128, 122, 94, 132, 35, 0, 122, 94, 148, 175, 0, 37, 93, 189, 186, 164,
    	134, 61, 255, 98, 0, 8, 223, 247, 140, 32, 35, 170, 74, 184, 128, 222,
    	247, 189, 131, 96, 125, 106, 210, 148, 160, 50, 84, 81, 37, 38, 0, 0,
    	0, 127, 224, 35, 170, 74, 184, 159, 1, 29, 82, 16, 128, 1, 8, 74,
    	184, 128, 1, 5, 241, 16, 0, 1, 17, 244, 16, 0, 4, 33, 15, 128,
    	0, 2, 191, 245, 0, 0, 1, 8, 239, 252, 0, 7, 254, 226, 16, 0,
    	0, 0, 0, 0, 0, 33, 8, 66, 0, 128, 82, 148, 0, 0, 0, 82,
    	190, 175, 169, 64, 35, 232, 226, 248, 128, 198, 68, 68, 76, 96, 69, 40,
    	138, 201, 160, 49, 136, 128, 0, 0, 17, 16, 132, 16, 64, 65, 4, 33,
    	17, 0, 37, 93, 247, 84, 128, 1, 9, 242, 16, 0, 0, 0, 3, 24,
    	136, 0, 1, 240, 0, 0, 0, 0, 0, 24, 192, 0, 68, 68, 64, 0,
    	116, 103, 92, 197, 192, 35, 8, 66, 17, 192, 116, 66, 232, 67, 224, 248,
    	68, 96, 197, 192, 17, 149, 47, 136, 64, 252, 60, 16, 197, 192, 58, 33,
    	232, 197, 192, 248, 66, 34, 34, 0, 116, 98, 232, 197, 192, 116, 98, 240,
    	139, 128, 0, 8, 2, 0, 0, 0, 8, 2, 17, 0, 8, 136, 130, 8,
    	32, 0, 62, 15, 128, 0, 65, 4, 17, 17, 0, 116, 66, 98, 0, 128,
    	116, 107, 123, 65, 224, 34, 163, 31, 198, 32, 244, 99, 232, 199, 192, 116,
    	97, 8, 69, 192, 244, 99, 24, 199, 192, 252, 33, 232, 67, 224, 252, 33,
    	232, 66, 0, 124, 97, 9, 197, 224, 140, 99, 248, 198, 32, 113, 8, 66,
    	17, 192, 56, 132, 33, 73, 128, 140, 169, 138, 74, 32, 132, 33, 8, 67,
    	224, 142, 235, 90, 198, 32, 140, 115, 89, 198, 32, 116, 99, 24, 197, 192,
    	244, 99, 232, 66, 0, 116, 99, 26, 201, 160, 244, 99, 234, 74, 32, 116,
    	96, 224, 197, 192, 253, 72, 66, 16, 128, 140, 99, 24, 197, 192, 140, 99,
    	24, 168, 128, 140, 99, 90, 213, 64, 140, 84, 69, 70, 32, 140, 84, 66,
    	16, 128, 248, 68, 228, 67, 224, 122, 16, 132, 33, 224, 4, 16, 65, 4,
    	0, 120, 66, 16, 133, 224, 34, 162, 0, 0, 0, 0, 0, 0, 3, 224,
    	99, 8, 32, 0, 0, 0, 24, 39, 73, 224, 132, 45, 152, 230, 192, 0,
    	29, 24, 69, 192, 8, 91, 56, 205, 160, 0, 29, 31, 193, 192, 17, 72,
    	226, 16, 128, 0, 29, 57, 180, 46, 132, 45, 152, 198, 32, 32, 24, 66,
    	17, 192, 16, 4, 33, 73, 128, 132, 37, 76, 82, 64, 97, 8, 66, 17,
    	192, 0, 53, 90, 214, 160, 0, 45, 152, 198, 32, 0, 29, 24, 197, 192,
    	0, 45, 156, 218, 16, 0, 27, 57, 180, 33, 0, 45, 152, 66, 0, 0,
    	31, 7, 7, 192, 33, 62, 66, 20, 64, 0, 35, 24, 205, 160, 0, 35,
    	24, 168, 128, 0, 35, 26, 213, 64, 0, 34, 162, 42, 32, 0, 35, 23,
    	134, 46, 0, 62, 34, 35, 224, 17, 8, 130, 16, 64, 33, 8, 2, 16,
    	128, 65, 8, 34, 17, 0, 69, 68, 0, 0, 0, 35, 183, 24, 252, 0,
    	116, 97, 8, 184, 76, 4, 65, 24, 205, 160, 24, 29, 31, 193, 224, 248,
    	24, 39, 73, 224, 4, 88, 39, 73, 224, 192, 24, 39, 73, 224, 48, 24,
    	39, 73, 224, 3, 241, 135, 136, 192, 248, 29, 31, 193, 224, 136, 29, 31,
    	193, 224, 192, 29, 31, 193, 224, 40, 12, 33, 8, 224, 50, 76, 33, 8,
    	224, 96, 12, 33, 8, 224, 170, 163, 31, 198, 32, 32, 8, 168, 254, 49,
    	48, 61, 14, 67, 192, 0, 30, 39, 201, 224, 58, 165, 249, 74, 96, 116,
    	64, 232, 197, 192, 4, 93, 24, 197, 192, 6, 0, 232, 197, 192, 116, 65,
    	24, 205, 160, 6, 1, 24, 205, 160, 72, 18, 148, 156, 46, 139, 163, 24,
    	197, 192, 136, 35, 24, 197, 192, 33, 63, 74, 124, 132, 50, 211, 196, 39,
    	224, 222, 221, 242, 124, 132, 228, 165, 201, 94, 82, 25, 72, 226, 18, 152,
    	24, 24, 39, 73, 224, 24, 12, 33, 8, 224, 0, 192, 232, 197, 192, 0,
    	193, 24, 205, 160, 3, 192, 228, 165, 32, 248, 51, 219, 206, 32, 116, 164,
    	240, 124, 0, 116, 98, 224, 124, 0, 32, 8, 200, 69, 192, 0, 1, 248,
    	64, 0, 0, 1, 240, 132, 0, 132, 101, 116, 204, 135, 132, 101, 85, 220,
    	33, 33, 0, 66, 16, 128, 1, 85, 69, 20, 0, 5, 20, 85, 80, 0,
    	168, 42, 10, 130, 160, 85, 85, 85, 85, 85, 253, 127, 95, 215, 245, 16,
    	132, 33, 8, 66, 16, 132, 47, 8, 66, 16, 188, 47, 8, 66, 41, 74,
    	94, 148, 165, 0, 0, 15, 148, 165, 0, 60, 47, 8, 66, 41, 122, 30,
    	148, 165, 41, 74, 82, 148, 165, 0, 62, 30, 148, 165, 41, 122, 31, 128,
    	0, 41, 74, 95, 128, 0, 16, 188, 47, 0, 0, 0, 0, 15, 8, 66,
    	16, 132, 33, 128, 0, 16, 132, 47, 128, 0, 0, 0, 15, 136, 66, 16,
    	132, 33, 136, 66, 0, 0, 15, 128, 0, 16, 132, 47, 136, 66, 16, 134,
    	33, 136, 66, 41, 74, 82, 148, 165, 41, 74, 67, 128, 0, 0, 14, 66,
    	148, 165, 41, 122, 15, 128, 0, 0, 62, 14, 148, 165, 41, 74, 66, 148,
    	165, 0, 62, 15, 128, 0, 41, 122, 14, 148, 165, 16, 190, 15, 128, 0,
    	41, 74, 95, 128, 0, 0, 62, 15, 136, 66, 0, 0, 15, 148, 165, 41,
    	74, 83, 128, 0, 16, 134, 33, 128, 0, 0, 6, 33, 136, 66, 0, 0,
    	3, 148, 165, 41, 74, 95, 148, 165, 16, 190, 47, 136, 66, 16, 132, 47,
    	0, 0, 0, 0, 1, 136, 66, 255, 255, 255, 255, 255, 0, 0, 15, 255,
    	255, 231, 57, 206, 115, 156, 24, 198, 49, 140, 99, 255, 255, 240, 0, 0,
    	0, 27, 41, 73, 160, 3, 163, 232, 199, 208, 7, 231, 8, 66, 0, 7,
    	212, 165, 41, 64, 252, 80, 68, 71, 224, 0, 31, 41, 73, 128, 2, 148,
    	165, 55, 0, 7, 232, 66, 16, 128, 249, 29, 24, 184, 159, 34, 163, 248,
    	168, 128, 34, 163, 21, 43, 96, 50, 12, 232, 197, 192, 0, 0, 234, 213,
    	192, 11, 167, 90, 229, 208, 116, 33, 232, 65, 192, 116, 99, 24, 198, 32,
    	7, 193, 240, 124, 0, 33, 62, 66, 3, 224, 65, 4, 68, 3, 224, 17,
    	16, 65, 3, 224, 57, 72, 66, 16, 132, 33, 8, 66, 82, 156, 49, 129,
    	240, 24, 192, 7, 110, 14, 220, 0, 118, 246, 224, 0, 0, 0, 0, 99,
    	0, 0, 0, 0, 3, 0, 0, 57, 8, 74, 81, 132, 114, 82, 148, 128,
    	0, 112, 204, 199, 128, 0, 0, 30, 247, 188, 0, 0, 0, 0, 0, 0 };
    
    
    static const GFXglyph classicGFXFontGlyphs[256] PROGMEM = {
    	{0,5,8,6,0,0},{5,5,8,6,0,0},{10,5,8,6,0,0},{15,5,8,6,0,0},{20,5,8,6,0,0},{25,5,8,6,0,0},{30,5,8,6,0,0},{35,5,8,6,0,0},
    	{40,5,8,6,0,0},{45,5,8,6,0,0},{50,5,8,6,0,0},{55,5,8,6,0,0},{60,5,8,6,0,0},{65,5,8,6,0,0},{70,5,8,6,0,0},{75,5,8,6,0,0},
    	{80,5,8,6,0,0},{85,5,8,6,0,0},{90,5,8,6,0,0},{95,5,8,6,0,0},{100,5,8,6,0,0},{105,5,8,6,0,0},{110,5,8,6,0,0},{115,5,8,6,0,0},
    	{120,5,8,6,0,0},{125,5,8,6,0,0},{130,5,8,6,0,0},{135,5,8,6,0,0},{140,5,8,6,0,0},{145,5,8,6,0,0},{150,5,8,6,0,0},{155,5,8,6,0,0},
    	{160,5,8,6,0,0},{165,5,8,6,0,0},{170,5,8,6,0,0},{175,5,8,6,0,0},{180,5,8,6,0,0},{185,5,8,6,0,0},{190,5,8,6,0,0},{195,5,8,6,0,0},
    	{200,5,8,6,0,0},{205,5,8,6,0,0},{210,5,8,6,0,0},{215,5,8,6,0,0},{220,5,8,6,0,0},{225,5,8,6,0,0},{230,5,8,6,0,0},{235,5,8,6,0,0},
    	{240,5,8,6,0,0},{245,5,8,6,0,0},{250,5,8,6,0,0},{255,5,8,6,0,0},{260,5,8,6,0,0},{265,5,8,6,0,0},{270,5,8,6,0,0},{275,5,8,6,0,0},
    	{280,5,8,6,0,0},{285,5,8,6,0,0},{290,5,8,6,0,0},{295,5,8,6,0,0},{300,5,8,6,0,0},{305,5,8,6,0,0},{310,5,8,6,0,0},{315,5,8,6,0,0},
    	{320,5,8,6,0,0},{325,5,8,6,0,0},{330,5,8,6,0,0},{335,5,8,6,0,0},{340,5,8,6,0,0},{345,5,8,6,0,0},{350,5,8,6,0,0},{355,5,8,6,0,0},
    	{360,5,8,6,0,0},{365,5,8,6,0,0},{370,5,8,6,0,0},{375,5,8,6,0,0},{380,5,8,6,0,0},{385,5,8,6,0,0},{390,5,8,6,0,0},{395,5,8,6,0,0},
    	{400,5,8,6,0,0},{405,5,8,6,0,0},{410,5,8,6,0,0},{415,5,8,6,0,0},{420,5,8,6,0,0},{425,5,8,6,0,0},{430,5,8,6,0,0},{435,5,8,6,0,0},
    	{440,5,8,6,0,0},{445,5,8,6,0,0},{450,5,8,6,0,0},{455,5,8,6,0,0},{460,5,8,6,0,0},{465,5,8,6,0,0},{470,5,8,6,0,0},{475,5,8,6,0,0},
    	{480,5,8,6,0,0},{485,5,8,6,0,0},{490,5,8,6,0,0},{495,5,8,6,0,0},{500,5,8,6,0,0},{505,5,8,6,0,0},{510,5,8,6,0,0},{515,5,8,6,0,0},
    	{520,5,8,6,0,0},{525,5,8,6,0,0},{530,5,8,6,0,0},{535,5,8,6,0,0},{540,5,8,6,0,0},{545,5,8,6,0,0},{550,5,8,6,0,0},{555,5,8,6,0,0},
    	{560,5,8,6,0,0},{565,5,8,6,0,0},{570,5,8,6,0,0},{575,5,8,6,0,0},{580,5,8,6,0,0},{585,5,8,6,0,0},{590,5,8,6,0,0},{595,5,8,6,0,0},
    	{600,5,8,6,0,0},{605,5,8,6,0,0},{610,5,8,6,0,0},{615,5,8,6,0,0},{620,5,8,6,0,0},{625,5,8,6,0,0},{630,5,8,6,0,0},{635,5,8,6,0,0},
    	{640,5,8,6,0,0},{645,5,8,6,0,0},{650,5,8,6,0,0},{655,5,8,6,0,0},{660,5,8,6,0,0},{665,5,8,6,0,0},{670,5,8,6,0,0},{675,5,8,6,0,0},
    	{680,5,8,6,0,0},{685,5,8,6,0,0},{690,5,8,6,0,0},{695,5,8,6,0,0},{700,5,8,6,0,0},{705,5,8,6,0,0},{710,5,8,6,0,0},{715,5,8,6,0,0},
    	{720,5,8,6,0,0},{725,5,8,6,0,0},{730,5,8,6,0,0},{735,5,8,6,0,0},{740,5,8,6,0,0},{745,5,8,6,0,0},{750,5,8,6,0,0},{755,5,8,6,0,0},
    	{760,5,8,6,0,0},{765,5,8,6,0,0},{770,5,8,6,0,0},{775,5,8,6,0,0},{780,5,8,6,0,0},{785,5,8,6,0,0},{790,5,8,6,0,0},{795,5,8,6,0,0},
    	{800,5,8,6,0,0},{805,5,8,6,0,0},{810,5,8,6,0,0},{815,5,8,6,0,0},{820,5,8,6,0,0},{825,5,8,6,0,0},{830,5,8,6,0,0},{835,5,8,6,0,0},
    	{840,5,8,6,0,0},{845,5,8,6,0,0},{850,5,8,6,0,0},{855,5,8,6,0,0},{860,5,8,6,0,0},{865,5,8,6,0,0},{870,5,8,6,0,0},{875,5,8,6,0,0},
    	{880,5,8,6,0,0},{885,5,8,6,0,0},{890,5,8,6,0,0},{895,5,8,6,0,0},{900,5,8,6,0,0},{905,5,8,6,0,0},{910,5,8,6,0,0},{915,5,8,6,0,0},
    	{920,5,8,6,0,0},{925,5,8,6,0,0},{930,5,8,6,0,0},{935,5,8,6,0,0},{940,5,8,6,0,0},{945,5,8,6,0,0},{950,5,8,6,0,0},{955,5,8,6,0,0},
    	{960,5,8,6,0,0},{965,5,8,6,0,0},{970,5,8,6,0,0},{975,5,8,6,0,0},{980,5,8,6,0,0},{985,5,8,6,0,0},{990,5,8,6,0,0},{995,5,8,6,0,0},
    	{1000,5,8,6,0,0},{1005,5,8,6,0,0},{1010,5,8,6,0,0},{1015,5,8,6,0,0},{1020,5,8,6,0,0},{1025,5,8,6,0,0},{1030,5,8,6,0,0},{1035,5,8,6,0,0},
    	{1040,5,8,6,0,0},{1045,5,8,6,0,0},{1050,5,8,6,0,0},{1055,5,8,6,0,0},{1060,5,8,6,0,0},{1065,5,8,6,0,0},{1070,5,8,6,0,0},{1075,5,8,6,0,0},
    	{1080,5,8,6,0,0},{1085,5,8,6,0,0},{1090,5,8,6,0,0},{1095,5,8,6,0,0},{1100,5,8,6,0,0},{1105,5,8,6,0,0},{1110,5,8,6,0,0},{1115,5,8,6,0,0},
    	{1120,5,8,6,0,0},{1125,5,8,6,0,0},{1130,5,8,6,0,0},{1135,5,8,6,0,0},{1140,5,8,6,0,0},{1145,5,8,6,0,0},{1150,5,8,6,0,0},{1155,5,8,6,0,0},
    	{1160,5,8,6,0,0},{1165,5,8,6,0,0},{1170,5,8,6,0,0},{1175,5,8,6,0,0},{1180,5,8,6,0,0},{1185,5,8,6,0,0},{1190,5,8,6,0,0},{1195,5,8,6,0,0},
    	{1200,5,8,6,0,0},{1205,5,8,6,0,0},{1210,5,8,6,0,0},{1215,5,8,6,0,0},{1220,5,8,6,0,0},{1225,5,8,6,0,0},{1230,5,8,6,0,0},{1235,5,8,6,0,0},
    	{1240,5,8,6,0,0},{1245,5,8,6,0,0},{1250,5,8,6,0,0},{1255,5,8,6,0,0},{1260,5,8,6,0,0},{1265,5,8,6,0,0},{1270,5,8,6,0,0},{1275,5,8,6,0,0}
    };
    
    
    const GFXfont classicGFXfont = { (uint8_t*)classicGFXFontBitmaps,
    						   (GFXglyph*)classicGFXFontGlyphs,
    						   0,
    						   255,
    						   8 };
    You just have to add the .cpp and .h file to your project and then you can draw text using the original gfx font by referencing the classicGFXfont font object.

  3. #3
    Junior Member
    Join Date
    Sep 2022
    Posts
    6
    It works Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •