textWidth()

Typography / Attributes

Description

Calculates and returns the width of any character or text string in the current font.

Syntax

float textWidth(std::string s)

Parameters

NameTypeDescription
sstd::stringthe string to measure

Returns

float

Related

Under the Hood

From Processing.h:

float textWidth(const std::string& s);

Under the Hood

From Processing.cpp:

float PApplet::textWidth(const std::string& s) { return getLineWidth(s); }