Difference between revisions of "Legacy:Font"
From Spherical
(Created page with "{{subst:objtemp}}") |
(added navbox) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | Sphere has its own font file format. These are files contain bitmap images and have the .rfn extension. You can use the Font object in Sphere to display text on the screen. |
+ | |||
+ | |||
+ | ==Initializing a font object== | ||
+ | * [[API:GetSystemFont|GetSystemFont]](): Load the default system font. | ||
+ | * [[API:LoadFont|LoadFont]](): Load a font file. | ||
+ | |||
+ | ==Function methods== | ||
+ | Use these on an initialized instance of the Font object. | ||
+ | |||
+ | === Font object === | ||
+ | |||
+ | * [[API:Font/clone|Font.clone]](): returns a copy of 'font_object' | ||
+ | |||
+ | ==== Drawing text ==== | ||
+ | |||
+ | * [[API:Font/drawText|Font.drawText]](''x'', ''y'', ''text''): Draw ''text'' at (''x'', ''y'') using the font. | ||
+ | * [[API:Font/drawTextBox|Font.drawTextBox]](''x'', ''y'', ''width'', ''height'', ''y_offset'', ''text''): Draw wrapped ''text'', shifted up/down by ''y_offset'', in the box (''x'', ''y'', ''width'', ''height''). | ||
+ | * [[API:Font/drawZoomedText|Font.drawZoomedText]](''x'', ''y'', ''scale'', ''text''): Draw scaled text with upper-left corner (''x'', ''y'') using the font. | ||
+ | * [[API:Font/wordWrapString|Font.wordWrapString]](''string'', ''width''): Splits a string into an array of lines as if it were wrapped using [[API:Font/drawTextBox|Font.drawTextBox]](). | ||
+ | |||
+ | ==== Font size info ==== | ||
+ | |||
+ | * [[API:Font/getHeight|Font.getHeight]](): Get the height of chars in the font, in pixels. | ||
+ | |||
+ | * [[API:Font/getStringWidth|Font.getStringWidth]](''string''): Determine the width of a ''string'' drawn with the font, in pixels. | ||
+ | * [[API:Font/getStringHeight|Font.getStringHeight]](''string'', ''width''): Determine the height of the ''string'' as if it was drawn by [[API:Font/drawTextBox|Font.drawTextBox]]() with ''width''. | ||
+ | |||
+ | ==== Font color masking ==== | ||
+ | |||
+ | * [[API:Font/getColorMask|Font.getColorMask]](): Get the color mask being used by the font. | ||
+ | * [[API:Font/setColorMask|Font.setColorMask]](''color''): Set the color mask for a font to ''color'' (see [[color masking]]). | ||
+ | |||
+ | ==== Font characters ==== | ||
+ | |||
+ | * [[API:Font/getCharacterImage|Font.getCharacterImage]](code): returns the image in the font_object of the character based on the code, e.g. 65 is 'A' | ||
+ | * [[API:Font/setCharacterImage|Font.setCharacterImage]](code, image): sets the character image in the font_object based on the code | ||
+ | |||
+ | ==== Saving to disk ==== | ||
+ | |||
+ | * [[API:Font/clone|Font.save]](filename): saves the Font_object as a font using the filename 'filename' | ||
+ | |||
+ | {{API:Font/navbox}} | ||
+ | [[Category:Objects]] |
Latest revision as of 21:40, 24 June 2013
Sphere has its own font file format. These are files contain bitmap images and have the .rfn extension. You can use the Font object in Sphere to display text on the screen.
Contents
Initializing a font object
- GetSystemFont(): Load the default system font.
- LoadFont(): Load a font file.
Function methods
Use these on an initialized instance of the Font object.
Font object
- Font.clone(): returns a copy of 'font_object'
Drawing text
- Font.drawText(x, y, text): Draw text at (x, y) using the font.
- Font.drawTextBox(x, y, width, height, y_offset, text): Draw wrapped text, shifted up/down by y_offset, in the box (x, y, width, height).
- Font.drawZoomedText(x, y, scale, text): Draw scaled text with upper-left corner (x, y) using the font.
- Font.wordWrapString(string, width): Splits a string into an array of lines as if it were wrapped using Font.drawTextBox().
Font size info
- Font.getHeight(): Get the height of chars in the font, in pixels.
- Font.getStringWidth(string): Determine the width of a string drawn with the font, in pixels.
- Font.getStringHeight(string, width): Determine the height of the string as if it was drawn by Font.drawTextBox() with width.
Font color masking
- Font.getColorMask(): Get the color mask being used by the font.
- Font.setColorMask(color): Set the color mask for a font to color (see color masking).
Font characters
- Font.getCharacterImage(code): returns the image in the font_object of the character based on the code, e.g. 65 is 'A'
- Font.setCharacterImage(code, image): sets the character image in the font_object based on the code
Saving to disk
- Font.save(filename): saves the Font_object as a font using the filename 'filename'