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
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;
Image, Image.image
int baseline()
font baseline (pixels from top)
height, text_extents
int height()
array(int) text_extents(string text, ...)
Calculate extents of a text-image, that would be created by calling write with the same arguments.
- string text, ...
- One or more lines of text.
an array of width and height
write, height, baseline
object|int load(string filename)
Loads a font file to this font object.
- string filename
- Font file
zero upon failure, font object upon success
write
void set_xspacing_scale(float scale)
void set_yspacing_scale(float scale)
Set spacing scale to write characters closer or more far away. This does not change scale of character, only the space between them.
- float scale
- what scale to use
object write(string text, ...)
Writes some text; thus creating an image object that can be used as mask or as a complete picture.
- string text, ...
- One or more lines of text.
an Image::image object
text_extents, load, image::paste_mask, image::paste_alpha_color