IceMan Reference Guide |
'it' can render text into images using FreeType. Two functions support this.
This function creates a single-channel, 8-bit image with the specified string rendered into it. The returned image has a box such that (0, 0) is at the string baseline. The actual height of the image depends on the string itself, but it is always possible to render a line of text in pieces just by translating by the X size of the previous string rendered.
# Make the "Hello" label1 = IceImage DrawString("Hello ", 50, 50, "Georgia", "Bold") label2 = IceImage DrawString("World!", 50, 50, "Georgia", "Bold") # X offset calculation: just grab the x size of the first label # and use it to translate the second before addition offset = list(label1 DataBox at(2), 0) result = label1 Add(label2 Translate(offset)) |
The above example illustrates the utility of the origin being at the baseline: individual strings have different bounding boxes, but are arranged such that concatenation simply requires the use of an x offset. Note that for the purposes of the above example we could just have rendered both words as a single string.
DrawString always returns a single-channel, 8-bit image. IceMan's built-in operations can be used very easily to create color and transparency as desired.
This function returns a List of Lists enumerating the various font family-style combinations available for use. If called with no argmuents it returns the list of fonts installed on the current system. If called with a single file name argument that file is expected to be a text file where each line has three tab delimited columns of "family", "style" and "font file path". To define a mapping between a family and style to a particular font file user the second form of FontChoices.
# List all the fonts that are currently available for use IceImage FontChoices foreach(f, writeln(f)) |
Pixar Animation Studios
|