TFT_eSPI provides two complementary approaches to displaying text. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Marcussacapuces91/doc-TFT_eSPI/llms.txt
Use this file to discover all available pages before exploring further.
print() / println() stream interface (inherited from Arduino’s Print class) advances a cursor automatically, while the explicit drawString(), drawNumber(), and drawFloat() family position output using a configurable datum point. Font selection, colour, size, alignment, wrapping, and UTF-8 decoding are all controllable at runtime. Built-in fonts are numbered 1–8 (fonts 4, 6, 7, and 8 are Run Length Encoded), and GFX free fonts can be loaded with setFreeFont().
print() / println() — Arduino Print Stream
Print base class. Renders any printable value at the current cursor position and advances the cursor. println() adds a newline, moving the cursor to the left edge of the next line.
The value to render. Accepts
String, char*, int, float, double, etc.Optional format specifier (e.g.
DEC, HEX, BIN, or decimal places for floats).drawString() — Draw String at Position
(x, y) using the specified font (or the current font if omitted). The position is interpreted relative to the current text datum set by setTextDatum().
The text to render. Accepts both
char[] and Arduino String types.X coordinate (interpreted via the current text datum).
Y coordinate (interpreted via the current text datum).
Font number (1–8). If omitted the current font is used.
int16_t — rendered string width in pixels.
drawCentreString() — Centre-Justified String
x.
Text to render.
X coordinate of the horizontal centre of the string.
Y coordinate of the top of the string.
Font number (1–8).
int16_t — x coordinate at the end of the rendered text.
drawRightString() — Right-Justified String
x.
Text to render.
X coordinate of the right edge of the string.
Y coordinate of the top of the string.
Font number (1–8).
int16_t — rendered string width in pixels.
drawChar() — Draw Single Character
X coordinate for the character top-left corner.
Y coordinate for the character top-left corner.
Character code (ASCII or Unicode glyph).
Foreground colour (overload 1 only).
Background colour (overload 1 only).
Size multiplier (overload 1 only).
Unicode code point to render (overloads 2 & 3).
Font number (overload 3 only).
int16_t — character width in pixels. Overload 1 returns void.
drawNumber() — Draw Integer
setTextPadding() to erase previously displayed values.
Integer value to display.
X coordinate.
Y coordinate.
Font number. If omitted the current font is used.
int16_t — rendered text width in pixels.
drawFloat() — Draw Floating-Point Number
Float value to display.
Number of decimal places to render (0–9).
X coordinate.
Y coordinate.
Font number. If omitted the current font is used.
int16_t — rendered text width in pixels.
setTextColor() — Set Text Colour
bgfill is true the background is also extended across the full padding width.
Text foreground colour (transparent background overload).
Foreground (text) colour.
Background colour painted behind each character.
If
true, fill the full padding width with bgcolor. Default false.setTextSize() — Set Font Size Multiplier
Size multiplier (1–7). Each step adds 8 pixels to the character height:
1 = 8px, 2 = 16px, 3 = 24px, 4 = 32px, …
setTextFont() — Select Built-In Font
print() and drawString() calls. Fonts 1–3 are proportional GLCD bitmaps; fonts 4, 6, 7, and 8 are Run Length Encoded large fonts. Font 0 selects the GLCD default.
Font number (0–8). Values outside the range of loaded fonts are ignored.
setFreeFont() — Select GFX Free Font
NULL (or call with no argument) to revert to the built-in font. Requires the LOAD_GFXFF option to be set in User_Setup.h.
Pointer to a
GFXfont structure (typically a PROGMEM constant). NULL reverts to the built-in GLCD font.setTextDatum() — Set Text Alignment Datum
(x, y) coordinate passed to draw functions is mapped to this datum point on the text bounding box.
A datum constant. Key values:
TL_DATUM (0, default), TC_DATUM (1), TR_DATUM (2), ML_DATUM (3), MC_DATUM (4), MR_DATUM (5), BL_DATUM (6), BC_DATUM (7), BR_DATUM (8), L_BASELINE (9), C_BASELINE (10), R_BASELINE (11).getTextDatum() — Read Current Datum
uint8_t — current datum constant (see setTextDatum()).
setTextPadding() — Set Overwrite Padding Width
Padding width in pixels. The background colour fills from the end of the rendered string up to this total width. Set to 0 to disable.
getTextPadding() — Read Current Padding
uint16_t — current padding width in pixels.
setTextWrap() — Configure Text Wrapping
print() / println() wraps text at the right edge and optionally at the bottom edge of the display.
If
true, text wraps to the next line when reaching the right edge.If
true, text wraps back to the top when reaching the bottom edge. Default false.textWidth() — Measure String Width
The string to measure.
Font number. If omitted the current font is used.
int16_t — string width in pixels.
fontHeight() — Measure Font Height
Font number. If omitted the current font is used.
int16_t — font height in pixels.
decodeUTF8() — UTF-8 Byte Decoder
write() stream path).
Pointer to a UTF-8 encoded byte buffer.
Current position within the buffer; incremented by the decoder.
Number of bytes remaining in the buffer.
Single UTF-8 byte to feed into the stream decoder.
uint16_t — decoded Unicode code point, or 0 if the sequence is incomplete.
setAttribute() / getAttribute() — Library Feature Flags
Feature identifier:
CP437_SWITCH(1) — enable/disable CP437 GLCD font error correctionUTF8_SWITCH(2) — enable/disable UTF-8 decoding in thewrite()stream (on by default)PSRAM_ENABLE(3) — enable/disable PSRAM use for sprites and internal buffers
Value to set:
true / 1 to enable, false / 0 to disable.getAttribute() Returns: uint8_t — current value of the specified attribute.