fbutils.c 添加:
void put_chinese_char(int x, int y, int c, int colidx)
{
int i,j;
uint16_t a = 0, b = 0;
uint16_t bits;
for (i = 0; i < font_vga_16x16.height*2; i++) {
a = font_vga_16x16.data [c * 32 + i];
i++;
b = font_vga_16x16.data [c * 32 + i];
bits = a<<8 | b;
printf("a=0x%02x, b=0x%02x, bits = 0x%04x, font_vga_16x16.width=%d\n", a, b, bits, font_vga_16x16.width);
for (j = 0; j < font_vga_16x16.width; j++, bits <<= 1)
{
if (bits & 0x8000)
pixel (x + j, y + i/2, colidx);
}
}
}
字库文件 font_16x16.c:
#include "font.h"
#define FONTDATAMAX 4096*2
static unsigned char fontdata_16x16[FONTDATAMAX] = {
/*-- 文字: 请 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x40,0x40,0x27,0xFC,0x20,0x40,0x03,0xF8,0x00,0x40,0xE7,0xFE,0x20,0x00,
0x23,0xF8,0x22,0x08,0x23,0xF8,0x22,0x08,0x2B,0xF8,0x32,0x08,0x22,0x28,0x02,0x10,
/*-- 文字: 点 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x02,0x00,0x03,0xFC,0x02,0x00,0x02,0x00,0x3F,0xF0,0x20,0x10,
0x20,0x10,0x20,0x10,0x3F,0xF0,0x00,0x00,0x24,0x88,0x22,0x44,0x42,0x44,0x80,0x04,
/*-- 文字: 击 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,
0x01,0x00,0x01,0x00,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x00,0x08,
/*-- 文字: 十 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
/*-- 文字: 字 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x01,0x00,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,0x00,0x40,0x00,0x80,
0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,
/*-- 文字: 光 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x21,0x08,0x11,0x08,0x09,0x10,0x09,0x20,0x01,0x00,0xFF,0xFE,0x04,0x40,
0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x42,0x08,0x42,0x10,0x42,0x20,0x3E,0xC0,0x00,
/*-- 文字: 标 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x00,0x11,0xFC,0x10,0x00,0x10,0x00,0xFC,0x00,0x13,0xFE,0x30,0x20,0x38,0x20,
0x55,0x28,0x55,0x24,0x92,0x24,0x12,0x22,0x14,0x22,0x10,0x20,0x10,0xA0,0x10,0x40,
/*-- 文字: 校 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x40,0x10,0x20,0x10,0x20,0x11,0xFE,0xFC,0x00,0x10,0x88,0x31,0x04,0x3A,0x02,
0x54,0x88,0x50,0x88,0x90,0x50,0x10,0x50,0x10,0x20,0x10,0x50,0x10,0x88,0x13,0x06,
/*-- 文字: 正 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x11,0x00,0x11,0xF8,
0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0xFF,0xFE,0x00,0x00,
/*-- 文字: 触 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x20,0x20,0x20,0x78,0x20,0x49,0xFC,0x91,0x24,0x7D,0x24,0x55,0x24,0x55,0x24,
0x7D,0xFC,0x55,0x24,0x54,0x20,0x7C,0x28,0x54,0x24,0x57,0xFE,0x45,0x02,0x8C,0x00,
/*-- 文字: 摸 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x11,0x10,0x11,0x10,0x17,0xFC,0x11,0x10,0xFC,0x00,0x13,0xF8,0x12,0x08,0x17,0xF8,
0x1A,0x08,0x33,0xF8,0xD0,0x40,0x17,0xFC,0x10,0xA0,0x11,0x10,0x52,0x08,0x24,0x06,
/*-- 文字: 屏 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x3F,0xF8,0x24,0x10,0x22,0x20,0x2F,0xF8,
0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x42,0x20,0x44,0x20,0x84,0x20,0x08,0x20,
/*-- 文字: 。 --*/
/*-- Franklin Gothic Medium12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0x24,0x00,0x24,0x00,0x18,0x00,0x00,0x00,0x00,0x00,
};
struct fbcon_font_desc font_vga_16x16 = {
VGA16x16_IDX,
"VGA16x16",
16,
16,
fontdata_16x16,
0
};
显示汉字:
int xleft = 300;
int ytop = yres / 4 + 50;
put_chinese_char(xleft + 16*0, ytop + 0 ,0, 1);
put_chinese_char(xleft + 16*1, ytop + 0 ,1, 1);
put_chinese_char(xleft + 16*2, ytop + 0 ,2, 1);
put_chinese_char(xleft + 16*3, ytop + 0 ,3, 1);
put_chinese_char(xleft + 16*4, ytop + 0 ,4, 1);
put_chinese_char(xleft + 16*5, ytop + 0 ,5, 1);
put_chinese_char(xleft + 16*6, ytop + 0 ,6, 1);
put_chinese_char(xleft + 16*7, ytop + 0 ,7, 1);
put_chinese_char(xleft + 16*8, ytop + 0 ,8, 1);
put_chinese_char(xleft + 16*9, ytop + 0 ,9, 1);
put_chinese_char(xleft + 16*10, ytop + 0 ,10, 1);
put_chinese_char(xleft + 16*11, ytop + 0 ,11, 1);
put_chinese_char(xleft + 16*12, ytop + 0 ,12, 1);
就这样搞定!
离线
厉害了大神,我是来学习的。
离线
厉害了
离线
厉害了,大神,就是把汉字的编码指向字库所在的位置
离线
厉害了晕哥,你这精力跟充沛啊!赶不上,只能膜拜
离线
厉害了晕哥
离线
有没有好用的字模提取工具
离线
厉害了
离线
这个可以有,哈哈,每天晕哥都在进步!
离线
这个可以有,哈哈,每天晕哥都在进步!
同学你眼花了,这个是晕哥 18年发的。所以晕哥已经进步了两年你才发现=。=
离线
怎么是显示在虚拟机上?
离线
这个实现中文显示。目前在研究字体
离线