1. 创建codeblocks工程。
加入字库文件: https://files.cnblogs.com/files/blogs/799931/font.7z?t=1692239003&download=true
2. 编辑代码:
int main(void) { FILE* fphzk = NULL; FILE* fpASC24 = NULL; int i,j, k, offset; int flag; unsigned char buffer[512]; unsigned char word[5]; fphzk = fopen("HZK24H", "rb"); //HZK24S HZK24K HZK24H if(fphzk == NULL){ fprintf(stderr, "error HZK24H\n"); return 1; } fpASC24 = fopen("ASC24H", "rb"); if(fpASC24 == NULL){ fprintf(stderr, "error ASC24\n"); return 1; } while(1){ printf("输入要生成字模的字(多个):"); for(;;){ fgets((char*)word, 3, stdin); if(*word == '\n') break; if(word[0] >= 0x81) { offset = (94*(unsigned int)(word[0]-0xa0-1)+(word[1]-0xa0-1))*72 - (0*15*94*72); fseek(fphzk, offset, SEEK_SET); fread(buffer, 1, 72, fphzk); for(i = 0; i < 72; i++) { for (j = 0; j < 8; j++) { if(buffer[i] & (0x80 >> j)) printf("●"); else printf("○"); } if(i%3==2) printf("\n"); } printf("\n"); } else { offset = (word[0]-0x20)*48 - (0*15*94*48); //区数*94*72 fseek(fpASC24, offset, SEEK_SET); fread(buffer, 1, 48, fpASC24); k=0; for(i = 0; i < 48; i+=2) { for (j = 0; j < 8; j++) { if(buffer[i] & (0x80 >> j)) printf("●"); else printf("○"); } for (j = 0; j < 4; j++) { if(buffer[i+1] & (0x80 >> j)) printf("●"); else printf("○"); } printf("\n"); } printf("\n"); } } } fclose(fphzk); fphzk = NULL; return 0; }
标签:word,buffer,HZK24,ASC24,字体库,72,printf,NULL,fphzk From: https://www.cnblogs.com/moon458/p/17636941.html