Skip to main content

Text

Text adds a text leaf to the current container. It takes any C string, plus optional style fields. Fields you leave out fall back to the global font, size and color set on the Fonts page.

Example​

static void labels(int score) {
char buf[32];
snprintf(buf, sizeof buf, "Score: %d", score); // runtime strings are fine

Column("Labels", .layout = { .childGap = 4 }) {
Text("Plain text uses the global style");
Text(buf, .fontSize = 24, .textColor = ColorHex(0xFFD166));
Text("A long paragraph that wraps at word boundaries",
.wrapMode = CC_TEXT_WRAP_WORDS,
.textAlignment = CC_TEXT_ALIGN_CENTER);
}
}

Reference​

NameFormWhat it doesPage
TextText(const char *str, .field = ...)Text leaf. Fields are CC_TextElementConfig: .fontId, .fontSize, .textColor, .letterSpacing, .lineHeight, .wrapMode, .textAlignment. Unset font, size and color fall back to the globals.Text
CC_DEFAULT_FONT_SIZE16Starting global font size.Text