TFT_eSPI inherits from Arduino’sDocumentation 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 class, giving you familiar print() and println() calls alongside a rich set of dedicated text drawing methods. You can choose between the built-in bitmap fonts (numbered 1–8), GFX-compatible fonts loaded at compile time, or smooth anti-aliased TrueType-style fonts loaded at runtime. Text color, background fill, datum alignment, size scaling, wrapping, and padding are all configurable independently, letting you match any display layout requirement.
Text Configuration
Before drawing text you typically call one or more configuration functions. They persist until you change them again.setTextColor
Set the foreground color, and optionally a background fill color.
Foreground (glyph) color in RGB565.
Background color drawn behind each character cell. Providing this avoids the need to erase old text before redrawing.
When
true, the background fill extends to cover the full text padding width set by setTextPadding().setTextSize
Scale the built-in font by an integer multiplier. Size 1 is native resolution; size 2 doubles each pixel.
Integer scale factor (1 = native, 2 = double, etc.).
setTextFont
Select one of the pre-compiled bitmap fonts by number.
Font number.
0 or 1 selects the built-in GLCD 6×8 font; fonts 2–8 are optional compiled-in fonts.setTextDatum
Set the reference point (datum) from which text coordinates are interpreted. This replaces the older drawCentreString / drawRightString helpers.
| Constant | Meaning |
|---|---|
TL_DATUM | Top-left (default) |
TC_DATUM | Top-center |
TR_DATUM | Top-right |
ML_DATUM | Middle-left |
MC_DATUM | Middle-center |
MR_DATUM | Middle-right |
BL_DATUM | Bottom-left |
BC_DATUM | Bottom-center |
BR_DATUM | Bottom-right |
setTextWrap
Enable or disable automatic line wrapping at the right edge, and optionally at the bottom edge.
Wrap at the right edge of the display (or active viewport).
Wrap at the bottom edge. Defaults to
false.setTextPadding and getTextPadding
Reserve a fixed-width background fill zone. When updating a number or string that may shrink, this erases leftover pixels from the previous render.
Width in pixels of the padded fill zone.
Measuring Text
textWidth
Return the rendered pixel width of a string in the given font.
fontHeight
Return the height (in pixels) of the current or specified font.
Drawing Strings
drawString
Draw a string at (x, y) using the current or specified font. Returns the rendered pixel width.
The text to render. Accepts both C-string (
char[]) and Arduino String objects.X coordinate (interpretation depends on
setTextDatum).Y coordinate.
Font number. Omit to use the current font.
drawCentreString
Draw a string horizontally centered on x.
drawRightString
Draw a string right-justified so that its right edge aligns with x.
Drawing Characters
drawChar
Three overloads let you draw a single character either with explicit color/size arguments, or using the current text settings plus a font number.
X coordinate.
Y coordinate.
Character code (first overload).
Glyph color (first overload).
Background color (first overload).
Scale multiplier (first overload).
Unicode code point (second and third overloads).
Font number (third overload).
Drawing Numbers
drawNumber
Draw a long integer using the specified or current font. Returns the rendered width in pixels.
The integer value to display.
X coordinate.
Y coordinate.
Font number. Omit to use the current font.
drawFloat
Draw a floating-point number with a specified number of decimal places. Returns the rendered width in pixels.
The value to display.
Number of decimal places to render.
X coordinate.
Y coordinate.
Font number. Omit to use the current font.
print() and println()
TFT_eSPI inherits the Arduino Print interface, so any data type that can be converted to a string can be streamed directly to the display at the current cursor position.
println() appends a newline and advances the cursor to the left edge of the next line. The cursor position is managed internally and advances automatically after each character.
Use
tft.setCursor(x, y) or tft.setCursor(x, y, font) to position the cursor before calling print() / println().Practical Example — print() vs drawString()
The following sketch demonstrates both approaches side by side on a 240×135 display.
Text Datum Reference
Full list of datum constants and alignment examples.
Anti-Aliased Fonts
Smooth TrueType-style fonts with sub-pixel rendering.