5
* mag \- computes fontsizes and magsteps
21
* [-\fBR\fIdpi\fP\fP] magstep . . .
25
* [-\fBr\fP] [-\fBR\fP\fIdpi\fP] fontsize . . .
31
* This tool calculates fontsizes given magsteps. TeXfonts are provided as
32
* true sized fonts or as magnifications. The fontsize of a true sized
33
* font equals the resolution of the printer (ex. 300). The fontsize
34
* of a font magnified $n$ \fImagsteps\fP equals:
36
* 1.2 sup{n} times 300
39
* rounded to its nearest integer value. Fontnames for TeX fonts normally
40
* consists of the name (\fIcmr\fP), pointsize (\fI10\fP), type (\fIpk\fP)
41
* and fontsize (\fI360\fP), for example: \fIcmr10.360pk\fP.
44
* The result of \fImag -R240 -2 0 0.5 1\fP will be:
49
* The inverse function is computed with the \fI-r\fP option. The result of
50
* \fImag -r -R240 167 240 263 288\fP
51
* will be the fontsteps:
56
* The UNIX shells allow command substitution. One can write:
58
* mag -r -R240 `mag -R240 -2 0 0.5 1`
67
* University of Technology Eindhoven
71
#include "basics.h" /* fatal() */
87
static int fontsize(double);
88
static double stepsize(double);
90
int main(int argc, char *argv[]) {
95
while (--argc > 0 && (*++argv)[0] == '-') {
96
if (isdigit((int)(*argv)[1])) { /* allow negative numbers as arguments */
100
while ((!done) && (c = *++argv[0])) /* allow -bcK like options */
105
if (*++argv[0] == '\0') {
112
fatal("%s: %c illegal option\n", myname, c);
117
fatal("Usage: %s [-r] [-Rdpi] size . . .\n", myname);
120
setmode(fileno(stdout), _O_BINARY);
123
for ( ; argc; argc--, argv++) {
127
printf("%d%c", fontsize(arg), argc > 1 ? ' ' : '\n');
131
if (((int)(10*sz))%10==0)
132
printf("%d%c", (int)sz, argc > 1 ? ' ' : '\n');
134
printf("%f%c", sz, argc > 1 ? ' ' : '\n');
143
return(DPI*pow(1.2, x) + 0.5);
150
s=(log(x)-log(DPI))/log(1.2);
151
if (s>=0) return floor(10*s+0.5)/10;
152
return -floor(10*(-s)+0.5)/10;