MiniGUI API Reference (MiniGUI-Threads)
v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
|
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. More...
Modules | |
Abstract Character Types | |
MiniGUI uses a Uint32 value to store the type information of a character. | |
Language Code | |
The language code specifies the content language. | |
Data Structures | |
struct | _LOGFONT |
struct | _DEVFONT |
struct | _FONTMETRICS |
struct | _GLYPHBITMAP |
Macros | |
#define | FONT_CHARSET_GB1988_0 "GB1988-0" |
EUC encoding of GB1988 charset, treat as ISO8859-1. More... | |
#define | FONT_CHARSET_GB2312_0 "GB2312-0" |
EUC encoding of GB2312 charset. More... | |
#define | FONT_CHARSET_GB18030_0 "GB18030-0" |
EUC encoding of GB18030 charset. More... | |
#define | FONT_CHARSET_EUCTW "EUC-TW" |
EUC encoding of CNS11643 charset, not supported. More... | |
#define | FONT_CHARSET_KSC5636_0 "KSC5636-0" |
EUC encoding of KSC5636 charset, treat as ISO8859-1. More... | |
#define | FONT_CHARSET_KSC5601_0 "KSC5601-0" |
EUC encoding of KSC5601 charset. More... | |
#define | FONT_CHARSET_JISX0201_0 "JISX0201-0" |
EUC encoding of JISX0201 charset. More... | |
#define | FONT_CHARSET_JISX0208_0 "JISX0208-0" |
EUC encoding of JISX0208 charset. More... | |
#define | FONT_CHARSET_JISX0201_1 "JISX0201-1" |
Shift-JIS encoding of JISX0201 charset. More... | |
#define | FONT_CHARSET_JISX0208_1 "JISX0208-1" |
Shift-JIS encoding of JISX0208 charset. More... | |
#define | FONT_CHARSET_ISO_10646_1 "ISO-10646-1" |
UCS-2 encoding of UNICODE. More... | |
#define | FONT_CHARSET_UTF8 "UTF-8" |
UTF-8 encoding of UNICODE. More... | |
#define | FONT_CHARSET_UTF16LE "UTF-16LE" |
UTF-16 encoding (Little-Endian) of UNICODE. More... | |
#define | FONT_CHARSET_UTF16BE "UTF-16BE" |
UTF-16 encoding (Big-Endian) of UNICODE. More... | |
#define | INV_LOGFONT 0 |
Invalid logfont. More... | |
Typedefs | |
typedef struct _LOGFONT | LOGFONT |
typedef LOGFONT * | PLOGFONT |
Data type of pointer to a LOGFONT. More... | |
typedef struct _WORDINFO | WORDINFO |
Date type of _WORDINFO. More... | |
typedef struct _FONTMETRICS | FONTMETRICS |
typedef struct _GLYPHBITMAP | GLYPHBITMAP |
Enumerations | |
enum | FT2LCDFilter { MG_SMOOTH_NONE = 0, MG_SMOOTH_DEFAULT = 1, MG_SMOOTH_LIGHT = 2, MG_SMOOTH_LEGACY = 16, MG_SMOOTH_MAX } |
Functions | |
MG_EXPORT void GUIAPI | GetFontMetrics (LOGFONT *log_font, FONTMETRICS *font_metrics) |
Get metrics information of a logical font. More... | |
MG_EXPORT void GUIAPI | GetGlyphBitmap (LOGFONT *log_font, const char *mchar, int mchar_len, GLYPHBITMAP *glyph_bitmap) |
Get the glyph bitmap information when uses a logical font to output a multi-byte character. More... | |
static BOOL GUIAPI | InitVectorialFonts (void) |
Initializes vectorial font renderer. More... | |
static void GUIAPI | TermVectorialFonts (void) |
Terminates vectorial font renderer. More... | |
MG_EXPORT 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. More... | |
MG_EXPORT PLOGFONT GUIAPI | CreateLogFontEx (const char *type, const char *family, const char *charset, char weight, char slant, char flip, char other, char decoration, char rendering, int size, int rotation) |
Creates a logical font. More... | |
MG_EXPORT PLOGFONT GUIAPI | CreateLogFontByName (const char *font_name) |
Creates a logical font by a font name. More... | |
MG_EXPORT PLOGFONT GUIAPI | CreateLogFontForMChar2UChar (const char *charset) |
Create a logical font for conversion from multi-byte character string to Uchar32 string. More... | |
MG_EXPORT PLOGFONT GUIAPI | CreateLogFontIndirect (LOGFONT *logfont) |
Creates a logical font indirectly from a LOGFONT structure. More... | |
MG_EXPORT PLOGFONT GUIAPI | CreateLogFontIndirectEx (LOGFONT *logfont, int rotation) |
Creates a new logical font indirectly from a LOGFONT structure with a rotation degrees. More... | |
MG_EXPORT void GUIAPI | DestroyLogFont (PLOGFONT log_font) |
Destroys a logical font. More... | |
MG_EXPORT void GUIAPI | GetLogFontInfo (HDC hdc, LOGFONT *log_font) |
Get logical font information of a DC. More... | |
MG_EXPORT PLOGFONT GUIAPI | GetCurFont (HDC hdc) |
Get the pointer to the current logical font of a DC. More... | |
MG_EXPORT PLOGFONT GUIAPI | SelectFont (HDC hdc, PLOGFONT log_font) |
Selects a logical font into a DC. More... | |
const MG_EXPORT DEVFONT *GUIAPI | GetNextDevFont (const DEVFONT *dev_font) |
Get next devfont information. More... | |
MG_EXPORT BOOL GUIAPI | ft2SetLcdFilter (LOGFONT *logfont, FT2LCDFilter filter) |
Set freetype2 smooth mode. More... | |
MG_EXPORT DEVFONT *GUIAPI | LoadDevFontFromIncoreData (const char *devfont_name, const void *data) |
Load device font from incore data. More... | |
MG_EXPORT DEVFONT *GUIAPI | LoadDevFontFromFile (const char *devfont_name, const char *file_name) |
Load device font from font file. More... | |
MG_EXPORT void GUIAPI | DestroyDynamicDevFont (DEVFONT **devfont) |
Destroy device font loaded dynamically from font file. More... | |
Variables | |
const typedef LOGFONT * | CPLOGFONT |
Data type of pointer to a LOGFONT. More... | |
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 FT2LCDFilter |
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. Since version 4.0.0, you can specify up to 7 family names separated by comma, e.g., "Helvetica,黑体,Naskh,SansSerif". Note that a family name should be encoded in UTF-8 and without special characters (middle spaces are allowed). |
charset | The charset of the logical font. You can specify a sigle-byte charset like "ISO8859-1", or a multi-byte charset like "UTF-8", or "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 vector fonts (use FreeType 2 font engine). |
Example:
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. Note that since version 4.0.0, you can specify up to 7 family names in the LOGFONT name, such as:
ttf-Courier,宋体,Naskh,SansSerif-rrncns-U-16-UTF-8
In this way, you can specify a logfont to use multiple devfonts to render a complex text. This is useful when different glyphs are contained in different font files. It is well known that, a font is often designed for a particular language/script or a few similar languages/scripts.
Since 4.0.0, the previous width field of a logfont name is used for the glyph orientation:
font_name | The name of the logfont. |
PLOGFONT GUIAPI CreateLogFontEx | ( | const char * | type, |
const char * | family, | ||
const char * | charset, | ||
char | weight, | ||
char | slant, | ||
char | flip, | ||
char | other, | ||
char | decoration, | ||
char | rendering, | ||
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. Since version 4.0.0, you can specify up to 7 family names separated by comma, e.g., "Helvetica,黑体,Naskh,SansSerif". Note that a family name should be encoded in UTF-8 and without special characters (middle spaces are allowed). |
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" and "UTF-8". |
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:
|
decoration | The decoration (underline and/or struckout line) of the logical font, can be one of the values:
|
rendering | The rendering type 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:
PLOGFONT GUIAPI CreateLogFontForMChar2UChar | ( | const char * | charset | ) |
Create a logical font for conversion from multi-byte character string to Uchar32 string.
This function creates a logical font in order to convert a multi-byte character string to Uchar32 string. You can use this logfont for GetUCharsUntilParagraphBoundary.
charset | The charset name of the multi-byte character string. |
Since 4.0.0
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. |
Creates a new logical font indirectly from a LOGFONT structure with a rotation degrees.
This function creates a new logical font from information in the LOGFONT object logfont and the new rotation value rotation.
Since 4.0.0.
logfont | The pointer to the reference logical font structure. |
rotation | The rotation of the logical font, it is in units of tenth degrees. Note that you can specify rotation only for vector fonts (use FreeType2 font engine). |
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, |
FT2LCDFilter | 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 FT2LCDFilter. |
Get 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 | ||
) |
Get 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 | ||
) |
Get the glyph bitmap information when uses a logical font to output a multi-byte 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:
Get 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. |
|
inlinestatic |
Initializes vectorial font renderer.
Before 5.0.0, for the performance reason, under MiniGUI-Processes and MiniGUI-Standalone runtime modes, MiniGUI does not load vector fonts, such as TrueType or Adobe Type 1, at startup automatically. This function initializes the vector font engines for MiniGUI-Processes and MiniGUI-Standalone apps. If you want to render text in vector fonts, you must call this function to initialize the vector font engines.
Since 5.0.0, MiniGUI always initialize the vector font engines at startup if it was configured for all runtime modes.
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. |
DEVFONT *GUIAPI LoadDevFontFromIncoreData | ( | const char * | devfont_name, |
const void * | data | ||
) |
Load device font from incore data.
This function can be used to load device font from incore data.
devfont_name | The device font name. |
data | The pointer to the incore font data. |
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:
|
inlinestatic |
Terminates vectorial font renderer.
Before 5.0.0, this function terminates the vector font engines. When you are done with the vector fonts, you should call this function to unload the vector fonts to save memory.
Since 5.0.0, MiniGUI always initialize the FreeType fonts at startup if it was configured for all runtime modes. Therefore, this function does nothing.