ASCII 8×8點(diǎn)陣字庫生成器
請(qǐng)自行下載好ASC16文件?;蛘甙l(fā)郵件到我的信箱:dv.xw@qq.com索取。BYET流量傷不起??!
本文引用地址:http://m.butianyuan.cn/article/201611/323415.htm上代碼(讀取ASC16在別人的代碼上改動(dòng)完成):
/**************************************************** FILE qm.c* Write by 萬致遠(yuǎn) * 輸出8x8字體* ************************************************/#include#include #include #include #include #include #include #include #ifdef DEBUG#define debug(fmt, ...) printf(fmt, #__VA_ARGS__)#else#define debug(fmt, ...)#endifvoid display_font_ascii(char *asc){int i, j,k=0;unsigned char outbuf[20];//8*8字體debug("=================");for(i=0;i<20;i++){outbuf[i]=0x00;}for(i=2;i<12;i++){if(i==9 || i == 10) continue;for(j=0;j<8;j++){/* 逐位相與,為1者打印“*”,否則打印空格 */if(asc[i] & (0x80>>j)){if(i==11){k=7;}else{k=i-2;}k=7-k;outbuf[j]=outbuf[j] | (0x80>>k);//printf("j=%d,value=0x%X,k=%d",j,0x80>>k,k);}else{//printf("0");}}//printf("");}printf("{");for(i=0;i<8;i++){if(i!=7){printf("0x%X,",outbuf[i]);}else{printf("0x%X}",outbuf[i]);}}debug("=================");}int main(){int i;unsigned char *p;//unsigned char asciicode[] = "B";unsigned long offset;FILE *asc;char ascii[16];if((asc=fopen("ASC16","rb"))==NULL){perror("Cant Open ASC16");exit(0);}printf("unsigned char __code ASCII[][8]={");/* ASCII字庫文件 */for (i = 32; i < 127; i++){// debug("%c %x", asciicode[i], asciicode[i]); /* 打印數(shù)值 */offset = i*16;debug("offset: %x", offset); /* 打印偏移量 */fseek(asc,offset,SEEK_SET);fread(ascii,16,1,asc); /* 讀取16字節(jié) */display_font_ascii(ascii); /* 顯示 */if(i==126){printf("};");}else{printf(",");}}fclose(asc);return 0;}
評(píng)論