summaryrefslogtreecommitdiff
path: root/dviware/catdvi/tfminfo.c
blob: 435307f20fe763306378c06ae60edefdd1447908 (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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "util.h"
#include "findtfm.h"
#include "fontinfo.h"
#include "bytesex.h"
#include "fixword.h"

#define FONT_INDEX 0
    /* we use only this one font slot */

char * generic_parms[] = {
    "slant",
    "space",
    "space_stretch",
    "space_shrink",
    "x_height",
    "quad",
    "extra_space"
};

char * OMS_parms[] = {
    "num1",
    "num2",
    "num3",
    "denom1",
    "denom2",
    "sup1",
    "sup2",
    "sup3",
    "sub1",
    "sub2",
    "supdrop",
    "subdrop",
    "delim1",
    "delim2",
    "axis_height"
};

char * OMX_parms[] ={
    "default_rule_thickness",
    "big_op_spacing1",
    "big_op_spacing2",
    "big_op_spacing3",
    "big_op_spacing4",
    "big_op_spacing5"
};

static size_t desc_copy(
    char ** to,
    char ** from,
    size_t base,
    size_t count,
    size_t np
)
{
    if(base > np) return (np + 1);
    count = min(count, np + 1 - base);
    memcpy(to + base, from, sizeof(char *) * count);
    return (base + count);
}

int main(int argc, char * argv[])
{
    int np, enp, i;
    size_t b;
    char ** description;

    if(argc != 2) {
    	fputs("Usage error!\n", stderr);
	exit(1);
    }
    
    setup_findtfm(argv[0]);

    font_def(
    	FONT_INDEX,
	0,  	    	    /* checksum - we don't know that */
	double2fw(1.0),     /* scaling */
	double2fw(10.0),    /* design size */
	0,  	    	    /* length of the fontnames directory part */
	strlen(argv[1]),    /* length of the fontnames non-directory part */
	argv[1]     	    /* fontname (e.g. cmr10) */
    );
    np = font_nparams(FONT_INDEX);

    description = malloc((np + 1) * sizeof(char *));
    for(i = 0; i <= np; ++i) description[i] = "unknown";
    
    b = 1;
    enp = lengthof(generic_parms);
    b = desc_copy(description, generic_parms, b, lengthof(generic_parms), np);
    
    if(strcmp(font_enc(FONT_INDEX), "TeX math symbols") == 0) {
    	enp += lengthof(OMS_parms);
    	b = desc_copy(
	    description,
	    OMS_parms,
	    b,
	    lengthof(OMS_parms),
	    np
	);
    }
    else if(strcmp(font_enc(FONT_INDEX), "TeX math extension") == 0) {
    	enp += lengthof(OMX_parms);
    	b = desc_copy(
	    description,
	    OMX_parms,
	    b,
	    lengthof(OMX_parms),
	    np
	);
    }
    
    printf("Encoding: %s\n", font_enc(FONT_INDEX));
    printf("Family: %s\n", font_family(FONT_INDEX));

    printf("Nparams: %d [expected: %d]\n", np, enp);
    for(i = 1; i <= np; ++i) {
    	printf(
	    "Param%02d: %4.7g [%s]\n",
	    i,
	    fw2double(font_param(FONT_INDEX, i)),
	    description[i]
	);
    }
    exit(0);
}