From 4c25fe279c10164600be523eaf2dd6c78192f1ee Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Thu, 21 Nov 2019 18:02:49 +0900 Subject: [PATCH] Fix: When the print function is used with a free font, the vertical offset shifts. --- TFT_eSPI.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index e7936fa..06d4806 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -4222,8 +4222,12 @@ size_t TFT_eSPI::write(uint8_t utf8) cursor_y += (int16_t)textsize * (uint8_t)pgm_read_byte(&gfxFont->yAdvance); } - if (textwrapY && (cursor_y >= (int32_t)_height)) cursor_y = 0; - drawChar(cursor_x, cursor_y, uniCode, textcolor, textbgcolor, textsize); + int32_t y = cursor_y + glyph_ab * textsize; + if (textwrapY && (y >= (int32_t)_height)) { + cursor_y = 0; + y = glyph_ab * textsize; + } + drawChar(cursor_x, y, uniCode, textcolor, textbgcolor, textsize); } cursor_x += pgm_read_byte(&glyph->xAdvance) * (int16_t)textsize; }