高级会员

- 积分
- 641
- 金钱
- 641
- 注册时间
- 2012-11-3
- 在线时间
- 6 小时
|
void Show_Str(u16 x,u16 y,u16 width,u16 height,u8 *str,u8 size,u8 mode)
{
u16 x0=x;
u16 y0=y;
u8 bHz=0; //字符或者中文
while(*str!=0)
{
if(!bHz)
{
if(*str>0x80)bHz=1;
else
{
if(x>(x0+width-size/2))
{
y+=size;
x=x0;
}
if(y>(y0+height-size))break;
if(*str==10)
{
printf("回车\r\n");
y+=size;
x=x0;
str++;
continue;
}
else
{
ShowChar(x,y,*str,size,mode);
}
str++;
x+=size/2;
}
}
else
{
bHz=0;
if(x>(x0+width-size))
{
y+=size;
x=x0;
}
if(y>(y0+height-size))break;
Show_Font(x,y,str,size,mode);
str+=2;
x+=size;
}
}
}
上面红色的部分 原子哥是这样写的
if(*str==13)
{
y+=size;
x=x0;
str++;
} 没实现换行功能 我测试了一下 \n的值为10 ,我就改成了if(*str==10) 然后又加了个continue; 才实现换行的功能 |
|