投入低就是麻烦,俗话说一分钱一分货嘛。买的12864没有字库,不得不自己去找字库。今天有幸找到一个16*8的点阵ASCII字库,8 kByte的点阵,恩,不错,正符合我非常小的flash。这么小的flash,看来是不能放中文字库了。
拿到这个字库,遇到个问题,他只给出了点阵,但没进行标示,我根本不知道每一个序列到底对应哪个字符。刚写了一个读取点阵的程序,终于可以看到实际的点阵效果了:
->> 3---------------------
> <
> <
> <
> [] [] <
> [] [] <
> [] [] <
>[][][][][][][] <
> [] [] <
> [] [] <
> [] [] <
>[][][][][][][] <
> [] [] <
> [] [] <
> [] [] <
> <
> <
--------------------------
->> 4---------------------
> [] <
> [][][] <
> [] [] [] <
>[] [] [] <
>[] [] [] <
> [] [] <
> [][] <
> [][] <
> [] [] <
> [] [] <
>[] [] [] <
>[] [] [] <
> [] [] [] <
> [][][] <
> [] <
> <
--------------------------
程序如下:
#include
#include
unsigned char hex2u8(char *hex)
{
unsigned char resu = 0;
// high
if(hex[0] >= '0' && hex[0] <= '9')
resu = 16*(hex[0] - '0');
else
resu = 16*(hex[0] +10 - 'A');
// low
if(hex[1] >= '0' && hex[1] <= '9')
resu += hex[1] - '0';
else
resu += hex[1] +10 - 'A';
return resu;
}
int main()
{
FILE *IN, *OUT;
unsigned char dot[16], utemp;
char rhex[2];
int i=0, j=0, k=0, line=0;
//rhex[0]='F';
//rhex[1]='F';
//printf("Now %d\n", hex2u8(rhex));
IN=fopen("1608.txt", "r");
OUT=fopen("font.txt", "w");
//fprintf(OUT, "Hello\n");
//fclose(OUT);
while(line < 96)
{
fprintf(OUT, "->>%2d---------------------\n", line);
for(i=0; i < 16; i++)
{
fscanf(IN, "0x%c%c,", &rhex[0], &rhex[1]);
dot[i] = hex2u8(rhex);
//printf("Now %d\n", dot[i]);
fprintf(OUT, "\t>");
for(j=0; j < 8; j++)
{
utemp=(dot[i] << j) & 0x80;
//printf("utemp is:%d\n", utemp);
if(0 == utemp)
//printf("%%");
fprintf(OUT, " ");
else
//printf("*");
fprintf(OUT, "[]");
}
fscanf(IN, "\n");
//printf("\n");
fprintf(OUT, "<\n");
}
fprintf(OUT, "--------------------------\n");
//printf("------------------------\n");
line++;
}
}
字库文件和解析后的文件下载:
|
文件: |
fontread.rar |
大小: |
2KB |
下载: |
下载 | |
阅读(5664) | 评论(0) | 转发(0) |