本文是讲一种快速制作字库的方法,在不需要显示大量中文的时候,一般是两三百个以内的,使用我要说的这种方法效率非常高。如果是完整的GBK字库那需要把字库存在Flash存储器上,但在此就不讲了。
先介绍一下这个字库的来源,那是在几年前使用ucGUI时,发现它里面的那个字库很有意思,很直观,不再是枯燥十六进制代码,但是还是没有中文字库,后来我就在网上找软件,果然找到一个可以生成ucGUI格式的中文字库的软件----ucGUI-gb2312汉字生成器v3,在此得感谢这位大侠提供了这个软件,也才有我今天要说的内容。
现在看看这个软件生成的字库长什么样吧:
这个软件操作简单,在此不多说,如果你真用得着的时候自己去摸索,为了简洁,我没勾选ASCII码,把生成的字库导出来,如下:
-
#include "GUI.H"
-
-
-
/* char: 好 code:0xBAC3 */
-
unsigned char acFontHZ_BAC3[24] = {
-
__X_____,________,
-
__X__XXX,XX______,
-
__X_____,_X______,
-
XXXXX___,X_______,
-
_X__X__X,________,
-
_X__X__X,________,
-
_X__XXXX,XXX_____,
-
X__X___X,________,
-
_X_X___X,________,
-
__X____X,________,
-
_X_X___X,________,
-
X___X_XX,________
-
};
-
-
/* char: 界 code:0xBDE7 */
-
unsigned char acFontHZ_BDE7[24] = {
-
_XXXXXXX,XX______,
-
_X___X__,_X______,
-
_XXXXXXX,XX______,
-
_X___X__,_X______,
-
_XXXXXXX,XX______,
-
_____X__,________,
-
___XX_XX,________,
-
XXX_____,XXX_____,
-
___X___X,________,
-
___X___X,________,
-
__X____X,________,
-
_X_____X,________
-
};
-
-
/* char: 你 code:0xC4E3 */
-
unsigned char acFontHZ_C4E3[24] = {
-
___X_X__,________,
-
___X_X__,________,
-
__X__XXX,XXX_____,
-
__X__X__,__X_____,
-
_XX_X__X,_X______,
-
X_X____X,________,
-
__X__X_X,_X______,
-
__X__X_X,__X_____,
-
__X__X_X,__X_____,
-
__X_X__X,__X_____,
-
__X____X,________,
-
__X___XX,________
-
};
-
-
/* char: 世 code:0xCAC0 */
-
unsigned char acFontHZ_CAC0[24] = {
-
_____X__,X_______,
-
__X__X__,X_______,
-
__X__X__,X_______,
-
__X__X__,X_______,
-
XXXXXXXX,XXX_____,
-
__X__X__,X_______,
-
__X__X__,X_______,
-
__X__X__,X_______,
-
__X__XXX,X_______,
-
__X_____,________,
-
__X_____,________,
-
__XXXXXX,XXX_____
-
};
-
-
GUI_CHARINFO GUI_FontHZ_12x12_CharInfo[4] = {
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_BAC3 }, /*0: 好*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_BDE7 }, /*1: 界*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_C4E3 }, /*2: 你*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_CAC0 }, /*3: 世*/
-
};
-
-
GUI_FONT_PROP GUI_FontHZ_12x12_Prop4 = {
-
0xCAC0, /*start :世*/
-
0xCAC0, /*end :世, len=1*/
-
&GUI_FontHZ_12x12_CharInfo[ 3 ],
-
(void*)0
-
};
-
-
-
GUI_FONT_PROP GUI_FontHZ_12x12_Prop3 = {
-
0xC4E3, /*start :你*/
-
0xC4E3, /*end :你, len=1*/
-
&GUI_FontHZ_12x12_CharInfo[ 2 ],
-
&GUI_FontHZ_12x12_Prop4
-
};
-
-
-
GUI_FONT_PROP GUI_FontHZ_12x12_Prop2 = {
-
0xBDE7, /*start :界*/
-
0xBDE7, /*end :界, len=1*/
-
&GUI_FontHZ_12x12_CharInfo[ 1 ],
-
&GUI_FontHZ_12x12_Prop3
-
};
-
-
-
GUI_FONT_PROP GUI_FontHZ_12x12_Prop1 = {
-
0xBAC3, /*start :好*/
-
0xBAC3, /*end :好, len=1*/
-
&GUI_FontHZ_12x12_CharInfo[ 0 ],
-
&GUI_FontHZ_12x12_Prop2
-
};
-
-
-
GUI_FONT GUI_FontHZ12x12 = {
-
GUI_FONTTYPE_PROP_SJIS,
-
12,
-
12,
-
1,
-
1,
-
&GUI_FontHZ_12x12_Prop1
-
};
注意:在正式使用时要把所有的unsigned char替换成const unsigned char,这样代码才会不会放到单片机的RAM中而是flash中
上面字库中GUI_FontHZ12x12就是这个字库的名字,它是字库链表的头,在显示函数中就是通过这个头去查找要显示的字所在字库的位置,
看看下面这个数组:
-
GUI_CHARINFO GUI_FontHZ_12x12_CharInfo[4] = {
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_BAC3 }, /*0: 好*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_BDE7 }, /*1: 界*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_C4E3 }, /*2: 你*/
-
{ 12, 12, 2, (unsigned char *)&acFontHZ_CAC0 }, /*3: 世*/
-
};
这个数组中存的就是生成的每一个字符或汉字的信息,看数组中的第一行,12, 12, 2, (unsigned char *)&acFontHZ_BAC3,从左到右分别是字库点阵的行宽、列数、每行所占字节数。
-
/* char: 好 code:0xBAC3 */
-
unsigned char acFontHZ_BAC3[24] = {
-
__X_____,________,
-
__X__XXX,XX______,
-
__X_____,_X______,
-
XXXXX___,X_______,
-
_X__X__X,________,
-
_X__X__X,________,
-
_X__XXXX,XXX_____,
-
X__X___X,________,
-
_X_X___X,________,
-
__X____X,________,
-
_X_X___X,________,
-
X___X_XX,________
-
};
这个数组就是字库中好字的点阵,第一次看到这些“X”和“_”我也很疑惑,其实它只是红定义,“X”代表二进制的1,"_"代表二进制的0 。__X_____表示的就是0010 0000(二进制),注释中的BAC3就是好字的GBK码,显示函数就是通过这个编码来查找到存放“好”字点阵数据的这个数组,再根据这个点阵的行、列和每行所占字节数的信息来在屏幕上绘字。
要使用这个字库还得需要两个uCGUI中的头文件,GUI.h和GUIType.h,这两个文件的代码放在最后面,现在来看看使用这个字库的代码:
-
#include "GUI.h"
-
-
GUI_FONT * SystemFont=&GUI_FontHZ12x12;
-
-
extern UInt8 s_lcdBuff[(LCD_Y_MAX+1)/8][LCD_X_MAX+1];
-
-
-
u8 ScreenDrawPoint(u8 x,u8 y,u8 color);//在屏上画一个点的函数
-
-
extern void def_CDC_setPoint(UInt8 (*pLcdBuff)[LCD_X_MAX+1],LCDSIZETYPE xpoint,LCDSIZETYPE ypoint,COLOR color);
-
const GUI_CHARINFO * GetBitMapStruct(GUI_FONT *Font,u16 ch)//根据字符编码查找字符点阵数据
{
GUI_FONT_PROP pProp;
pProp.First=Font->pProp->First;
pProp.Last= Font->pProp->Last;
pProp.paCharInfo=Font->pProp->paCharInfo;
pProp.pNext=Font->pProp->pNext;
if((ch>=0x20 && ch<=0x7F)&& (pProp.First>=0x20 && pProp.Last<=0x7F))
{
while((chpProp.Last)&&pProp.pNext>0)
{
memcpy(&pProp,pProp.pNext,sizeof( GUI_FONT_PROP));
}
if(pProp.First==pProp.Last&&ch==pProp.First)
return pProp.paCharInfo;
else if(!(chpProp.Last)&&pProp.First
return &pProp.paCharInfo[ch-pProp.First];
else if(!pProp.pNext&&ch>pProp.Last)
return Font->pProp->paCharInfo;//反回空格
}
else if(ch>=0x8140 && ch<=0xfefe)
{
while((chpProp.Last)&&pProp.pNext>0)
{
memcpy(&pProp,pProp.pNext,sizeof( GUI_FONT_PROP));
}
if(pProp.First==pProp.Last&&ch==pProp.First)
return pProp.paCharInfo;
else if(!(chpProp.Last)&&pProp.First
return &pProp.paCharInfo[ch-pProp.First];
else if(!pProp.pNext&&ch>pProp.Last)
return Font->pProp->paCharInfo;//反回空格
}
return Font->pProp->paCharInfo;//反回空格
}
-
-
-
void ShowChar(u16 x,u16 y,const GUI_CHARINFO * BitMapStruct,u16 FontColor,u16 BkColor)//显示一个字符的函数
-
{
-
u8 BitMapData;
-
u8 i,j,m;
-
u16 x0=x;//保存x 起点
-
-
if(x>MAX_CHAR_POSX||y>MAX_CHAR_POSY)return;
-
-
for(i=0;iXDist;i++)
-
{
-
for(j=0;jBytesPerLine;j++)//显示点阵的一行
-
{
-
BitMapData=BitMapStruct->pData[i*BitMapStruct->BytesPerLine+j];
-
for(m=0;m<8;m++)
-
{
-
if(BitMapData&0x80)
-
DrawPoint(x,y,FontColor);
-
else
-
DrawPoint(x,y,BkColor);
-
BitMapData<<=1;
-
x++;
-
if((x-x0)>=BitMapStruct->XSize)
-
break;
-
}
-
}
-
x=x0;
-
y++;
-
}
-
}
-
-
-
void ShowStrings(u16 x,u16 y, GUI_FONT *Font,const u8*pStrings,u16 FontColor,u16 BkColor)//显示一串字符的函数
-
{
-
u8 i=0;
-
u16 Strings[64]={0};
-
const GUI_CHARINFO * BitMapStruct;
-
u8 StringSize=0;
-
-
for(i=0;pStrings[i++]!='\0';StringSize++);//计算字符长度
-
for(i=0;StringSize>0;i++)
-
{
-
if(*pStrings<0x7f)
-
{
-
Strings[i]=(u16)*pStrings;
-
pStrings++;
-
StringSize--;
-
}
-
else if(*pStrings>0x7f)
-
{
-
Strings[i]=((u16)*pStrings)<<8;
-
pStrings++;
-
StringSize--;
-
Strings[i]|=(u16)*pStrings;
-
pStrings++;
-
StringSize--;
-
}
-
}
-
-
StringSize=0;
-
i=0;
-
for(i=0;Strings[i++]>0x19;StringSize++);//计算字符长度
-
-
for(i=0;i {
-
BitMapStruct=GetBitMapStruct(Font,Strings[i]);
-
if(x>(127-BitMapStruct->XSize))
-
{
-
y+=BitMapStruct->XDist+1;
-
x=0;
-
}
-
ShowChar(x,y,BitMapStruct,FontColor,BkColor);
-
x+=BitMapStruct->XSize+1;
-
}
-
}
-
-
-
-
u8 ScreenDrawPoint(u8 xpoint,u8 ypoint,u8 color)//画点的函数
-
{
-
UInt8 row,col,offset;
-
-
if( (xpoint>LCD_X_MAX) || (ypoint>LCD_Y_MAX) ) return 1;
-
ypoint=LCD_Y_MAX-ypoint;
-
row=ypoint/8;
-
col=xpoint;
-
offset=ypoint%8;
-
if( color==COLOR_WHITE ){
-
s_lcdBuff[row][col] &= ~(0x01< s_lcdBuff[row][col] |= (0x01< }else if( color==COLOR_XOR ){
-
s_lcdBuff[row][col] ^= (0x01< }
-
-
return 0;
-
}
只要实现在屏上任意坐标画一个点的函数,就可以实现利用上面的函数了,如上面的u8 ScreenDrawPoint(u8 x,u8 y,u8 color),函数中查找字符信息的函数const GUI_CHARINFO * GetBitMapStruct(GUI_FONT *Font,u16 ch)有点难度,这需要对字库结构仔细研究一下才能理解,在此不多说,大家先把代码利用起来再慢慢研究。要显示一串字符只需要调用ShowStrings(u16 x,u16 y, GUI_FONT *Font,const u8*pStrings,u16 FontColor,u16 BkColor)函数,参数x是屏幕X坐标,y是屏幕Y坐标,Font是指定的字库,如ShowStrings(5,10, GUI_FontHZ12x12,“世界你好”,0,0);
下面是GUI.h和GUIType.h的代码:
s_lcdBuff[row][col] ^= (0x01<
}
return 0;
}
只要实现在屏上任意坐标画一个点的函数,就可以实现利用上面的函数了,如上面的u8 ScreenDrawPoint(u8 x,u8 y,u8 color),函数中查找字符信息的函数const GUI_CHARINFO * GetBitMapStruct(GUI_FONT *Font,u16 ch)有点难度,这需要对字库结构仔细研究一下才能理解,在此不多说,大家先把代码利用起来再慢慢研究。要显示一串字符只需要调用ShowStrings(u16 x,u16 y, GUI_FONT *Font,const u8*pStrings,u16 FontColor,u16 BkColor)函数,参数x是屏幕X坐标,y是屏幕Y坐标,Font是指定的字库,如ShowStrings(5,10, GUI_FontHZ12x12,“世界你好”,0,0);
下面是GUI.h和GUIType.h的代码:
//GUIType.h文件
#ifndef GUITYPE_H_INCLUDED
#define GUITYPE_H_INCLUDED
#include " lcd.h"
-
//GUIType.h文件
-
#ifndef GUITYPE_H_INCLUDED
-
#define GUITYPE_H_INCLUDED
-
-
#include "LCD.h"
-
#include "GUIConf.h"
-
-
/* *************************************************************
-
* *
-
* Simple types *
-
* *
-
*************************************************************
-
*/
-
-
typedef const char * GUI_ConstString;
-
-
-
/* *************************************************************
-
* *
-
* Structures *
-
* *
-
*************************************************************
-
*/
-
-
typedef LCD_COLOR GUI_COLOR;
-
typedef LCD_LOGPALETTE GUI_LOGPALETTE;
-
typedef LCD_DRAWMODE GUI_DRAWMODE;
-
typedef LCD_RECT GUI_RECT;
-
-
typedef struct {
-
void (* pfDraw)(int x0,int y0,int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag);
-
GUI_COLOR (* pfIndex2Color)(int Index);
-
} GUI_BITMAP_METHODS;
-
-
typedef struct {
-
U16P XSize;
-
U16P YSize;
-
U16P BytesPerLine;
-
U16P BitsPerPixel;
-
const U8 GUI_UNI_PTR * pData;
-
const GUI_LOGPALETTE GUI_UNI_PTR * pPal;
-
const GUI_BITMAP_METHODS * pMethods;
-
} GUI_BITMAP;
-
-
/* This structure may not be changed because the data that it
-
expects is read in binary form (via any kind of interface,
-
at runtime).
-
This structure should therefor not be changed.
-
*/
-
typedef struct {
-
U16 ID; /* Version 1.00 => 100*/
-
U16 Version;
-
U16 XSize;
-
U16 YSize;
-
U16 BytesPerLine;
-
U16 BitsPerPixel;
-
U16 NumColors;
-
U16 HasTrans;
-
} GUI_BITMAP_STREAM;
-
-
typedef struct {
-
int x,y;
-
unsigned char Pressed;
-
} GUI_PID_STATE;
-
-
/*
-
****************************************
-
* *
-
* FONT structures (new in V1.10) *
-
* *
-
****************************************
-
*/
-
-
/* Translation list. Translates a character code into up to 2
-
indices of images to display on top of each other;
-
'? -> index('a'), index('?) */
-
typedef struct {
-
I16P c0;
-
I16P c1;
-
} GUI_FONT_TRANSLIST;
-
-
typedef struct {
-
U16P FirstChar;
-
U16P LastChar;
-
const GUI_FONT_TRANSLIST GUI_UNI_PTR * pList;
-
} GUI_FONT_TRANSINFO;
-
-
typedef struct {
-
U8 XSize;
-
U8 XDist;
-
U8 BytesPerLine;
-
const unsigned char GUI_UNI_PTR * pData;
-
} GUI_CHARINFO;
-
-
typedef struct GUI_FONT_PROP {
-
U16P First; /* first character */
-
U16P Last; /* last character */
-
const GUI_CHARINFO GUI_UNI_PTR * paCharInfo; /* address of first character */
-
const struct GUI_FONT_PROP GUI_UNI_PTR * pNext; /* pointer to next */
-
} GUI_FONT_PROP;
-
-
typedef struct {
-
const unsigned char GUI_UNI_PTR * pData;
-
const U8 GUI_UNI_PTR * pTransData;
-
const GUI_FONT_TRANSINFO GUI_UNI_PTR * pTrans;
-
U16P FirstChar;
-
U16P LastChar;
-
U8 XSize;
-
U8 XDist;
-
U8 BytesPerLine;
-
} GUI_FONT_MONO;
-
-
-
typedef struct GUI_FONT_INFO {
-
U16P First; /* first character */
-
U16P Last; /* last character */
-
const GUI_CHARINFO* paCharInfo; /* address of first character */
-
const struct GUI_FONT_INFO* pNext; /* pointer to next */
-
} GUI_FONT_INFO;
-
-
/*
-
****************************************
-
* *
-
* FONT info structure *
-
* *
-
****************************************
-
-
This structure is used when retrieving information about a font.
-
It is designed for future expansion without incompatibilities.
-
*/
-
typedef struct {
-
U16 Flags;
-
U8 Baseline;
-
U8 LHeight; /* height of a small lower case character (a,x) */
-
U8 CHeight; /* height of a small upper case character (A,X) */
-
} GUI_FONTINFO;
-
-
#define GUI_FONTINFO_FLAG_PROP (1<<0) /* Is proportional */
-
#define GUI_FONTINFO_FLAG_MONO (1<<1) /* Is monospaced */
-
#define GUI_FONTINFO_FLAG_AA (1<<2) /* Is an antialiased font */
-
#define GUI_FONTINFO_FLAG_AA2 (1<<3) /* Is an antialiased font, 2bpp */
-
#define GUI_FONTINFO_FLAG_AA4 (1<<4) /* Is an antialiased font, 4bpp */
-
-
-
/**********************************************************************
-
*
-
* UNICODE Encoding
-
*
-
***********************************************************************
-
*/
-
typedef U16 tGUI_GetCharCode(const char GUI_UNI_PTR *s);
-
typedef int tGUI_GetCharSize(const char GUI_UNI_PTR *s);
-
typedef int tGUI_CalcSizeOfChar(U16 Char);
-
typedef int tGUI_Encode(char *s, U16 Char);
-
-
typedef struct {
-
tGUI_GetCharCode* pfGetCharCode;
-
tGUI_GetCharSize* pfGetCharSize;
-
tGUI_CalcSizeOfChar* pfCalcSizeOfChar;
-
tGUI_Encode* pfEncode;
-
} GUI_UC_ENC_APILIST;
-
-
/**********************************************************************
-
*
-
* FONT Encoding
-
*
-
***********************************************************************
-
*/
-
-
typedef int tGUI_GetLineDistX(const char GUI_UNI_PTR *s, int Len);
-
typedef int tGUI_GetLineLen(const char GUI_UNI_PTR *s, int MaxLen);
-
typedef void tGL_DispLine(const char GUI_UNI_PTR *s, int Len);
-
-
typedef struct {
-
tGUI_GetLineDistX* pfGetLineDistX;
-
tGUI_GetLineLen* pfGetLineLen;
-
tGL_DispLine* pfDispLine;
-
} tGUI_ENC_APIList;
-
-
extern const tGUI_ENC_APIList GUI_ENC_APIList_SJIS;
-
-
-
/*
-
****************************************
-
* *
-
* FONT methods *
-
* *
-
****************************************
-
-
The parameter to the methods called pFont should be of type
-
GUI_FONT, but unfortunately a lot of compilers can not handle
-
forward declarations right ...
-
So it ends up to be a void pointer.
-
*/
-
-
typedef struct GUI_FONT GUI_FONT;
-
-
typedef void GUI_DISPCHAR(U16 c);
-
typedef int GUI_GETCHARDISTX(U16P c);
-
typedef void GUI_GETFONTINFO(const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO * pfi);
-
typedef char GUI_ISINFONT (const GUI_FONT GUI_UNI_PTR * pFont, U16 c);
-
-
#define DECLARE_FONT(Type) \
-
void GUI##Type##_DispChar (U16P c); \
-
int GUI##Type##_GetCharDistX(U16P c); \
-
void GUI##Type##_GetFontInfo (const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO * pfi); \
-
char GUI##Type##_IsInFont (const GUI_FONT GUI_UNI_PTR * pFont, U16 c)
-
-
#if defined(__cplusplus)
-
extern "C" { /* Make sure we have C-declarations in C++ programs */
-
#endif
-
-
/* MONO: Monospaced fonts */
-
DECLARE_FONT(MONO);
-
#define GUI_FONTTYPE_MONO \
-
GUIMONO_DispChar, \
-
GUIMONO_GetCharDistX, \
-
GUIMONO_GetFontInfo, \
-
GUIMONO_IsInFont, \
-
(tGUI_ENC_APIList*)0
-
-
/* PROP: Proportional fonts */
-
DECLARE_FONT(PROP);
-
#define GUI_FONTTYPE_PROP \
-
GUIPROP_DispChar, \
-
GUIPROP_GetCharDistX, \
-
GUIPROP_GetFontInfo, \
-
GUIPROP_IsInFont, \
-
(tGUI_ENC_APIList*)0
-
-
/* PROP: Proportional fonts SJIS */
-
DECLARE_FONT(PROP);
-
#define GUI_FONTTYPE_PROP_SJIS \
-
GUIPROP_DispChar, \
-
GUIPROP_GetCharDistX, \
-
GUIPROP_GetFontInfo, \
-
GUIPROP_IsInFont, \
-
&GUI_ENC_APIList_SJIS
-
-
/* PROPAA: Proportional, antialiased fonts */
-
DECLARE_FONT(PROPAA);
-
#define GUI_FONTTYPE_PROPAA \
-
GUIPROPAA_DispChar, \
-
GUIPROPAA_GetCharDistX, \
-
GUIPROPAA_GetFontInfo, \
-
GUIPROPAA_IsInFont, \
-
(tGUI_ENC_APIList*)0
-
-
/* PROPAA: Proportional, antialiased fonts, 2bpp */
-
DECLARE_FONT(PROP_AA2);
-
#define GUI_FONTTYPE_PROP_AA2 \
-
GUIPROP_AA2_DispChar, \
-
GUIPROP_AA2_GetCharDistX, \
-
GUIPROP_AA2_GetFontInfo, \
-
GUIPROP_AA2_IsInFont, \
-
(tGUI_ENC_APIList*)0
-
-
/* PROPAA: Proportional, antialiased fonts, 2bpp, SJIS encoding */
-
DECLARE_FONT(PROP_AA2);
-
#define GUI_FONTTYPE_PROP_AA2_SJIS \
-
GUIPROP_AA2_DispChar, \
-
GUIPROP_AA2_GetCharDistX, \
-
GUIPROP_AA2_GetFontInfo, \
-
GUIPROP_AA2_IsInFont, \
-
GUI_ENCODE_SJIS
-
-
/* PROPAA: Proportional, antialiased fonts, 4bpp */
-
DECLARE_FONT(PROP_AA4);
-
#define GUI_FONTTYPE_PROP_AA4 \
-
GUIPROP_AA4_DispChar, \
-
GUIPROP_AA4_GetCharDistX, \
-
GUIPROP_AA4_GetFontInfo, \
-
GUIPROP_AA4_IsInFont, \
-
(tGUI_ENC_APIList*)0
-
-
/* PROPAA: Proportional, antialiased fonts, 4bpp, SJIS encoding */
-
DECLARE_FONT(PROP_AA4);
-
#define GUI_FONTTYPE_PROP_AA4_SJIS \
-
GUIPROP_AA4_DispChar, \
-
GUIPROP_AA4_GetCharDistX, \
-
GUIPROP_AA4_GetFontInfo, \
-
GUIPROP_AA4_IsInFont, \
-
GUI_ENCODE_SJIS
-
-
#if defined(__cplusplus)
-
}
-
#endif
-
-
struct GUI_FONT {
-
GUI_DISPCHAR* pfDispChar;
-
GUI_GETCHARDISTX* pfGetCharDistX;
-
GUI_GETFONTINFO* pfGetFontInfo;
-
GUI_ISINFONT* pfIsInFont;
-
const tGUI_ENC_APIList* pafEncode;
-
U8 YSize;
-
U8 YDist;
-
U8 XMag;
-
U8 YMag;
-
union {
-
const void GUI_UNI_PTR * pFontData;
-
const GUI_FONT_MONO GUI_UNI_PTR * pMono;
-
const GUI_FONT_PROP GUI_UNI_PTR * pProp;
-
} p;
-
U8 Baseline;
-
U8 LHeight; /* height of a small lower case character (a,x) */
-
U8 CHeight; /* height of a small upper case character (A,X) */
-
};
-
-
/*********************************************************************
-
*
-
* Position independent font structures
-
*/
-
typedef struct {
-
U32 ID; /* Font file ID */
-
U16 YSize; /* Height of font */
-
U16 YDist; /* Space of font Y */
-
U16 Baseline; /* Index of baseline */
-
U16 LHeight; /* Height of a small lower case character (a) */
-
U16 CHeight; /* Height of a upper case character (A) */
-
U16 NumAreas; /* Number of character areas */
-
} GUI_SI_FONT;
-
-
typedef struct {
-
U16 First; /* Index of first character */
-
U16 Last; /* Index of last character */
-
} GUI_SIF_CHAR_AREA;
-
-
typedef struct {
-
U16 XSize; /* Size of bitmap data in X */
-
U16 XDist; /* Number of pixels for increment cursor in X */
-
U16 BytesPerLine; /* Number of bytes per line */
-
U16 Dummy;
-
U32 OffData; /* Offset of pixel data */
-
} GUI_SIF_CHARINFO;
-
-
typedef struct tGUI_SIF_APIList_struct {
-
GUI_DISPCHAR * pDispChar;
-
GUI_GETCHARDISTX * pGetCharDistX;
-
GUI_GETFONTINFO * pGetFontInfo;
-
GUI_ISINFONT * pIsInFont;
-
} tGUI_SIF_APIList;
-
-
#define GUI_SIF_TYPE tGUI_SIF_APIList
-
#define GUI_SIF_TYPE_PROP &GUI_SIF_APIList_Prop
-
-
extern const tGUI_SIF_APIList GUI_SIF_APIList_Prop;
-
-
/*
-
*********************************
-
* *
-
* Typedefs *
-
* *
-
*********************************
-
*/
-
-
#ifndef GUI_HMEM
-
#define GUI_HMEM I16P
-
#endif
-
#define GUI_HMEM_NULL (0)
-
typedef GUI_HMEM GUI_HWIN;
-
#endif /* GUITYPE_H_INCLUDED */
-
-
/*************************** End of file ****************************/
-
-
//GUI.h文件
-
#ifndef __GUI_H__
-
#define __GUI_H__
-
-
#include "stm32f10x.h"
-
/**************************************************************
-
*
-
* Defines for constants
-
*
-
***************************************************************
-
*/
-
-
#define USE_HORIZONTAL 1
-
-
-
#define MAX_CHAR_POSX 240
-
#define MAX_CHAR_POSY 400
-
-
-
extern u16 POINT_COLOR,BACK_COLOR;
-
-
#define GUI_FONTTYPE_PROP_SJIS 0
-
//#pragma pack(1)
-
typedef struct {
-
u8 XSize;
-
u8 XDist;
-
u8 BytesPerLine;
-
const u8 * pData;
-
} GUI_CHARINFO;
-
-
typedef struct GUI_FONT_PROP {
-
u16 First; /* first character */
-
u16 Last; /* last character */
-
const GUI_CHARINFO * paCharInfo; /* address of first character */
-
const struct GUI_FONT_PROP * pNext; /* pointer to next */
-
} GUI_FONT_PROP;
-
-
typedef struct GUI_FONT {
-
void * ShowFunction;
-
u8 YSize;
-
u8 YDist;
-
u8 XMag;
-
u8 YMag;
-
const GUI_FONT_PROP * pProp;
-
}GUI_FONT;
-
-
//#pragma pack()
-
-
extern GUI_FONT GUI_FontHZ12x12;
-
//extern GUI_FONT GUI_FontHZ24x24;
-
//extern GUI_FONT GUI_FontHZ26x26;
-
-
extern GUI_FONT * SystemFont;
-
-
#define DrawPoint(x,y,color) ScreenDrawPoint(x,y,color)
-
#define Clear(Color) LCD_Clear(Color)
-
-
extern void LCD_Clear(u16 Color);
-
const GUI_CHARINFO * GetBitMapStruct(GUI_FONT *Font,u16 ch);
-
void ShowChar(u16 x,u16 y,const GUI_CHARINFO * BitMapStruct,u16 FontColor,u16 BkColor);
-
void ShowStrings(u16 x,u16 y, GUI_FONT *Font,const u8*pStrings,u16 FontColor,u16 BkColor);
-
void DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);
-
-
/*****************************************************************************************************/
-
-
-
#define ________ 0x0
-
#define _______X 0x1
-
#define ______X_ 0x2
-
#define ______XX 0x3
-
#define _____X__ 0x4
-
#define _____X_X 0x5
-
#define _____XX_ 0x6
-
#define _____XXX 0x7
-
#define ____X___ 0x8
-
#define ____X__X 0x9
-
#define ____X_X_ 0xa
-
#define ____X_XX 0xb
-
#define ____XX__ 0xc
-
#define ____XX_X 0xd
-
#define ____XXX_ 0xe
-
#define ____XXXX 0xf
-
#define ___X____ 0x10
-
#define ___X___X 0x11
-
#define ___X__X_ 0x12
-
#define ___X__XX 0x13
-
#define ___X_X__ 0x14
-
#define ___X_X_X 0x15
-
#define ___X_XX_ 0x16
-
#define ___X_XXX 0x17
-
#define ___XX___ 0x18
-
#define ___XX__X 0x19
-
#define ___XX_X_ 0x1a
-
#define ___XX_XX 0x1b
-
#define ___XXX__ 0x1c
-
#define ___XXX_X 0x1d
-
#define ___XXXX_ 0x1e
-
#define ___XXXXX 0x1f
-
#define __X_____ 0x20
-
#define __X____X 0x21
-
#define __X___X_ 0x22
-
#define __X___XX 0x23
-
#define __X__X__ 0x24
-
#define __X__X_X 0x25
-
#define __X__XX_ 0x26
-
#define __X__XXX 0x27
-
#define __X_X___ 0x28
-
#define __X_X__X 0x29
-
#define __X_X_X_ 0x2a
-
#define __X_X_XX 0x2b
-
#define __X_XX__ 0x2c
-
#define __X_XX_X 0x2d
-
#define __X_XXX_ 0x2e
-
#define __X_XXXX 0x2f
-
#define __XX____ 0x30
-
#define __XX___X 0x31
-
#define __XX__X_ 0x32
-
#define __XX__XX 0x33
-
#define __XX_X__ 0x34
-
#define __XX_X_X 0x35
-
#define __XX_XX_ 0x36
-
#define __XX_XXX 0x37
-
#define __XXX___ 0x38
-
#define __XXX__X 0x39
-
#define __XXX_X_ 0x3a
-
#define __XXX_XX 0x3b
-
#define __XXXX__ 0x3c
-
#define __XXXX_X 0x3d
-
#define __XXXXX_ 0x3e
-
#define __XXXXXX 0x3f
-
#define _X______ 0x40
-
#define _X_____X 0x41
-
#define _X____X_ 0x42
-
#define _X____XX 0x43
-
#define _X___X__ 0x44
-
#define _X___X_X 0x45
-
#define _X___XX_ 0x46
-
#define _X___XXX 0x47
-
#define _X__X___ 0x48
-
#define _X__X__X 0x49
-
#define _X__X_X_ 0x4a
-
#define _X__X_XX 0x4b
-
#define _X__XX__ 0x4c
-
#define _X__XX_X 0x4d
-
#define _X__XXX_ 0x4e
-
#define _X__XXXX 0x4f
-
#define _X_X____ 0x50
-
#define _X_X___X 0x51
-
#define _X_X__X_ 0x52
-
#define _X_X__XX 0x53
-
#define _X_X_X__ 0x54
-
#define _X_X_X_X 0x55
-
#define _X_X_XX_ 0x56
-
#define _X_X_XXX 0x57
-
#define _X_XX___ 0x58
-
#define _X_XX__X 0x59
-
#define _X_XX_X_ 0x5a
-
#define _X_XX_XX 0x5b
-
#define _X_XXX__ 0x5c
-
#define _X_XXX_X 0x5d
-
#define _X_XXXX_ 0x5e
-
#define _X_XXXXX 0x5f
-
#define _XX_____ 0x60
-
#define _XX____X 0x61
-
#define _XX___X_ 0x62
-
#define _XX___XX 0x63
-
#define _XX__X__ 0x64
-
#define _XX__X_X 0x65
-
#define _XX__XX_ 0x66
-
#define _XX__XXX 0x67
-
#define _XX_X___ 0x68
-
#define _XX_X__X 0x69
-
#define _XX_X_X_ 0x6a
-
#define _XX_X_XX 0x6b
-
#define _XX_XX__ 0x6c
-
#define _XX_XX_X 0x6d
-
#define _XX_XXX_ 0x6e
-
#define _XX_XXXX 0x6f
-
#define _XXX____ 0x70
-
#define _XXX___X 0x71
-
#define _XXX__X_ 0x72
-
#define _XXX__XX 0x73
-
#define _XXX_X__ 0x74
-
#define _XXX_X_X 0x75
-
#define _XXX_XX_ 0x76
-
#define _XXX_XXX 0x77
-
#define _XXXX___ 0x78
-
#define _XXXX__X 0x79
-
#define _XXXX_X_ 0x7a
-
#define _XXXX_XX 0x7b
-
#define _XXXXX__ 0x7c
-
#define _XXXXX_X 0x7d
-
#define _XXXXXX_ 0x7e
-
#define _XXXXXXX 0x7f
-
#define X_______ 0x80
-
#define X______X 0x81
-
#define X_____X_ 0x82
-
#define X_____XX 0x83
-
#define X____X__ 0x84
-
#define X____X_X 0x85
-
#define X____XX_ 0x86
-
#define X____XXX 0x87
-
#define X___X___ 0x88
-
#define X___X__X 0x89
-
#define X___X_X_ 0x8a
-
#define X___X_XX 0x8b
-
#define X___XX__ 0x8c
-
#define X___XX_X 0x8d
-
#define X___XXX_ 0x8e
-
#define X___XXXX 0x8f
-
#define X__X____ 0x90
-
#define X__X___X 0x91
-
#define X__X__X_ 0x92
-
#define X__X__XX 0x93
-
#define X__X_X__ 0x94
-
#define X__X_X_X 0x95
-
#define X__X_XX_ 0x96
-
#define X__X_XXX 0x97
-
#define X__XX___ 0x98
-
#define X__XX__X 0x99
-
#define X__XX_X_ 0x9a
-
#define X__XX_XX 0x9b
-
#define X__XXX__ 0x9c
-
#define X__XXX_X 0x9d
-
#define X__XXXX_ 0x9e
-
#define X__XXXXX 0x9f
-
#define X_X_____ 0xa0
-
#define X_X____X 0xa1
-
#define X_X___X_ 0xa2
-
#define X_X___XX 0xa3
-
#define X_X__X__ 0xa4
-
#define X_X__X_X 0xa5
-
#define X_X__XX_ 0xa6
-
#define X_X__XXX 0xa7
-
#define X_X_X___ 0xa8
-
#define X_X_X__X 0xa9
-
#define X_X_X_X_ 0xaa
-
#define X_X_X_XX 0xab
-
#define X_X_XX__ 0xac
-
#define X_X_XX_X 0xad
-
#define X_X_XXX_ 0xae
-
#define X_X_XXXX 0xaf
-
#define X_XX____ 0xb0
-
#define X_XX___X 0xb1
-
#define X_XX__X_ 0xb2
-
#define X_XX__XX 0xb3
-
#define X_XX_X__ 0xb4
-
#define X_XX_X_X 0xb5
-
#define X_XX_XX_ 0xb6
-
#define X_XX_XXX 0xb7
-
#define X_XXX___ 0xb8
-
#define X_XXX__X 0xb9
-
#define X_XXX_X_ 0xba
-
#define X_XXX_XX 0xbb
-
#define X_XXXX__ 0xbc
-
#define X_XXXX_X 0xbd
-
#define X_XXXXX_ 0xbe
-
#define X_XXXXXX 0xbf
-
#define XX______ 0xc0
-
#define XX_____X 0xc1
-
#define XX____X_ 0xc2
-
#define XX____XX 0xc3
-
#define XX___X__ 0xc4
-
#define XX___X_X 0xc5
-
#define XX___XX_ 0xc6
-
#define XX___XXX 0xc7
-
#define XX__X___ 0xc8
-
#define XX__X__X 0xc9
-
#define XX__X_X_ 0xca
-
#define XX__X_XX 0xcb
-
#define XX__XX__ 0xcc
-
#define XX__XX_X 0xcd
-
#define XX__XXX_ 0xce
-
#define XX__XXXX 0xcf
-
#define XX_X____ 0xd0
-
#define XX_X___X 0xd1
-
#define XX_X__X_ 0xd2
-
#define XX_X__XX 0xd3
-
#define XX_X_X__ 0xd4
-
#define XX_X_X_X 0xd5
-
#define XX_X_XX_ 0xd6
-
#define XX_X_XXX 0xd7
-
#define XX_XX___ 0xd8
-
#define XX_XX__X 0xd9
-
#define XX_XX_X_ 0xda
-
#define XX_XX_XX 0xdb
-
#define XX_XXX__ 0xdc
-
#define XX_XXX_X 0xdd
-
#define XX_XXXX_ 0xde
-
#define XX_XXXXX 0xdf
-
#define XXX_____ 0xe0
-
#define XXX____X 0xe1
-
#define XXX___X_ 0xe2
-
#define XXX___XX 0xe3
-
#define XXX__X__ 0xe4
-
#define XXX__X_X 0xe5
-
#define XXX__XX_ 0xe6
-
#define XXX__XXX 0xe7
-
#define XXX_X___ 0xe8
-
#define XXX_X__X 0xe9
-
#define XXX_X_X_ 0xea
-
#define XXX_X_XX 0xeb
-
#define XXX_XX__ 0xec
-
#define XXX_XX_X 0xed
-
#define XXX_XXX_ 0xee
-
#define XXX_XXXX 0xef
-
#define XXXX____ 0xf0
-
#define XXXX___X 0xf1
-
#define XXXX__X_ 0xf2
-
#define XXXX__XX 0xf3
-
#define XXXX_X__ 0xf4
-
#define XXXX_X_X 0xf5
-
#define XXXX_XX_ 0xf6
-
#define XXXX_XXX 0xf7
-
#define XXXXX___ 0xf8
-
#define XXXXX__X 0xf9
-
#define XXXXX_X_ 0xfa
-
#define XXXXX_XX 0xfb
-
#define XXXXXX__ 0xfc
-
#define XXXXXX_X 0xfd
-
#define XXXXXXX_ 0xfe
-
#define XXXXXXXX 0xff
-
-
-
#endif /* ifdef GUI_H */
阅读(2021) | 评论(0) | 转发(0) |