MiniGUI uses logical font to render text in a DC. You can create a logical font by using CreateLogFont and select it into a DC by using SelectFont, then you can use this logical font to render text by using TextOutLen or DrawTextEx.
#define FONT_CHARSET_EUCTW "EUC-TW" |
#define FONT_CHARSET_GB18030_0 "GB18030-0" |
#define FONT_CHARSET_GB1988_0 "GB1988-0" |
#define FONT_CHARSET_GB2312_0 "GB2312-0" |
#define FONT_CHARSET_ISO_10646_1 "ISO-10646-1" |
#define FONT_CHARSET_JISX0201_0 "JISX0201-0" |
#define FONT_CHARSET_JISX0201_1 "JISX0201-1" |
#define FONT_CHARSET_JISX0208_0 "JISX0208-0" |
#define FONT_CHARSET_JISX0208_1 "JISX0208-1" |
#define FONT_CHARSET_KSC5601_0 "KSC5601-0" |
#define FONT_CHARSET_KSC5636_0 "KSC5636-0" |
#define FONT_CHARSET_UTF16BE "UTF-16BE" |
#define FONT_CHARSET_UTF16LE "UTF-16LE" |
typedef struct _FONTMETRICS FONTMETRICS |
The font metrics structure.
typedef struct _GLYPHBITMAP GLYPHBITMAP |
The glyph bitmap structure.
enum mg_FT_LcdFilter |
List of values to identify various types of LCD filters, Note a freetype2 specific definition.
PLOGFONT GUIAPI CreateLogFont | ( | const char * | type, | |
const char * | family, | |||
const char * | charset, | |||
char | weight, | |||
char | slant, | |||
char | flip, | |||
char | other, | |||
char | underline, | |||
char | struckout, | |||
int | size, | |||
int | rotation | |||
) |
Creates a logical font.
This function creates a logical font.
type | The type of the logical font, can be one of the values:
| |
family | The family of the logical font, such as "Courier", "Helvetica", and so on. | |
charset | The charset of the logical font. You can specify a sigle-byte charset like "ISO8859-1", or a multi-byte charset like "GB2312-0". | |
weight | The weight of the logical font, can be one of the values:
| |
slant | The slant of the logical font, can be one of the values:
| |
flip | Does flip the glyph of the font, can be one of the following values:
| |
other | Other rendering features, can be one of the following values:
| |
underline | The underline of the logical font, can be one of the values:
| |
struckout | The struckout line of the logical font, can be one of the values:
| |
size | The size, i.e. the height, of the logical font. Note that the size of the created logical font may be different from the size expected. | |
rotation | The rotation of the logical font, it is in units of tenth degrees. Note that you can specify rotation only for TrueType and Adobe Type1 fonts. |
Example:
static LOGFONT *logfont, *logfontgb12, *logfontbig24; logfont = CreateLogFont (NULL, "SansSerif", "ISO8859-1", FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_LINE, 16, 0); logfontgb12 = CreateLogFont (NULL, "song", "GB2312", FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_LINE, 12, 0); logfontbig24 = CreateLogFont (NULL, "ming", "BIG5", FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL, FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_NONE, 24, 0);
PLOGFONT GUIAPI CreateLogFontByName | ( | const char * | font_name | ) |
Creates a logical font by a font name.
This function creates a logical font by a font name specified by font_name.
font_name | The name of the font. |
Creates a logical font indirectly from a LOGFONT structure.
This function creates a logical font from information in a LOGFONT object.
logfont | The pointer to the reference logical font structure. |
void GUIAPI DestroyDynamicDevFont | ( | DEVFONT ** | devfont | ) |
Destroy device font loaded dynamically from font file.
devfont | The double pointer to DEVFONT structure. Note that the pointer must be the double pointer to device font loaded by LoadDevFontFromFile. |
void GUIAPI DestroyLogFont | ( | PLOGFONT | log_font | ) |
Destroys a logical font.
This function destroys the specified logical font log_font.
log_font | The logical font will be destroied. |
BOOL ft2SetLcdFilter | ( | LOGFONT * | logfont, | |
mg_FT_LcdFilter | filter | |||
) |
Set freetype2 smooth mode.
This function can be used to set freetype2 library handle font smooth mode.
logfont | The logical font. | |
filter | The handle font smooth mode, it must be a value of mg_FT_LcdFilter. |
Gets the pointer to the current logical font of a DC.
This function returns the pointer to the current logical font selected to the DC hdc.
hdc | The device context. |
void GUIAPI GetFontMetrics | ( | LOGFONT * | log_font, | |
FONTMETRICS * | font_metrics | |||
) |
Gets metrics information of a logical font.
This function returns the font metrics information of the specified logical font log_font.
log_font | The pointer to the logical font. | |
font_metrics | The buffer receives the metrics information. |
void GUIAPI GetGlyphBitmap | ( | LOGFONT * | log_font, | |
const char * | mchar, | |||
int | mchar_len, | |||
GLYPHBITMAP * | glyph_bitmap | |||
) |
Gets the glyph bitmap information when uses a logical font to output a character.
This function gets the glyph bitmap of one multi-byte character (specified by mchar and mchar_len) and returns the bitmap information through font_bitmap when using log_font to render the character.
log_font | The logical font used to render the character. | |
mchar | The pointer to the multi-byte character. | |
mchar_len | The length of the multi-byte character. | |
glyph_bitmap | The buffer receives the glyph bitmap information. |
Example:
GLYPHBITMAP glyph_bitmap = {0}; GetGlyphBitmap (log_font, "A", 1, &glyph_bitmap);
Gets logical font information of a DC.
This function gets the logical font information of the specified DC hdc, and copies to the LOGFONT structure pointed to by log_font.
hdc | The device context. | |
log_font | The pointer to the LOGFONT structure to save the logical font info. |
Get next devfont information.
This function can be used to enumerate all device fonts loaded by MiniGUI.
dev_font | The pointer to the current device font, can be NULL to get the first device font. |
BOOL GUIAPI InitVectorialFonts | ( | void | ) |
Initializes vectorial font renderer.
This function initializes vectorial font renderer for MiniGUI-Processes application. For the performance reason, MiniGUI-Processes does not load vetorical fonts, such as TrueType or Adobe Type1, at startup. If you want to render text in vectorial fonts, you must call this function to initialize TrueType and Type1 font renderer.
DEVFONT *GUIAPI LoadDevFontFromFile | ( | const char * | devfont_name, | |
const char * | file_name | |||
) |
Load device font from font file.
This function can be used to load device font from font file.Now,it support free type font file and qpf font file.
devfont_name | The device font name. | |
file_name | The font file name. |
Selects a logical font into a DC.
This function selects the specified logical font log_font into the device context hdc.
hdc | The device context. | |
log_font | The pointer to the logical font to be selected into the DC. |
Example:
void OnModeDrawText (HDC hdc) { RECT rc1, rc2, rc3, rc4; const char* szBuff1 = "This is a good day. \n" "This text is drawn by calling DrawText."; const char* szBuff2 = "This is a good day. \n" "This text is drawn by calling DrawText."; const char* szBuff3 = "Single line text, center."; const char* szBuff4 = "This text is drawn by calling DrawText."; rc1.left = 1; rc1.top = 1; rc1.right = 401; rc1.bottom = 101; rc2.left = 0; rc2.top = 110; rc2.right = 401; rc2.bottom = 351; rc3.left = 0; rc3.top = 361; rc3.right = 401; rc3.bottom = 451; rc4.left = 0; rc4.top = 461; rc4.right = 401; rc4.bottom = 551; SetBkColor (hdc, COLOR_lightwhite); Rectangle (hdc, rc1.left, rc1.top, rc1.right, rc1.bottom); Rectangle (hdc, rc2.left, rc2.top, rc2.right, rc2.bottom); Rectangle (hdc, rc3.left, rc3.top, rc3.right, rc3.bottom); Rectangle (hdc, rc4.left, rc4.top, rc4.right, rc4.bottom); InflateRect (&rc1, -1, -1); InflateRect (&rc2, -1, -1); InflateRect (&rc3, -1, -1); InflateRect (&rc4, -1, -1); SelectFont (hdc, logfontgb12); DrawText (hdc, szBuff1, -1, &rc1, DT_NOCLIP | DT_CENTER | DT_WORDBREAK); SelectFont (hdc, logfontgb16); DrawText (hdc, szBuff2, -1, &rc2, DT_NOCLIP | DT_RIGHT | DT_WORDBREAK); SelectFont (hdc, logfontgb24); DrawText (hdc, szBuff3, -1, &rc3, DT_NOCLIP | DT_SINGLELINE | DT_CENTER | DT_VCENTER); SelectFont (hdc, logfontgb16); DrawTextEx (hdc, szBuff4, -1, &rc4, 32, DT_NOCLIP | DT_LEFT | DT_WORDBREAK); }
void GUIAPI TermVectorialFonts | ( | void | ) |
Terminates vectorial font renderer.
This function terminates the vectorial font renderer. When you are done with vectorial fonts, you should call this function to unload the vectorial fonts to save memory.