Name | text() |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Processing.js Behavior | Font support for the Canvas element varies across browsers. FireFox currently has the best support, but still uses a pre-defined set of fonts. (Documentation to follow soon.) Good alternatives to the browser's Canvas-font functions are available: such as the Glyph method. See also: Canvas Text, BurntToys Bauhaus.
Please use the following demos to learn how fonts can be rendered in Firefox with Processing.js: Letters, Words, width() |
||||||||||||||
Examples | PFont font; // The font must be located in the sketch's // "data" directory to load successfully font = loadFont("FFScala.ttf"); textFont(font); text("word", 15, 30); fill(0, 102, 153); text("word", 15, 60); fill(0, 102, 153, 51); text("word", 15, 90); size(100, 100, P3D); PFont font; font = loadFont("FFScala.ttf"); textFont(font); text("word", 15, 60, -30); fill(0, 102, 153); text("word", 15, 60); PFont font; font = loadFont("FFScala-Bold.ttf"); textFont(font); String s = "The quick brown fox jumped over the lazy dog."; text(s, 15, 20, 70, 70); |
||||||||||||||
Description | Draws text to the screen. Displays the information specified in the data or stringdata parameters on the screen in the position specified by the x and y parameters and the optional z parameter. A font must be set with the textFont() function before text() may be called. The width and height parameters define a rectangular area to display within and may only be used with string data. The text displays in relation to the textAlign() function, which gives the option to draw to the left, right, and center of the coordinates. Use the textMode() function with the SCREEN parameter to display text in 2D at the surface of the window. Change the color of the text with the fill() function. | ||||||||||||||
Syntax | text(data, x, y) text(data, x, y, z) text(stringdata, x, y, width, height) text(stringdata, x, y, width, height, z) |
||||||||||||||
Parameters |
|
||||||||||||||
Usage | Web & Application | ||||||||||||||
Related |
textAlign() textMode() loadFont() PFont textFont() |