1 /* $XConsortium: htest.c,v 1.2 91/05/11 09:48:58 rws Exp $ */
5 Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
6 You are hereby granted permission under all Bitstream propriety rights to
7 use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
8 software and the Bitstream Charter outline font for any purpose and without
9 restrictions; provided, that this notice is left intact on all copies of such
10 software or font and that Bitstream's trademark is acknowledged as shown below
11 on all unmodified copies of such font.
13 BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
16 BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
17 WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
19 DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
20 INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
21 WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
25 /****************************** H T E S T . C ********************************
27 * SPEEDO FONT HEADER TEST MODULE *
29 ****************************************************************************/
32 #include "speedo.h" /* General definition for make_bmap */
38 #define SHOW(X) printf("X = %d\n", X)
43 #define FONT_BUFFER_SIZE 1000
45 /***** EXTERNAL FUNCTIONS *****/
47 /***** STATIC VARIABLES *****/
48 static char pathname[100]; /* Name of font file to be output */
49 static ufix8 font_buffer[FONT_BUFFER_SIZE]; /* Font buffer */
50 static FILE *fdescr; /* Speedo outline file descriptor */
54 FUNCTION main(argc,argv)
58 int bytes_read; /* Number of bytes read from font file */
59 ufix8 tmpufix8; /* Temporary workspace */
60 fix15 tmpfix15; /* Temporary workspace */
61 ufix16 tmpufix16; /* Temporary workspace */
62 ufix32 tmpufix32; /* Temporary workspace */
63 ufix8 *pvt_header_org; /* Origin of provate header data */
65 ufix8 read_1b(); /* Read 1 byte field from font header */
66 fix15 read_2b(); /* Read 2 byte field from font header */
67 fix31 read_4b(); /* Read 4 byte field from font header */
71 fprintf(stderr,"Usage: htest {fontfile}\n\n");
75 sprintf(pathname, argv[1]);
78 printf("\n SPEEDO FONT FILE HEADER DATA\n");
79 printf(" -------------------------\n\n");
80 /* Load Speedo outline file */
81 fdescr = fopen (pathname, "rb");
84 printf("****** Cannot open file %s\n", pathname);
88 bytes_read = fread(font_buffer, sizeof(ufix8), sizeof(font_buffer), fdescr);
91 printf("****** Error on reading %s: %x\n", pathname, bytes_read);
96 printf("Format Identifier ...................... %.4s\n", font_buffer + FH_FMVER);
98 tmpufix32 = (ufix32)read_4b(font_buffer + FH_FMVER + 4);
99 printf("CR-LF-NULL-NULL data ............... %8.8lx %s\n", tmpufix32, (tmpufix32 != 0x0d0a0000)? "(incorrect)": " ");
101 printf("Font Size .............................. %4ld\n", (ufix32)read_4b(font_buffer + FH_FNTSZ));
103 printf("Minimum Font Buffer Size ............... %4ld\n", (ufix32)read_4b(font_buffer + FH_FBFSZ));
105 printf("Minimum Character Buffer Size .......... %4d\n", (ufix16)read_2b(font_buffer + FH_CBFSZ));
107 printf("Header Size ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_HEDSZ));
109 printf("Font ID ................................ %4.4d\n", (ufix16)read_2b(font_buffer + FH_FNTID));
111 printf("Font Version Number .................... %4d\n", (ufix16)read_1b(font_buffer + FH_SFVNR));
113 printf("Font Full Name:\n %.70s\n", font_buffer + FH_FNTNM);
115 printf("Manufacturing Date ................ %10.10s\n", font_buffer + FH_MDATE);
117 printf("Character Set Name:\n %s\n", font_buffer + FH_LAYNM);
119 printf("Character Set ID: ...................... %.4s\n", font_buffer + FH_LAYNM + 66);
121 printf("Copyright Notice:\n %.70s\n", font_buffer + FH_CPYRT);
123 printf("Number of Char. Indexes in Char. Set ... %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRL));
125 printf("Total number of Char. Indexes in Font .. %4d\n", (ufix16)read_2b(font_buffer + FH_NCHRF));
127 printf("Index of First Character ............... %4d\n", (ufix16)read_2b(font_buffer + FH_FCHRF));
129 printf("Number of Kerning Tracks ............... %4d\n", (ufix16)read_2b(font_buffer + FH_NKTKS));
131 printf("Number of Kerning Pairs ................ %4d\n", (ufix16)read_2b(font_buffer + FH_NKPRS));
133 printf("Font Flags:\n");
134 tmpufix8 = read_1b(font_buffer + FH_FLAGS);
135 printf(" Extended font ...................... %s\n", (tmpufix8 & BIT0)? " Yes": " No");
137 printf("Classification Flags:\n");
138 tmpufix8 = read_1b(font_buffer + FH_CLFGS);
139 printf(" Italic ............................. %s\n", (tmpufix8 & BIT0)? " Yes": " No");
140 printf(" Monospace .......................... %s\n", (tmpufix8 & BIT1)? " Yes": " No");
141 printf(" Serif .............................. %s\n", (tmpufix8 & BIT2)? " Yes": " No");
142 printf(" Display ............................ %s\n", (tmpufix8 & BIT3)? " Yes": " No");
144 tmpufix8 = read_1b(font_buffer + FH_FAMCL);
145 printf("Family Classification .................. %4d ", tmpufix8);
149 printf("(Don't care)\n");
155 printf("(Sans serif)\n");
158 printf("(Monospace)\n");
161 printf("(Script or calligraphic)\n");
164 printf("(Decorative)\n");
171 printf("Font Form Classification:\n");
172 tmpufix8 = read_1b(font_buffer + FH_FRMCL);
173 printf(" Width Type ......................... %4d ", (tmpufix8 & 0x0f));
174 switch (tmpufix8 & 0x0f)
177 printf("(Condensed)\n");
180 printf("(Semi-condensed)\n");
183 printf("(Normal)\n");
186 printf("(Semi-expanded)\n");
189 printf("(Expanded)\n");
195 printf(" Weight ............................. %4d ", (tmpufix8 >> 4));
196 switch (tmpufix8 >> 4)
202 printf("(Ultralight)\n");
205 printf("(Extra light)\n");
214 printf("(Normal)\n");
217 printf("(Medium)\n");
220 printf("(Semibold)\n");
223 printf("(Demibold)\n");
229 printf("(Extrabold)\n");
232 printf("(Ultrabold)\n");
245 printf("Short Font Name ........................ %.16s\n", font_buffer + FH_SFNTN);
247 printf("Short Face Name ........................ %.16s\n", font_buffer + FH_SFACN);
249 printf("Font Form .............................. %.14s\n", font_buffer + FH_FNTFM);
251 printf("Italic Angle ........................... %7.2f\n", ((real)read_2b(font_buffer + FH_ITANG) / 256.0));
253 printf("ORUs per Em ............................ %4d\n", (ufix16)read_2b(font_buffer + FH_ORUPM));
255 printf("Width of Word Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_WDWTH));
257 printf("Width of Em Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_EMWTH));
259 printf("Width of En Space ...................... %4d\n", (ufix16)read_2b(font_buffer + FH_ENWTH));
261 printf("Width of Thin Space .................... %4d\n", (ufix16)read_2b(font_buffer + FH_TNWTH));
263 printf("Width of Figure Space .................. %4d\n", (ufix16)read_2b(font_buffer + FH_FGWTH));
265 printf("Min X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMIN));
267 printf("Min Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMIN));
269 printf("Max X coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FXMAX));
271 printf("Max Y coordinate in font ............... %4d\n", (fix15)read_2b(font_buffer + FH_FYMAX));
273 printf("Underline Position ..................... %4d\n", (fix15)read_2b(font_buffer + FH_ULPOS));
275 printf("Underline Thickness .................... %4d\n", (fix15)read_2b(font_buffer + FH_ULTHK));
277 printf("Small Caps Y position .................. %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
278 printf("Small Caps X scale ..................... %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
279 printf("Small Caps Y scale ..................... %7.2f\n", ((real)(fix15)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));
281 printf("Display Superiors Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_SMCTR));
282 printf("Display Superiors X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 2) / 4096.0));
283 printf("Display Superiors Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_SMCTR + 4) / 4096.0));
285 printf("Footnote Superiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_FNSTR));
286 printf("Footnote Superiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 2) / 4096.0));
287 printf("Footnote Superiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_FNSTR + 4) / 4096.0));
289 printf("Alpha Superiors Y position ............. %4d\n", (fix15)read_2b(font_buffer + FH_ALSTR));
290 printf("Alpha Superiors X scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 2) / 4096.0));
291 printf("Alpha Superiors Y scale ................ %7.2f\n", ((real)read_2b(font_buffer + FH_ALSTR + 4) / 4096.0));
293 printf("Chemical Inferiors Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_CMITR));
294 printf("Chemical Inferiors X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 2) / 4096.0));
295 printf("Chemical Inferiors Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_CMITR + 4) / 4096.0));
297 printf("Small Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_SNMTR));
298 printf("Small Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 2) / 4096.0));
299 printf("Small Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_SNMTR + 4) / 4096.0));
301 printf("Small Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_SDNTR));
302 printf("Small Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 2) / 4096.0));
303 printf("Small Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_SDNTR + 4) / 4096.0));
305 printf("Medium Numerators Y position ........... %4d\n", (fix15)read_2b(font_buffer + FH_MNMTR));
306 printf("Medium Numerators X scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 2) / 4096.0));
307 printf("Medium Numerators Y scale .............. %7.2f\n", ((real)read_2b(font_buffer + FH_MNMTR + 4) / 4096.0));
309 printf("Medium Denominators Y position ......... %4d\n", (fix15)read_2b(font_buffer + FH_MDNTR));
310 printf("Medium Denominators X scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 2) / 4096.0));
311 printf("Medium Denominators Y scale ............ %7.2f\n", ((real)read_2b(font_buffer + FH_MDNTR + 4) / 4096.0));
313 printf("Large Numerators Y position ............ %4d\n", (fix15)read_2b(font_buffer + FH_LNMTR));
314 printf("Large Numerators X scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 2) / 4096.0));
315 printf("Large Numerators Y scale ............... %7.2f\n", ((real)read_2b(font_buffer + FH_LNMTR + 4) / 4096.0));
317 printf("Large Denominators Y position .......... %4d\n", (fix15)read_2b(font_buffer + FH_LDNTR));
318 printf("Large Denominators X scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 2) / 4096.0));
319 printf("Large Denominators Y scale ............. %7.2f\n", ((real)read_2b(font_buffer + FH_LDNTR + 4) / 4096.0));
325 FUNCTION ufix8 read_1b(pointer)
328 * Reads 1-byte field from font buffer
334 FUNCTION fix15 read_2b(pointer)
337 * Reads 2-byte field from font buffer
343 temp = (temp << 8) + *(pointer);
347 FUNCTION fix31 read_4b(pointer)
350 * Reads 4-byte field from font buffer
356 temp = (temp << 8) + *(pointer++);
357 temp = (temp << 8) + *(pointer++);
358 temp = (temp << 8) + *(pointer);