Wish AdafruitGFX - setfont

derez

Expert
Licensed User
Longtime User
The library has a setfont method which enables use of other than default fonts with inclusion of a font file.
Can it be exposed to the rAdafruitGFX library or an inline C code supplied ?

An example of the use in Arduino code:
B4X:
#include "Adafruit_GFX.h"    // Core graphics library
#include "MCUFRIEND_kbv.h"   // Hardware-specific library
MCUFRIEND_kbv tft;
 
#include "Ard_Logo.h"
 
#define BLACK   0x0000
#define RED     0xF800
#define GREEN   0x07E0
#define WHITE   0xFFFF
#define GREY    0x8410
 
#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSans12pt7b.h"
#include "Fonts/FreeSerif12pt7b.h"
#include "FreeDefaultFonts.h"
 
 
void showmsgXY(int x, int y, int sz, const GFXfont *f, const char *msg)
{
  int16_t x1, y1;
  uint16_t wid, ht;
  tft.setFont(f);
  tft.setCursor(x, y);
  tft.setTextSize(sz);
  tft.println(msg);
}
 
uint8_t r = 255, g = 255, b = 255;
uint16_t color;
 
void setup()
{
  Serial.begin(9600);
  uint16_t ID = tft.readID();
  tft.begin(ID);
  tft.invertDisplay(true);
  tft.setRotation(1);
}
 
void loop(void)
{
  tft.invertDisplay(true);
  tft.fillScreen(WHITE);
 
  tft.drawRGBBitmap(100, 50, Logo, 350, 200);
delay(1000);
  tft.setTextSize(2);
  for (int j = 0; j < 20; j++) {
    color = tft.color565(r -= 12, g -= 12, b -= 12);
    tft.setTextColor(color);
    showmsgXY(95, 280, 1, &FreeSans12pt7b, "ELECTROPEAK PRESENTS");
    delay(20);
  }
delay(1000);
  for (int i = 0; i < 480; i++) {
    tft.vertScroll(0, 480, i);
    tft.drawFastVLine(i, 0, 320, 0xffff); // vertical line
    delay(5);}
  
    while (1);
  }
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User

derez

Expert
Licensed User
Longtime User
I got Hebrew letters in a font file that I created. I have to use the original characters in the code, for example if I put the font for א in a, I have to draw "a" to get the "א".
I want to locate the Hebrew letters higher in the ascii numbers where unused symbols are, write in the code the actual letters in Hebrew and use a sub to subtract the difference in the ascii code to point to the correct location.
I have two problems:
1. all the Hebrew characters' asc() method return -41
2. what is the transverse function to asc() - to define the character by its ascii number (like chr() ) ?

The workaround is of course to write a "dictionary" sub like a map: if st = "א" then draw("a")
 
Last edited:
Top