measureText and measureChar return negative or wrong sizes
Hi,
Could you provide me with a short example/code snippet so that I can check and try to fix it ?
const auto title_text = "Test";
fb.drawTextEx(title_text, tgx::iVec2(fb.lx() / 2, 16), font_tgx_OpenSans_12, tgx::CENTER,
false, false, tgx::RGB565_Black);
This is actually all I do, everything like its supposed to be.
This is what it actually looks like
When i print the character sizes and the text size they are either negative or very small.
My framebuffer is RGB565 320x240
I can send you a more sophisticated setup but it turned into a bigger project that requires some setup.
Hi,
Just found some time to try your code but it seems to be working correctly for me...
I run the code below (using your example) but 'test' does appear correctly in the middle of the screen.
Can you try it or provide me with a complete example that I can run ?
// install from arduino's library manager or from https://github.com/vindar/ILI9341_T4
#include <ILI9341_T4.h>
// the tgx library
#include <tgx.h>
#include "font_tgx_OpenSans.h"
// DEFAULT WIRING USING SPI 0 ON TEENSY 4/4.1
#define PIN_SCK 13 // mandatory
#define PIN_MISO 12 // mandatory
#define PIN_MOSI 11 // mandatory
#define PIN_DC 10 // mandatory, can be any pin but using pin 10 (or 36 or 37 on T4.1) provides greater performance
#define PIN_CS 9 // optional (but recommended), can be any pin.
#define PIN_RESET 6 // optional (but recommended), can be any pin.
#define PIN_BACKLIGHT 255 // optional, set this only if the screen LED pin is connected directly to the Teensy.
#define PIN_TOUCH_IRQ 255 // optional. set this only if the touchscreen is connected on the same SPI bus
#define PIN_TOUCH_CS 255 // optional. set this only if the touchscreen is connected on the same spi bus
#define SPI_SPEED 20000000
// the screen driver object
ILI9341_T4::ILI9341Driver tft(PIN_CS, PIN_DC, PIN_SCK, PIN_MOSI, PIN_MISO, PIN_RESET, PIN_TOUCH_CS, PIN_TOUCH_IRQ);
// screen dimension (landscape mode)
static const int SLX = 320;
static const int SLY = 240;
uint16_t fb[SLX * SLY]; // main screen framebuffer (150K in DTCM for fastest access)
tgx::Image<tgx::RGB565> im(fb, SLX, SLY); // image that encapsulates fb.
void setup()
{
Serial.begin(9600);
tft.output(&Serial);
while(!tft.begin(SPI_SPEED));
pinMode(PIN_BACKLIGHT, OUTPUT);
digitalWrite(PIN_BACKLIGHT, HIGH); // backlight
tft.setRotation(3); // portrait mode
// test
im.clear(tgx::RGB565_White);
const auto title_text = "Test";
im.drawTextEx(title_text, tgx::iVec2(im.lx() / 2, 16), font_tgx_OpenSans_12, tgx::CENTER, false, false, tgx::RGB565_Black);
tft.update(fb);
}
void loop()
{
}