Skip to content

Commit 645af66

Browse files
committed
Added Font File Viewer
1 parent b8602d7 commit 645af66

File tree

3 files changed

+473
-274
lines changed

3 files changed

+473
-274
lines changed

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,130 @@ This can be work on Windows 10.
324324
You can download FONTX Editor fron [here](http://elm-chan.org/fsw_e.html).
325325
![FontxEditor](https://user-images.githubusercontent.com/6020549/78731275-3b889800-797a-11ea-81ba-096dbf07c4b8.png)
326326

327+
---
328+
329+
# Font File Viewer
330+
```
331+
$ cc -o dump dump.c fontx.c
332+
$ ./dump fontx/ILGZ16XB.FNT 0x93FA
333+
argc=3
334+
fontFile=[/home/nop/ILFONT03/ILGZ16XB.FNT]
335+
Font width=16
336+
Font height=16
337+
Code flag=0
338+
Number of code blocks=94
339+
Block 0 start=8140 end=817e
340+
Block 1 start=8180 end=81fc
341+
Block 2 start=8240 end=827e
342+
Block 3 start=8280 end=82fc
343+
Block 4 start=8340 end=837e
344+
Block 5 start=8380 end=83fc
345+
Block 6 start=8440 end=847e
346+
Block 7 start=8480 end=84fc
347+
Block 8 start=8540 end=857e
348+
Block 9 start=8580 end=85fc
349+
Block 10 start=8640 end=867e
350+
Block 11 start=8680 end=86fc
351+
Block 12 start=8740 end=877e
352+
Block 13 start=8780 end=87fc
353+
Block 14 start=8840 end=887e
354+
Block 15 start=8880 end=88fc
355+
Block 16 start=8940 end=897e
356+
Block 17 start=8980 end=89fc
357+
Block 18 start=8a40 end=8a7e
358+
Block 19 start=8a80 end=8afc
359+
Block 20 start=8b40 end=8b7e
360+
Block 21 start=8b80 end=8bfc
361+
Block 22 start=8c40 end=8c7e
362+
Block 23 start=8c80 end=8cfc
363+
Block 24 start=8d40 end=8d7e
364+
Block 25 start=8d80 end=8dfc
365+
Block 26 start=8e40 end=8e7e
366+
Block 27 start=8e80 end=8efc
367+
Block 28 start=8f40 end=8f7e
368+
Block 29 start=8f80 end=8ffc
369+
Block 30 start=9040 end=907e
370+
Block 31 start=9080 end=90fc
371+
Block 32 start=9140 end=917e
372+
Block 33 start=9180 end=91fc
373+
Block 34 start=9240 end=927e
374+
Block 35 start=9280 end=92fc
375+
Block 36 start=9340 end=937e
376+
Block 37 start=9380 end=93fc
377+
Block 38 start=9440 end=947e
378+
Block 39 start=9480 end=94fc
379+
Block 40 start=9540 end=957e
380+
Block 41 start=9580 end=95fc
381+
Block 42 start=9640 end=967e
382+
Block 43 start=9680 end=96fc
383+
Block 44 start=9740 end=977e
384+
Block 45 start=9780 end=97fc
385+
Block 46 start=9840 end=987e
386+
Block 47 start=9880 end=98fc
387+
Block 48 start=9940 end=997e
388+
Block 49 start=9980 end=99fc
389+
Block 50 start=9a40 end=9a7e
390+
Block 51 start=9a80 end=9afc
391+
Block 52 start=9b40 end=9b7e
392+
Block 53 start=9b80 end=9bfc
393+
Block 54 start=9c40 end=9c7e
394+
Block 55 start=9c80 end=9cfc
395+
Block 56 start=9d40 end=9d7e
396+
Block 57 start=9d80 end=9dfc
397+
Block 58 start=9e40 end=9e7e
398+
Block 59 start=9e80 end=9efc
399+
Block 60 start=9f40 end=9f7e
400+
Block 61 start=9f80 end=9ffc
401+
Block 62 start=e040 end=e07e
402+
Block 63 start=e080 end=e0fc
403+
Block 64 start=e140 end=e17e
404+
Block 65 start=e180 end=e1fc
405+
Block 66 start=e240 end=e27e
406+
Block 67 start=e280 end=e2fc
407+
Block 68 start=e340 end=e37e
408+
Block 69 start=e380 end=e3fc
409+
Block 70 start=e440 end=e47e
410+
Block 71 start=e480 end=e4fc
411+
Block 72 start=e540 end=e57e
412+
Block 73 start=e580 end=e5fc
413+
Block 74 start=e640 end=e67e
414+
Block 75 start=e680 end=e6fc
415+
Block 76 start=e740 end=e77e
416+
Block 77 start=e780 end=e7fc
417+
Block 78 start=e840 end=e87e
418+
Block 79 start=e880 end=e8fc
419+
Block 80 start=e940 end=e97e
420+
Block 81 start=e980 end=e9fc
421+
Block 82 start=ea40 end=ea7e
422+
Block 83 start=ea80 end=eafc
423+
Block 84 start=eb40 end=eb7e
424+
Block 85 start=eb80 end=ebfc
425+
Block 86 start=ec40 end=ec7e
426+
Block 87 start=ec80 end=ecfc
427+
Block 88 start=ed40 end=ed7e
428+
Block 89 start=ed80 end=edfc
429+
Block 90 start=ee40 end=ee7e
430+
Block 91 start=ee80 end=eefc
431+
Block 92 start=ef40 end=ef7e
432+
Block 93 start=ef80 end=effc
433+
character code=0x93FA
434+
code=93fa
435+
GetFontx OK. code=93fa
436+
00................
437+
01................
438+
02...**********...
439+
03...*........*...
440+
04...*........*...
441+
05...*........*...
442+
06...*........*...
443+
07...**********...
444+
08...*........*...
445+
09...*........*...
446+
10...*........*...
447+
11...*........*...
448+
12...**********...
449+
13...*........*...
450+
14................
451+
15................
452+
```
453+

dump.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include <stdint.h>
5+
#include <stdbool.h>
6+
#include "fontx.h"
7+
8+
int main(int argc, char *argv[]) {
9+
printf("argc=%d\n",argc);
10+
if (argc == 1) {
11+
printf("Usage:%s font_file_path [charcater_code]\n",argv[0]);
12+
return 1;
13+
}
14+
char fontFile[128];
15+
strcpy(fontFile, argv[1]);
16+
printf("fontFile=[%s]\n",fontFile);
17+
18+
FontxFile fxs[2];
19+
Fontx_init(fxs, "", fontFile);
20+
if (!Fontx_openFontxFile(&fxs[1])) {
21+
printf("openFontxFile FAIL\n");
22+
return 1;
23+
}
24+
25+
printf("Font width=%d\n", fxs[1].w);
26+
printf("Font height=%d\n", fxs[1].h);
27+
printf("Code flag=%d\n", fxs[1].is_ank);
28+
printf("Number of code blocks=%d\n", fxs[1].bc);
29+
30+
uint16_t block[2];
31+
for(int i=0;i<fxs[1].bc;i++) {
32+
if(fread(block, 1, 4, fxs[1].file) != 4){
33+
printf("fread failed\n");
34+
return 1;
35+
}
36+
printf("Block %d start=%x end=%x\n", i, block[0], block[1]);
37+
}
38+
39+
if (argc == 3) {
40+
printf("character code=%s\n", argv[2]);
41+
long lv = strtol(argv[2], NULL, 16);
42+
uint16_t code = lv;
43+
printf("code=%x\n",code);
44+
45+
unsigned char fonts[128]; // font pattern
46+
unsigned char pw, ph;
47+
if (!GetFontx(fxs, code, fonts, &pw, &ph)) { // code -> Font pattern
48+
printf("GetFontx FAIL. code=%x\n", code);
49+
} else {
50+
printf("GetFontx OK. code=%x\n", code);
51+
ShowFont(fonts, pw, ph);
52+
}
53+
}
54+
55+
fclose(fxs[1].file);
56+
}

0 commit comments

Comments
 (0)