typography

v0.1.7
text(str, x, y);

Draw text on the screen.

Arguments

strString to render
xThe x position of the start of the text
yThe y position of the top of the text

Fonts are not yet implemented

function setup()
  createWindow(200, 200);
end

function draw()
  background('purple');

  text('Hello from lu5!', 25, 110);
end

Output

See text in typography.h
textFont(font);

Set a font family.

Arguments

fontThe font value returned when using loadFont

function setup()
  createWindow(200, 200);
end

function draw()
  background('purple');

  textFont('Monospace');
  text('Hello from lu5!', 5, 110);
end

Output

See textFont in typography.h
loadFont(path);

Load a font.

Arguments

pathThe font path on the local system

Returns

fontThe image reference

-- For Web
function setup()
  createWindow(200, 200);
  -- loadFont is not needed here...
end

function draw()
  background('purple');

  textFont('Verdana');
  text('Hello from lu5!', 35, 110);
end  

Output

-- For native
function setup()
  createWindow(200, 200);
  font = loadFont('/path/to/myfont.ttf');
end

function draw()
  background('purple');

  textFont(font);
  text('Hello from lu5!', 35, 110);
end   
See loadFont in typography.h
textSize(size);

Set a font size.

Arguments

sizeThe size of the font in pixels

If this is called using fonts, make sure to call textSize after calling textFont

function setup()
  createWindow(200, 200);
end

function draw()
  background('purple');

  textSize(48); -- Larger text
  text('Hello lu5!', 0, 120);
end

Output

See textSize in typography.h
textAlign(mode);

Set a font alignment.

Arguments

modeCENTER, LEFT, RIGHT

function setup()
  createWindow(200, 200);
  textAlign(CENTER); 
end

function draw()
  background('purple');

  text('Hello lu5!', width/2, height/2);
  point(width/2, height/2);
end

Output

See textAlign in typography.h
CENTERConstant

Alignment mode for textAlign.

See CENTER in typography.h
LEFTConstant

Alignment mode for textAlign.

See LEFT in typography.h