Skip to main content

Printing Text

Printing text on Inkplate 2 is simple and intuitive. With support for three colors (black, white, red) and compatibility with the Adafruit GFX library, text rendering is flexible and customizable.

ℹ️
For complete examples of text printing, most Arduino projects in the Inkplate library include some form of text output.

Basic Text Printing

To print text, use setCursor, setTextSize, and print. Below is a basic usage example:

#include "Inkplate.h"
Inkplate inkplate;

void setup() {
inkplate.begin();
inkplate.clearDisplay();
inkplate.setCursor(10, 10);
inkplate.setTextSize(2);
inkplate.setTextColor(INKPLATE2_BLACK);
inkplate.print("Black text!");

inkplate.setCursor(10, 40);
inkplate.setTextColor(INKPLATE2_RED);
inkplate.print("Red text!");

inkplate.setCursor(10, 70);
inkplate.setTextColor(INKPLATE2_WHITE, INKPLATE2_BLACK); // white text on black background
inkplate.print("Text w/ background");

inkplate.display();
}

void loop() {}
Expected output on Inkplate display
Expected output on Inkplate display.

inkplate.setCursor()

Sets the cursor position where the next text will be drawn.

Returns value: none

Function parameters:

TypeNameDescription
intxX coordinate of the cursor.
intyY coordinate of the cursor.

inkplate.setTextSize()

Sets the multiplier for text size (1 is default, 2 is double size, etc.).

Returns value: none

Function parameters:

TypeNameDescription
uint8_tsText size multiplier.

inkplate.setTextColor()

Sets the text color, with an optional background color.

Returns value: none

Function parameters:

TypeNameDescription
uint16_tcolorText color.
uint16_tbackgroundOptional background color.

Custom Fonts

Inkplate 2 also supports custom fonts from the Adafruit GFX library. Download a font, include it in your sketch, and pass it to setFont():

#include "Inkplate.h"
#include "FreeMono9pt7b.h"

Inkplate inkplate;

void setup() {
inkplate.begin();
inkplate.clearDisplay();
inkplate.setFont(&FreeMono9pt7b);
inkplate.setCursor(10, 40);
inkplate.setTextColor(INKPLATE2_RED);
inkplate.print("Custom Font!");
inkplate.display();
}

void loop() {}
Expected output on Inkplate display
Expected output on Inkplate display.

inkplate.setFont()

Sets a custom font from the GFX font collection.

Returns value: none

Function parameters:

TypeNameDescription
const GFXfont *fontPointer to the font struct.