1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include "util.h"
5 #include "findtfm.h"
6 #include "fontinfo.h"
7 #include "bytesex.h"
8 #include "fixword.h"
9 
10 #define FONT_INDEX 0
11     /* we use only this one font slot */
12 
13 char * generic_parms[] = {
14     "slant",
15     "space",
16     "space_stretch",
17     "space_shrink",
18     "x_height",
19     "quad",
20     "extra_space"
21 };
22 
23 char * OMS_parms[] = {
24     "num1",
25     "num2",
26     "num3",
27     "denom1",
28     "denom2",
29     "sup1",
30     "sup2",
31     "sup3",
32     "sub1",
33     "sub2",
34     "supdrop",
35     "subdrop",
36     "delim1",
37     "delim2",
38     "axis_height"
39 };
40 
41 char * OMX_parms[] ={
42     "default_rule_thickness",
43     "big_op_spacing1",
44     "big_op_spacing2",
45     "big_op_spacing3",
46     "big_op_spacing4",
47     "big_op_spacing5"
48 };
49 
desc_copy(char ** to,char ** from,size_t base,size_t count,size_t np)50 static size_t desc_copy(
51     char ** to,
52     char ** from,
53     size_t base,
54     size_t count,
55     size_t np
56 )
57 {
58     if(base > np) return (np + 1);
59     count = min(count, np + 1 - base);
60     memcpy(to + base, from, sizeof(char *) * count);
61     return (base + count);
62 }
63 
main(int argc,char * argv[])64 int main(int argc, char * argv[])
65 {
66     int np, enp, i;
67     size_t b;
68     char ** description;
69 
70     if(argc != 2) {
71     	fputs("Usage error!\n", stderr);
72 	exit(1);
73     }
74 
75     setup_findtfm(argv[0]);
76 
77     font_def(
78     	FONT_INDEX,
79 	0,  	    	    /* checksum - we don't know that */
80 	double2fw(1.0),     /* scaling */
81 	double2fw(10.0),    /* design size */
82 	0,  	    	    /* length of the fontnames directory part */
83 	strlen(argv[1]),    /* length of the fontnames non-directory part */
84 	argv[1]     	    /* fontname (e.g. cmr10) */
85     );
86     np = font_nparams(FONT_INDEX);
87 
88     description = malloc((np + 1) * sizeof(char *));
89     for(i = 0; i <= np; ++i) description[i] = "unknown";
90 
91     b = 1;
92     enp = lengthof(generic_parms);
93     b = desc_copy(description, generic_parms, b, lengthof(generic_parms), np);
94 
95     if(strcmp(font_enc(FONT_INDEX), "TeX math symbols") == 0) {
96     	enp += lengthof(OMS_parms);
97     	b = desc_copy(
98 	    description,
99 	    OMS_parms,
100 	    b,
101 	    lengthof(OMS_parms),
102 	    np
103 	);
104     }
105     else if(strcmp(font_enc(FONT_INDEX), "TeX math extension") == 0) {
106     	enp += lengthof(OMX_parms);
107     	b = desc_copy(
108 	    description,
109 	    OMX_parms,
110 	    b,
111 	    lengthof(OMX_parms),
112 	    np
113 	);
114     }
115 
116     printf("Encoding: %s\n", font_enc(FONT_INDEX));
117     printf("Family: %s\n", font_family(FONT_INDEX));
118 
119     printf("Nparams: %d [expected: %d]\n", np, enp);
120     for(i = 1; i <= np; ++i) {
121     	printf(
122 	    "Param%02d: %4.7g [%s]\n",
123 	    i,
124 	    fw2double(font_param(FONT_INDEX, i)),
125 	    description[i]
126 	);
127     }
128     exit(0);
129 }
130 
131 
132