Hzk16 must be used in recent projects.
The following is reproduced from the network:
Hzk16 font is in line with gb2312 Standard 16x16 dot matrix font, hzk16 GB2312-80 support 6763 Chinese characters, 682 symbols. among them, there are 3755 first-level Chinese characters, sorted by audio order, 3008 second-level Chinese characters, and arranged by radicals. we cannot use so many Chinese Character Fonts in some application scenarios, so we can extract only some fonts for our use. in the hzk16 font, a total of 256 Chinese characters are displayed, that is, 32 bytes are required to display a common Chinese character. we know that a gb2312 Chinese character is encoded in two bytes in the range of 0xa1a1 ~ 0xfefe. the A1-A9 is the symbol area, B0 to F7 is the Chinese character area. each zone has 94 characters (Note: This is only the permitted range of the encoding, not necessarily the corresponding fonts, for example, there are many blank areas of the Encoding Area ).
Some code is as follows:
Int fd_fb; struct internal var; struct internal fix; int screen_size; unsigned char * fbmem; unsigned int line_width; unsigned int pixel_width; int fd_hzk16; struct stat hzk_stat; unsigned char * hzkmem; void LCD _put_pixel (INT X, int y, unsigned int color) {unsigned char * pen_8 = fbmem + y * line_width + x * pixel_width; unsigned short * pen_16; unsigned int * pen_32; unsigned char red, green, blue; pen_16 = (unsigned short *) pen_8; pen_32 = (unsigned int *) pen_8; Switch (var. bits_per_pixel) {Case 8: {* pen_8 = color; break;} Case 16: {/* r: G: B = */Red = (color> 16) & 0x1f) <11; Green = (color> 8) & 0x3f) <6; Blue = color & 0x1f; * pen_16 = red | green | blue; break;} case 32: {* pen_32 = color;} default: {printf ("can't surport % d BPP \ n", var. bits_per_pixel); break ;}} void LCD _put_ascii (int x, int y, unsigned char c) {unsigned char * DOTS = & fontdata_8x16 [C * 16]; int I, J; unsigned char byte; for (I = 0; I <16; I ++) {byte = dots [I]; for (j = 7; j> = 0; j --) {If (byte & (1 <j) {/* show */LCD _put_pixel (x + 7-j, Y + I, 0 xffffff ); // display white} else {/* hide */LCD _put_pixel (x + 7-j, Y + I, 0x0 ); // display black }}} void LCD _put_chinese (INT X, int y, unsigned char * Str) {unsigned int area = STR [0]-0xa1; // The default UTF-8 storage, "in" UTF-8 storage for d6d0, the storage in fact, the row and column are A1 unsigned int where = STR [1]-0xa1; unsigned char * DOTS = hzkmem + (area * 94 + where) * 32; // each area occupies 94 characters, each character occupies 32 bytes unsigned char byte; int I, j, B; for (I = 0; I <16; I ++) {for (j = 0; j <2; j ++) {byte = dots [I * 2 + J]; for (B = 7; B> = 0; B --) {If (byte & (1 <B )) {/* show */LCD _put_pixel (x + 8 * j + 7-j, Y + I, 0 xffffff ); // display white} else {/* hide */LCD _put_pixel (x + 8 * j + 7-j, Y + I, 0x0); // display black }}}}}
Use of hzk16 in projects