LCD-TFT显示中文字体,调用中文字库(方法)
下面展示一些 内联代码片
。
/*************************
//在指定位置显示一个汉字字符
//x:0~234
//y:0~308
//num:要显示的字符
//size:字体大小 32
//mode:叠加方式(1)还是非叠加方式(0) :叠加方式:在图片上显示字符,非叠加方式:普通显示
*************************/
void LCD_ShowhanziChar(u16 x,u16 y,u8 num,u8 size,u8 mode,u16 color)
{
#if USE_HORIZONTAL==1
#define MAX_CHAR_POSX 312
#define MAX_CHAR_POSY 232
#else
#define MAX_CHAR_POSX 232
#define MAX_CHAR_POSY 312
#endif
u8 temp;
u8 pos,t;
u16 x0=x,y0=y;
u16 x1,y1;
u16 colortemp=color;
if(x>MAX_CHAR_POSX||y>MAX_CHAR_POSY)return;
//设置窗口
if(!mode) //非叠加方式
{
for(pos=0;pos<size;pos++)
{
temp= hanzi[num][pos];
for(t=0;t<size/2;t++)
{
if(temp&0x01)POINT_COLOR=colortemp;
else POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x,y);
temp>>=1;
x++;
}
pos=pos+1;
x=x0;
y++;
}
x1=x0+8;
y1=y0;
for(pos=1;pos<size;pos++)
{
temp= hanzi[num][pos];
for(t=0;t<size/4;t++)
{
if(temp&0x01)POINT_COLOR=colortemp;
else POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x1,y1);
temp>>=1;
x1++;
}
pos=pos+1;
x1=x0+8;
y1++;
}
}
else//叠加方式 有点丑...
{
for(pos=0;pos<size;pos++)
{
temp= hanzi[num][pos];
for(t=0;t<size/4;t++)
{
if(temp&0x01)LCD_DrawPoint(x+t,y+pos);//画一个点
temp>>=1;
}
pos=pos+1;
}
for(pos=1;pos<size;pos++)
{
temp= hanzi[num][pos];
for(t=0;t<size/4;t++)
{
if(temp&0x01)LCD_DrawPoint(x+8+t,y+pos);//画一个点
temp>>=1;
}
pos=pos+1;
}
}
POINT_COLOR=colortemp;
}
字体目前还不懂如何修改大小,目前字体为32号字体。如果有懂的大佬,欢迎联系交流。