Helma logo
helma.org » Home > Stories > Image.setFont()

Image.setFont()

Determines the typeface font to be used in current drawing actions.

Syntax
imageObject.setFont(nameString, styleNumber, sizeNumber)

Using this function sets the font to be used in subsequent calls of the drawString() function.

The nameString argument specifies the font face as string (e.g. "sansserif", "dialog").

The integer styleNumber sets the font to normal (0), bold (1), italic (2) or bold and italic (3).

The sizeNumber, an integer as well, refers to the font size in pixels.

Please take a look at the description about adding fonts to the Java runtime for a detailed look onto Java's font mechanics.

Example
var img = new Image("http://helma.org/images/original.jpg");
res.write('<img src="/images/original.jpg">');

A picture showing two funny people

img.setColor(255, 255, 255);
img.setFont("serif", 0, 12);
img.drawString("I shot the serif.", 50, 15);
img.setFont("sansserif", 1, 14);
img.drawString("But I didn't shoot", 10, 100);
img.setFont("monospaced", 2, 16);
img.drawString("the monotype.", 15, 115);
img.saveAs("/www/images/processed.png");
res.write('<img src="/images/processed.png">');

A picture with some funny text drawn onto it


... comment


Page last modified on 2002-07-16 17:24 by tobi