-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMINIFONT.CPP
78 lines (68 loc) · 1.48 KB
/
MINIFONT.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//Œ.à âãáì 12-06-95 12:43pm
#include <stdlib.h>
#include <alloc.h>
#include <io.h>
#include <dos.h>
#include <fcntl.h>
#include <string.h>
#include <stat.h>
#include "famegraf.h"
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
block oldfnt;
block newfnt;
unsigned char leftbit(unsigned char c);
unsigned char rightbit(unsigned char c);
void main (void) {
unsigned int i,j,k,l,r;
oldfnt=(block)famemalloc((unsigned long)2048);
newfnt=(block)famemalloc((unsigned long)2048+256);
_fmemset(newfnt,0,(unsigned long)2048+256);
SetLib("tmp");
GetLib("tmp.fnt",oldfnt);
for( i=0; i<256; i++ ) {
r=l=8;
for( j=0; j<8; j++ ) {
l=min(l,leftbit(oldfnt[i*8+j]));
r=min(r,rightbit(oldfnt[i*8+j]));
}
//ᤢ¨£ ¨ ¯¥à¥®á èà¨ä⮢
for( j=0; j<8; j++ ) {
newfnt[i*8+j]=((oldfnt[i*8+j])<<l);
}
newfnt[2048+i]=8-(l+r);
if (newfnt[2048+i]<2) {
//íâ® ¬¥«ª¨¥ ᨬ¢®«ë ᤢ¨¥¬ ¢¯à ¢® 1
newfnt[2048+i]=4;
for( j=0; j<8; j++ ) {
newfnt[i*8+j]=( ((oldfnt[i*8+j])>>1)&127);
}
}
printf("%u [%d<->%d] = %d\n",i,l,r,newfnt[2048+i]);
}
PutLib("tmp.fit",newfnt,(unsigned long)2048+256);
SetLib("");
}
unsigned char leftbit(unsigned char c) {
int i;
for( i=0; i<7; i++ ) {
if( (c<<i)&128 ) {
return i;
}
}
return 8;
}
unsigned char rightbit(unsigned char c) {
int i;
for( i=0; i<7; i++ ) {
if( (c>>i)&1 ) {
return i;
}
}
return 8;
}
void fatalerror(char *t) {
//¢ë室 ¯® ä ⠫쮩 ®è¨¡ª¥
puts(t);
exit(1);
}