The CFont
class represents fonts and font metrics.
More...
#include <CFont.h>
Public Member Functions | |
INT8 | GetCharWidth (CHAR ch) |
Gets the advance width of the specified character in this Font. | |
INT16 | GetCharsWidth (const CHAR *ch, UINT16 offset, UINT16 length) |
Returns the advance width of the characters in ch, starting at the specified offset and for the specified number of characters (length). | |
INT16 | GetStringWidth (const CString *str) |
Gets the total advance width for showing the specified String in this Font. | |
INT16 | GetSubstringWidth (const CString *str, UINT16 offset, UINT16 length) |
Gets the total advance width for showing the specified substring in this Font. | |
INT8 | GetHeight () |
Gets the standard height of a line of text in this font. | |
const UINT8 * | GetCharData (CHAR ch) |
Gets the pointer to specified char. | |
Static Public Member Functions | |
static CFont * | GetDefaultFont () |
Gets the default font of the system. | |
static CFont * | GetFont (INT8 face, INT8 style, INT8 size) |
Obtains an object representing a font having the specified face, style, and size. |
The CFont
class represents fonts and font metrics.
Fonts cannot be created by applications. Instead, applications query for fonts based on font attributes and the system will attempt to provide a font that matches the requested attributes as closely as possible. A Font's attributes are style, size, and face.
const UINT8 * CFont::GetCharData | ( | CHAR | ch | ) |
Gets the pointer to specified char.
INT16 CFont::GetCharsWidth | ( | const CHAR * | ch, | |
UINT16 | offset, | |||
UINT16 | length | |||
) |
Returns the advance width of the characters in ch, starting at the specified offset and for the specified number of characters (length).
The advance width is the horizontal distance that would be occupied if the characters were to be drawn using this Font, including inter-character spacing following the characters necessary for proper positioning of subsequent text. The offset and length parameters must specify a valid range of characters within the character array ch. The offset parameter must be within the range [0..(ch.length)], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= ch.length.
ch | - the array of characters | |
offset | - the index of the first character to measure | |
length | - the number of characters to measure |
INT8 CFont::GetCharWidth | ( | CHAR | ch | ) |
Gets the advance width of the specified character in this Font.
The advance width is the horizontal distance that would be occupied if ch were to be drawn using this Font, including inter-character spacing following ch necessary for proper positioning of subsequent text.
ch | - the character to be measured |
CFont * CFont::GetDefaultFont | ( | ) | [static] |
Gets the default font of the system.
CFont * CFont::GetFont | ( | INT8 | face, | |
INT8 | style, | |||
INT8 | size | |||
) | [static] |
Obtains an object representing a font having the specified face, style, and size.
If a matching font does not exist, the system will attempt to provide the closest match. This method always returns a valid font object, even if it is not a close match to the request.
face | - one of FACE_SYSTEM, FACE_MONOSPACE, or FACE_PROPORTIONAL | |
style | - STYLE_PLAIN, or a combination of STYLE_BOLD, STYLE_ITALIC, and STYLE_UNDERLINED | |
size | - one of SIZE_SMALL, SIZE_MEDIUM, or SIZE_LARGE |
INT8 CFont::GetHeight | ( | ) |
Gets the standard height of a line of text in this font.
INT16 CFont::GetStringWidth | ( | const CString * | str | ) |
Gets the total advance width for showing the specified String in this Font.
The advance width is the horizontal distance that would be occupied if str were to be drawn using this Font, including inter-character spacing following str necessary for proper positioning of subsequent text.
str | - the String to be measured |
INT16 CFont::GetSubstringWidth | ( | const CString * | str, | |
UINT16 | offset, | |||
UINT16 | length | |||
) |
Gets the total advance width for showing the specified substring in this Font.
The advance width is the horizontal distance that would be occupied if the substring were to be drawn using this Font, including inter-character spacing following the substring necessary for proper positioning of subsequent text.
The offset
and length
parameters must specify a valid range of characters within str
. The offset parameter must be within the range [0..(str.length())]
, inclusive. The length
parameter must be a non-negative integer such that (offset + len) <= str.length()
.
str | - the String to be measured | |
offset | - zero-based index of first character in the substring | |
length | - length of the substring |