Image.font

This object adds the text-drawing and -creation capabilities of the Image module.

For simple usage, see write and load.

other methods: baseline, height, set_xspacing_scale, set_yspacing_scale, text_extents

NOTE

Short technical documentation on a font file:
            struct file_head 
            {
               unsigned INT32 cookie;   - 0x464f4e54 
               unsigned INT32 version;  - 1 
               unsigned INT32 chars;    - number of chars
               unsigned INT32 height;   - height of font
               unsigned INT32 baseline; - font baseline
               unsigned INT32 o[1];     - position of char_head's
            } *fh;
            struct char_head
            {
               unsigned INT32 width;    - width of this character
               unsigned INT32 spacing;  - spacing to next character
               unsigned char data[1];   - pixmap data (1byte/pixel)
            } *ch;
     

SEE ALSO

Image, Image.image

SYNOPSIS

int baseline()

RETURNS

font baseline (pixels from top)

SEE ALSO

height, text_extents

SYNOPSIS

int height()
array(int) text_extents(string text, ...)

DESCRIPTION

Calculate extents of a text-image, that would be created by calling write with the same arguments.

ARGUMENTS

string text, ...
One or more lines of text.

RETURNS

an array of width and height

SEE ALSO

write, height, baseline

SYNOPSIS

object|int load(string filename)

DESCRIPTION

Loads a font file to this font object.

ARGUMENTS

string filename
Font file

RETURNS

zero upon failure, font object upon success

SEE ALSO

write

SYNOPSIS

void set_xspacing_scale(float scale)
void set_yspacing_scale(float scale)

DESCRIPTION

Set spacing scale to write characters closer or more far away. This does not change scale of character, only the space between them.

ARGUMENTS

float scale
what scale to use

SYNOPSIS

object write(string text, ...)

DESCRIPTION

Writes some text; thus creating an image object that can be used as mask or as a complete picture.

ARGUMENTS

string text, ...
One or more lines of text.

RETURNS

an Image::image object

SEE ALSO

text_extents, load, image::paste_mask, image::paste_alpha_color