The Rt2d Toolkit supports three font formats, one outline and two bitmap fonts. Each font description is contained in a text file with .met extension.
The text file must be in UTF-8 format. This is to provide support for Unicode characters.
The format of a metric 1 file is as follows,
METRICS1
<font bitmap> [<font mask bitmap>]
<base line>
<character code> <left pos> <top pos> <right pos> <bot pos>
<character code> <left pos> <top pos> <right pos> <bot pos>
Each character in the image is surrounded by a boundary. This marks the dimension of the character's bitmap. The start of a character's bitmap is denoted by a marker pixel at the top left of each boundary. It is therefore important that the color values of the marker pixel and the boundary are not used elsewhere. Otherwise the character will use an incorrect area of the bitmap for the character.
The same marker pixel must also be present at the bottom left corner for the first character's bitmap. This is used to determine the height of the font set. Otherwise the font will not be loaded correctly.
The area used for displaying the character is inset by two pixels from the four boundaries. This is to prevent the boundary pixels from appearing when displaying the character.
Metric 2 also support multiple bitmaps for the font. The font can spread over more than one bitmap. This can be used to break up a large image into smaller sections. Or it can be used to support font that have a large number of characters, such as Kanji.
Up to four image bitmaps can be specified.
The format of a metric 2 file is as follows,
METRICS2
<font bitmap> [<font mask bitmap>]
<base line>
<characters>
[<font bitmap>] [<font mask bitmap>]
[<base line>]
[<characters>]
The format of a metric 3 file is as follows,
METRICS3
<font name>
'<character>'
begin
moveto <x> <y>
lineto <x> <y>
curveto <x0> <y0> <x1> <y1> <x2> <y2>
closepath
moveto <x> <y>
end
The Rt2d Toolkit provides support for Unicode characters.
A font is considered to be Unicode if it contains characters outside the ASCII character set. Otherwise it is considered to be a plain ASCII font.
Unicode code characters in a font are encoded using the UTF-8 format in the font metrics file. This is so it remains compatible with a plain ASCII character set, which can be encoded in a single byte UTF-8 format.
Rendering a Unicode string is done as normal using the standard API functions. Depending on the font being used, the string will be treated either as Unicode or plain ASCII. Strings using a Unicode font must be in double byte format. Strings using a plain ASCII font must be in single byte format.
|
|
Rt2dFontDestroy is used to destroy the specified font. All fonts created by an application must be destroyed before the application closes down. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
||||||||||||||||||||||||||||
|
Rt2dFontFlow is used to render the specified string in the given bounding-box and have the text wrap over several lines if necessary. The string is rendered using the specified font, at the specified height and with the given brush. The text is justified within the boundaries of the box according to the specified format. Note that text is rendered until it reaches the end of the string or no more text can be accommodated inside the bounding-box, whichever comes first. The brush is used to determine the color of the font during rendering. The color is treated as a prelit color and is used to modulate the font's bitmap. This means, if the font's bitmap is red and the color is blue, the characters will appear black. Whereas, if the color was red or white, the characters will appear red. The string being rendered is modified during rendering. If the length of the string is greater than the width of the bounding box, the string will be broken into substrings by inserting null characters into any white space. Thus, any string to be rendered must be declared so that it can be modified by the function (declared strings must reside in read/write memory). If the font contains just the ASCII character set, the string is assumed to be in single byte format. If the font contains characters outside the ASCII set, it is assumed to be Unicode and the string must be in double byte format. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontGetFont is used to query if the font is in the font dictionary. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontGetHeight is used to retrieve the 'natural' height of the specified font. For outline fonts this function always returns 1.0, but for bitmap fonts the returned value will depend on the current view settings and the CTM. Therefore, using the bitmap font height when rendering text ensures there is a one-to-one mapping to the display; hence the text's rendered size remains independent of current transformations. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontGetReadCallBack is used to enquire which function is currently used for reading fonts.
|
|
||||||||||||||||
|
Rt2dFontGetStringWidth is used to determine the width of the specified string if it were to be rendered at the given height using the given font. If the font contains just the ASCII character set, then the string is assumed to be in single byte format. If the font contains characters outside the ASCII set, then it is assumed to be Unicode and the string must be in double byte format. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontIsOutline is used to query if the font is an outline or a bitmap font. This affects the way the font is rendered and appearance. Outline fonts are geometric fonts and can be scaled without visual artifacts. Bitmap fonts used a bitmap for displaying the character set. It is quicker than outline fonts but will produce visual artifacts it is not displayed at its recommended height. See Rt2dFontGetHeight for details. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontIsUnicode is used to query if the font is plain ASCII or Unicode. This affects the way strings are treated internally. Plain ASCII fonts treat strings as single bytes. Whereas Unicode fonts requires strings in double byte format. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontRead is used to create a font by reading the information contained in the specified font metrics file (the file extension . The metrics file must be in UTF-8 format. This is to support Unicode characters. Each line in the metric file must be less than 255 bytes, not characters, in length and terminated by a newline character. A side effect of this function is that the image path is changed. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
||||||||||||
|
Rt2dFontSetIntergapSpacing is used to define the horizontal spacing of characters when a string is rendered using the specified font. Essentially, an application can use this function to control the spread of rendered strings. The default spacing is zero, that is, no spreading. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontSetPath is used to specify the current search path for reading fonts from the file system. The search path can be considered to be either absolute or relative. In the latter case the search path is relative to the directory from which the application executable is running (the current directory). When fonts are read the image path is changed. Always include a trailing path separator in the directory name when setting the search path. The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontSetReadCallBack is used to override the function that will be used to read fonts. The default font loading mechanism can be used to read any fonts that are accessible via the usual RenderWare file system. The format of the callback function is:
Rt2dFont * (*Rt2dFontCallBackRead) (const RwChar *name)
|
|
||||||||||||||||||||||||
|
Rt2dFontShow is used to render the specified string using the given font and brush. The height and anchor parameters specify the size and position of the string text when it is rendered; the anchor defines the position of lower-left corner of the string's bounding-box. The anchor is updated to return the position at the end of the string. Note that heights and positions are defined in absolute coordinates and are subject to the current transformation matrix (CTM). The brush is used to determine the color of the font during rendering. The color is treated as a prelit color and is used to modulate the font's bitmap. This means, if the font's bitmap is red and the color is blue, the characters will appear black. Whereas, if the color was red or white, the characters will appear red. If the font contains just the ASCII character set, the string is assumed to be in single byte format. If the font contains characters outside the ASCII set, it is assumed to be Unicode and the string must be in double byte format.
Rt2dFontShow will ignore any characters that are not defined in the .met file. This includes characters such as the linefeed ' The include file rt2d.h and the library file rt2d.lib are required to use this function.
|
|
|
Rt2dFontStreamGetSize is used to determine the size in bytes of the binary representation of the given font. This value is used in the binary chunk header to indicate the size of the chunk. The size of the chunkheader is not included.
|
|
|
Rt2dFontStreamRead is used to read a font from the specified binary stream. Note that prior to this function call, a binary chunk 2d chunk header must be found in the stream using RwStreamFindChunk API function. The sequence to locate and read a brush from a binary stream is as follows: RwStream *stream; Rt2dFont *newFont; stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx"); if( stream ) { if( RwStreamFindChunk(stream, rwID_2DFONT, NULL, NULL) ) { newFont = Rt2dFontStreamRead(stream); } RwStreamClose(stream, NULL); }
|
|
||||||||||||
|
Rt2dFontStreamWrite is used to write the specified font to the given binary stream. Note that the stream will have been opened prior to this function call.
|
|
|
Rt2dFontTexDictionaryGet is used to query the RwTexDictionary currently used for storing the bitmap fonts' textures.
|
|
|
Rt2dFontTexDictionarySet is used to set the RwTexDictionary to be used for storing bitmap fonts' textures.
|
© 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:47:06 2004.
Send Feedback