Prev | Next


IceMan Reference Guide


Text Rendering

'it' can render text into images using FreeType. Two functions support this.

DrawString(string, width, height, family, style)
string: String to be rendered (string)
width: Nominal width of each character in pixels
height: Nominal height of each character in pixels
family: (Optional) Font family to use, e.g. Courier (Sequence)
style:(Optional) Font style to use, e.g. Bold (Sequence)

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.

List FontChoices(fontMapFile)
List FontChoices(family,style,path)
fontMapFile: (Optional) File to get font mappings from
family:(Optional) A font family name (Sequence)
style:(Optional) The style name (Sequence)
path:(Optional) Path to the font file (Sequence)

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))
				

 


Prev | Next


 

 

Pixar Animation Studios
Copyright© Pixar. All rights reserved.
Pixar® and RenderMan® are registered trademarks of Pixar.
All other trademarks are the properties of their respective holders.