仅当作学习笔记。
步骤:
1.制作字库
首先制作汉字的图片字库,可使用bitmap font generator软件制作,然后用利用GIMP图片编辑器把图片字库转换为C源文件,最后利用得到的C文件与minui/mkfont.c文件一起编译,执行后就会得到字库头文件。注意修改结构体名以及相应cwidth和cheight(字符长宽)。
2.修改代码
用刚才制作的字库头文件替换原有的字库头文件,然后修改graphics.c文件, 添加两个函数,并修改gr_text函数,所有修改如下:
int getGBCharID(unsigned c1, unsigned c2)
{
if (c1 >= 0xB0 && c1 <=0xF7 && c2>=0xA1 && c2<=0xFE)
{
return (c1-0xB0)*94+c2-0xA1;
}
return -1;
}
int getUNICharID(unsigned short unicode)
{
int i;
for (i = 0; i < UNICODE_NUM; i++) {
if (unicode == unicodemap[i]) return i;
}
return -1;
}
int gr_text(int x, int y, const char *s)
{
GGLContext *gl = gr_context;
GRFont *font = gr_font;
unsigned off;
unsigned off2;
unsigned off3;
int id;