(1)获取系统的字符集:
const char* sys_charset = GetSysCharset (TRUE);
解析:
此接口在/usr/local/include/gdi.h文件中定义,原型如下:
/**
* \fn const char* GUIAPI GetSysCharset (BOOL wchar)
* \brief Gets the current system charset.
*
* This function gets the current system charset and returns the charset name.
* By default, the system charset is ISO8859-1 (for single-byte charset) or
* GB2312.1980-0 (for wide charset), but you can change it by modifying
* \a MiniGUI.cfg.
*
* \param wchar Whether to retrive the wide charset supported currently.
* \return The read-only buffer of charset name. If you pass \a wchar TRUE,
* This function may return NULL, if there is not any wide
* charset supported.
*/
MG_EXPORT const char* GUIAPI GetSysCharset (BOOL wchar);
其他相关函数:
MG_EXPORT int GUIAPI GetSysCharHeight (void); //Gets the height of a character of the default system font.
MG_EXPORT int GUIAPI GetSysCharWidth (void); //Gets the width of a single-byte character of the default system font
MG_EXPORT int GUIAPI GetSysCCharWidth (void); //Gets the width of a multi-byte character of the default system font
例子:
在MiniGUI.cfg文件中的systemfont项目设置如下:
43 [systemfont]
44 font_number=6
45 font0=rbf-fixed-rrncnn-8-16-ISO8859-1
46 font1=*-fixed-rrncnn-*-16-GB2312
47 font2=*-Courier-rrncnn-*-16-GB2312
48 font3=*-SansSerif-rrncnn-*-16-GB2312
49 font4=*-Times-rrncnn-*-16-GB2312
50 font5=*-Helvetica-rrncnn-*-16-GB2312
51
52 default=0
53 wchar_def=1
54 fixed=1
55 caption=2
56 menu=3
57 control=3
执行如下代码时:
printf("hjhe--sysfont a char height=%d\n",GetSysCharHeight());
printf("hjhe--sysfont single byte weight=%d\n",GetSysCharWidth());
printf("hjhe--sysfont multi byte weight=%d\n",GetSysCCharWidth());
printf("hjhe--sys_charset=%s\n",GetSysCharset (FALSE));
返回:hjhe--sysfont a char height=16
hjhe--sysfont single byte weight=8
hjhe--sysfont multi byte weight=16
hjhe--sys_charset=ISO8859-1
当执行如下代码时:
printf("hjhe--sysfont a char height=%d\n",GetSysCharHeight());
printf("hjhe--sysfont single byte weight=%d\n",GetSysCharWidth());
printf("hjhe--sysfont multi byte weight=%d\n",GetSysCCharWidth());
printf("hjhe--sys_charset=%s\n",GetSysCharset (TRUE));
返回:
hjhe--sysfont a char height=16
hjhe--sysfont single byte weight=8
hjhe--sysfont multi byte weight=16
hjhe--sys_charset=GB2312-0
(2)字符集定义:
在/usr/local/include/gdi.h文件中定义了相关字符集宏:
#define FONT_CHARSET_US_ASCII "US-ASCII"
#define FONT_CHARSET_ISO8859_1 "ISO8859-1"
#define FONT_CHARSET_ISO8859_2 "ISO8859-2"
#define FONT_CHARSET_ISO8859_3 "ISO8859-3"
#define FONT_CHARSET_ISO8859_4 "ISO8859-4"
#define FONT_CHARSET_ISO8859_5 "ISO8859-5"
#define FONT_CHARSET_ISO8859_6 "ISO8859-6"
#define FONT_CHARSET_ISO8859_7 "ISO8859-7"
#define FONT_CHARSET_ISO8859_8 "ISO8859-8"
#define FONT_CHARSET_ISO8859_9 "ISO8859-9"
#define FONT_CHARSET_ISO8859_10 "ISO8859-10"
#define FONT_CHARSET_ISO8859_11 "ISO8859-11"
#define FONT_CHARSET_ISO8859_12 "ISO8859-12"
#define FONT_CHARSET_ISO8859_13 "ISO8859-13"
#define FONT_CHARSET_ISO8859_14 "ISO8859-14"
#define FONT_CHARSET_ISO8859_15 "ISO8859-15"
#define FONT_CHARSET_ISO8859_16 "ISO8859-16"
#define FONT_CHARSET_EUC_CN "EUC-CN"
/**
* \def FONT_CHARSET_GB1988_0
* \brief EUC encoding of GB1988 charset, treat as ISO8859-1.
*/
#define FONT_CHARSET_GB1988_0 "GB1988-0"
/**
* \def FONT_CHARSET_GB2312_0
* \brief EUC encoding of GB2312 charset.
*/
#define FONT_CHARSET_GB2312_0 "GB2312-0"
#define FONT_CHARSET_GBK "GBK"
/**
* \def FONT_CHARSET_GB18030_0
* \brief EUC encoding of GB18030 charset.
*/
#define FONT_CHARSET_GB18030_0 "GB18030-0"
#define FONT_CHARSET_BIG5 "BIG5"
/**
* \def FONT_CHARSET_EUCTW
* \brief EUC encoding of CNS11643 charset, not supported.
*/
#define FONT_CHARSET_EUCTW "EUC-TW"
#define FONT_CHARSET_EUCKR "EUC-KR"
/**
* \def FONT_CHARSET_KSC5636_0
* \brief EUC encoding of KSC5636 charset, treat as ISO8859-1.
*/
#define FONT_CHARSET_KSC5636_0 "KSC5636-0"
/**
* \def FONT_CHARSET_KSC5601_0
* \brief EUC encoding of KSC5601 charset.
*/
#define FONT_CHARSET_KSC5601_0 "KSC5601-0"
#define FONT_CHARSET_EUCJP "EUC-JP"
/**
* \def FONT_CHARSET_JISX0201_0
* \brief EUC encoding of JISX0201 charset.
*/
#define FONT_CHARSET_JISX0201_0 "JISX0201-0"
/**
* \def FONT_CHARSET_JISX0208_0
* \brief EUC encoding of JISX0208 charset.
*/
#define FONT_CHARSET_JISX0208_0 "JISX0208-0"
#define FONT_CHARSET_SHIFTJIS "SHIFT-JIS"
/**
* \def FONT_CHARSET_JISX0201_1
* \brief Shift-JIS encoding of JISX0201 charset
*/
#define FONT_CHARSET_JISX0201_1 "JISX0201-1"
/**
* \def FONT_CHARSET_JISX0208_1
* \brief Shift-JIS encoding of JISX0208 charset.
*/
#define FONT_CHARSET_JISX0208_1 "JISX0208-1"
/**
* \def FONT_CHARSET_ISO_10646_1
* \brief UCS-2 encoding of UNICODE.
*/
#define FONT_CHARSET_ISO_10646_1 "ISO-10646-1"
#define FONT_CHARSET_UTF8 "UTF-8"