23 #define MAX_FONTLEN 256
27 static void usage(
char *argv0)
30 " %s chartable [hashsize] [hashstep] [maxhashlevel]\n", argv0);
34 static int getunicode(
char **
p0)
38 while (*p ==
' ' || *p ==
'\t')
40 if (*p !=
'U' || p[1] !=
'+' ||
45 return strtol(p+2,0,16);
52 static void addpair(
int fp,
int un)
60 for ( i = 0 ; i < unicount[
fp] ; i++ )
61 if ( unitable[fp][i] == un )
66 if ( unicount[fp] > 254 )
68 fprintf(stderr,
"ERROR: Only 255 unicodes/glyph permitted!\n");
72 unitable[
fp][unicount[
fp]] = un;
86 int fp0, fp1, un0, un1;
89 if ( argc < 2 || argc > 5 )
92 if ( !
strcmp(argv[1],
"-") )
99 ctbl = fopen(tblname = argv[1],
"r");
112 for ( i = 0 ; i < fontlen ; i++ )
117 while ( fgets(buffer,
sizeof(buffer), ctbl) !=
NULL )
122 fprintf(stderr,
"%s: Warning: line too long\n", tblname);
137 while (*p ==
' ' || *p ==
'\t')
139 if (!*p || *p ==
'#')
142 fp0 = strtol(p, &p1, 0);
145 fprintf(stderr,
"Bad input line: %s\n", buffer);
150 while (*p ==
' ' || *p ==
'\t')
155 fp1 = strtol(p, &p1, 0);
158 fprintf(stderr,
"Bad input line: %s\n", buffer);
166 if ( fp0 < 0 || fp0 >= fontlen )
169 "%s: Glyph number (0x%x) larger than font length\n",
173 if ( fp1 && (fp1 < fp0 || fp1 >= fontlen) )
176 "%s: Bad end of range (0x%x)\n",
185 while (*p ==
' ' || *p ==
'\t')
189 for (i=fp0; i<=fp1; i++)
195 un0 = getunicode(&p);
196 while (*p ==
' ' || *p ==
'\t')
201 "%s: Corresponding to a range of font positions, there should be a Unicode range\n",
206 un1 = getunicode(&p);
207 if (un0 < 0 || un1 < 0)
210 "%s: Bad Unicode range corresponding to font position range 0x%x-0x%x\n",
214 if (un1 - un0 != fp1 - fp0)
217 "%s: Unicode range U+%x-U+%x not of the same length as font position range 0x%x-0x%x\n",
218 tblname, un0, un1, fp0, fp1);
221 for(i=fp0; i<=fp1; i++)
222 addpair(i,un0-fp0+i);
229 while ( (un0 = getunicode(&p)) >= 0 )
232 while (*p ==
' ' || *p ==
'\t')
235 fprintf(stderr,
"%s: trailing junk (%s) ignored\n", tblname, p);
245 for ( i = 0 ; i < fontlen ; i++ )
250 * Do not edit this file; it was automatically generated by\n\
252 * conmakehash %s > [this file]\n\
256 #include <linux/types.h>\n\
258 u8 dfont_unicount[%d] = \n\
259 {\n\t", argv[1], fontlen);
261 for ( i = 0 ; i < fontlen ; i++ )
263 printf(
"%3d", unicount[i]);
264 if ( i == fontlen-1 )
266 else if ( i % 8 == 7 )
272 printf(
"\nu16 dfont_unitable[%d] = \n{\n\t", nuni);
276 for ( i = 0 ; i < nuni ; i++ )
278 while ( nent >= unicount[fp0] )
283 printf(
"0x%04x", unitable[fp0][nent++]);
286 else if ( i % 8 == 7 )