aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/font/Speedo/htest.c
blob: 235b765601ef494b03125a0e3ba66f6ab7323f10 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/* $Xorg: htest.c,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */

/*

Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
You are hereby granted permission under all Bitstream propriety rights to
use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
software and the Bitstream Charter outline font for any purpose and without
restrictions; provided, that this notice is left intact on all copies of such
software or font and that Bitstream's trademark is acknowledged as shown below
on all unmodified copies of such font.

BITSTREAM CHARTER is a registered trademark of Bitstream Inc.


BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.

*/

/****************************** H T E S T . C ********************************
 *                                                                           *
 *              SPEEDO FONT HEADER TEST MODULE                               *
 *                                                                           *
 ****************************************************************************/


#include "speedo.h"                 /* General definition for make_bmap */
#include <stdio.h>

#define DEBUG  0

#if DEBUG
#define SHOW(X) printf("X = %d\n", X)
#else
#define SHOW(X)
#endif

#define FONT_BUFFER_SIZE  1000

/***** EXTERNAL FUNCTIONS *****/

/***** STATIC VARIABLES *****/
static  char   pathname[100]; /* Name of font file to be output */
static  ufix8  font_buffer[FONT_BUFFER_SIZE]; /* Font buffer */
static  FILE  *fdescr;             /* Speedo outline file descriptor */



FUNCTION main(argc,argv)
int argc;
char *argv[];
{
int     bytes_read;           /* Number of bytes read from font file */
ufix8   tmpufix8;             /* Temporary workspace */
fix15   tmpfix15;             /* Temporary workspace */
ufix16  tmpufix16;            /* Temporary workspace */
ufix32  tmpufix32;            /* Temporary workspace */
ufix8  *pvt_header_org;       /* Origin of provate header data */

ufix8   read_1b();            /* Read 1 byte field from font header */
fix15   read_2b();            /* Read 2 byte field from font header */
fix31   read_4b();            /* Read 4 byte field from font header */

if (argc != 2) 
    {
    fprintf(stderr,"Usage: htest {fontfile}\n\n"); 
    exit (1);
    }

sprintf(pathname, argv[1]);

/* Initialization */
printf("\n      SPEEDO FONT FILE HEADER DATA\n");
printf("      -------------------------\n\n");
/* Load Speedo outline file */
fdescr = fopen (pathname, "rb");
if (fdescr == NULL)
    {
    printf("****** Cannot open file %s\n", pathname);
    return;                  
    }

bytes_read = fread(font_buffer, sizeof(ufix8), sizeof(font_buffer), fdescr);
if (bytes_read == 0)
    {
    printf("****** Error on reading %s: %x\n", pathname, bytes_read);
    fclose(fdescr);     
    return;
    }

printf("Format Identifier ...................... %.4s\n", font_buffer + FH_FMVER);

tmpufix32 = (ufix32)read_4b(font_buffer + FH_FMVER + 4);
printf("CR-LF-NULL-NULL data ............... %8.8lx %s\n", tmpufix32, (tmpufix32 != 0x0d0a0000)? "(incorrect)": " ");

printf("Font Size .............................. %4ld\n", (ufix32)read_4b(font_buffer + FH_FNTSZ));

printf("Minimum Font Buffer Size ............... %4ld\n", (ufix32)read_4b(font_buffer + FH_FBFSZ));

printf("Minimum Character Buffer Size .......... %4d\n", (ufix16)read_2b(font_buffer + FH_CBFSZ));

printf("Header Size ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_HEDSZ));

printf("Font ID ................................ %4.4d\n", (ufix16)read_2b(font_buffer + FH_FNTID));

printf("Font Version Number .................... %4d\n", (ufix16)read_1b(font_buffer + FH_SFVNR));

printf("Font Full Name:\n    %.70s\n", font_buffer + FH_FNTNM);

printf("Manufacturing Date ................ %10.10s\n", font_buffer + FH_MDATE);

printf("Character Set Name:\n    %s\n", font_buffer + FH_LAYNM);

printf("Character Set ID: ...................... %.4s\n", font_buffer + FH_LAYNM + 66);

printf("Copyright Notice:\n    %.70s\n", font_buffer + FH_CPYRT);

printf("Number of Char. Indexes in Char. Set ... %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRL));

printf("Total number of Char. Indexes in Font .. %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRF));

printf("Index of First Character ............... %4d\n", (ufix16)read_2b(font_buffer + FH_FCHRF));

printf("Number of Kerning Tracks ............... %4d\n", (ufix16)read_2b(font_buffer + FH_NKTKS));

printf("Number of Kerning Pairs ................ %4d\n", (ufix16)read_2b(font_buffer + FH_NKPRS));

printf("Font Flags:\n");
tmpufix8 = read_1b(font_buffer + FH_FLAGS);
printf("    Extended font ...................... %s\n", (tmpufix8 & BIT0)? " Yes": "  No");

printf("Classification Flags:\n");
tmpufix8 = read_1b(font_buffer + FH_CLFGS);
printf("    Italic ............................. %s\n", (tmpufix8 & BIT0)? " Yes": "  No");
printf("    Monospace .......................... %s\n", (tmpufix8 & BIT1)? " Yes": "  No");
printf("    Serif .............................. %s\n", (tmpufix8 & BIT2)? " Yes": "  No");
printf("    Display ............................ %s\n", (tmpufix8 & BIT3)? " Yes": "  No");

tmpufix8 = read_1b(font_buffer + FH_FAMCL);
printf("Family Classification .................. %4d ", tmpufix8);
switch (tmpufix8)
    {
case 0:
    printf("(Don't care)\n");
    break;
case 1:
    printf("(Serif)\n");
    break;
case 2:
    printf("(Sans serif)\n");
    break;
case 3:
    printf("(Monospace)\n");
    break;
case 4:
    printf("(Script or calligraphic)\n");
    break;
case 5:
    printf("(Decorative)\n");
    break;
default:
    printf("\n");
    break;
    }

printf("Font Form Classification:\n");
tmpufix8 = read_1b(font_buffer + FH_FRMCL);
printf("    Width Type ......................... %4d ", (tmpufix8 & 0x0f));
switch (tmpufix8 & 0x0f)
    {
case 4:
    printf("(Condensed)\n");
    break;
case 6:
    printf("(Semi-condensed)\n");
    break;
case 8:
    printf("(Normal)\n");
    break;
case 10:
    printf("(Semi-expanded)\n");
    break;
case 12:
    printf("(Expanded)\n");
    break;
default:
    printf("\n");
    break;
    }
printf("    Weight ............................. %4d ", (tmpufix8 >> 4));
switch (tmpufix8 >> 4)
    {
case 1:
    printf("(Thin)\n");
    break;
case 2:
    printf("(Ultralight)\n");
    break;
case 3:
    printf("(Extra light)\n");
    break;
case 4:
    printf("(Light)\n");
    break;
case 5:
    printf("(Book)\n");
    break;
case 6:
    printf("(Normal)\n");
    break;
case 7:
    printf("(Medium)\n");
    break;
case 8:
    printf("(Semibold)\n");
    break;
case 9:
    printf("(Demibold)\n");
    break;
case 10:
    printf("(Bold)\n");
    break;
case 11:
    printf("(Extrabold)\n");
    break;
case 12:
    printf("(Ultrabold)\n");
    break;
case 13:
    printf("(Heavy)\n");
    break;
case 14:
    printf("(Black)\n");
    break;
default:
    printf("\n");
    break;
    }

printf("Short Font Name ........................ %.16s\n", font_buffer + FH_SFNTN);

printf("Short Face Name ........................ %.16s\n", font_buffer + FH_SFACN);

printf("Font Form .............................. %.14s\n", font_buffer + FH_FNTFM);

printf("Italic Angle ........................... %7.2f\n", ((real)read_2b(font_buffer + FH_ITANG) / 256.0));

printf("ORUs per Em ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_ORUPM));

printf("Width of Word Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_WDWTH));

printf("Width of Em Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_EMWTH));

printf("Width of En Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_ENWTH));

printf("Width of Thin Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_TNWTH));

printf("Width of Figure Space .................. %4d\n", (ufix16)read_2b(font_buffer + FH_FGWTH));

printf("Min X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMIN));

printf("Min Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMIN));

printf("Max X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMAX));

printf("Max Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMAX));

printf("Underline Position ..................... %4d\n", (fix15)read_2b(font_buffer + FH_ULPOS));

printf("Underline Thickness .................... %4d\n", (fix15)read_2b(font_buffer + FH_ULTHK));

printf("Small Caps Y position .................. %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
printf("Small Caps X scale ..................... %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
printf("Small Caps Y scale ..................... %7.2f\n", ((real)(fix15)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));

printf("Display Superiors Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
printf("Display Superiors X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
printf("Display Superiors Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));

printf("Footnote Superiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_FNSTR));
printf("Footnote Superiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 2) / 4096.0));
printf("Footnote Superiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 4) / 4096.0));

printf("Alpha Superiors Y position ............. %4d\n", (fix15)read_2b(font_buffer + FH_ALSTR));
printf("Alpha Superiors X scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 2) / 4096.0));
printf("Alpha Superiors Y scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 4) / 4096.0));

printf("Chemical Inferiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_CMITR));
printf("Chemical Inferiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 2) / 4096.0));
printf("Chemical Inferiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 4) / 4096.0));

printf("Small Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_SNMTR));
printf("Small Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 2) / 4096.0));
printf("Small Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 4) / 4096.0));

printf("Small Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_SDNTR));
printf("Small Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 2) / 4096.0));
printf("Small Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 4) / 4096.0));

printf("Medium Numerators Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_MNMTR));
printf("Medium Numerators X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 2) / 4096.0));
printf("Medium Numerators Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 4) / 4096.0));

printf("Medium Denominators Y position ......... %4d\n", (fix15)read_2b(font_buffer + FH_MDNTR));
printf("Medium Denominators X scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 2) / 4096.0));
printf("Medium Denominators Y scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 4) / 4096.0));

printf("Large Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_LNMTR));
printf("Large Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 2) / 4096.0));
printf("Large Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 4) / 4096.0));

printf("Large Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_LDNTR));
printf("Large Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 2) / 4096.0));
printf("Large Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 4) / 4096.0));

fclose(fdescr);     
}


FUNCTION ufix8 read_1b(pointer)
ufix8 *pointer;
/*
 * Reads 1-byte field from font buffer 
 */
{
return *pointer;
}

FUNCTION fix15 read_2b(pointer)
ufix8 *pointer;
/*
 * Reads 2-byte field from font buffer 
 */
{
fix31 temp;

temp = *pointer++;
temp = (temp << 8) + *(pointer);
return temp;
}

FUNCTION fix31 read_4b(pointer)
ufix8 *pointer;
/*
 * Reads 4-byte field from font buffer 
 */
{
fix31 temp;

temp = *pointer++;
temp = (temp << 8) + *(pointer++);
temp = (temp << 8) + *(pointer++);
temp = (temp << 8) + *(pointer);
return temp;
}