Back to index

tetex-bin  3.0
Functions | Variables
mag.c File Reference
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "basics.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
int fontsize (double x)
double stepsize (double x)

Variables

int invert = 0
float DPI = 300.0

Function Documentation

int fontsize ( double  x)

Definition at line 133 of file mag.c.

{
   return(DPI*pow(1.2, x) + 0.5);
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 83 of file mag.c.

                                 {
   float  sz, arg; int c;
   char *myname = "mag";
   short done;

   /* prototypes */
   int fontsize(double);
   double stepsize(double);

   while (--argc > 0 && (*++argv)[0] == '-') {
      if (isdigit((int)(*argv)[1])) { /* allow negative numbers as arguments */
         break;
      }
      done=0;
      while ((!done) && (c = *++argv[0]))  /* allow -bcK like options */
        switch (c) {
        case 'r':
           invert = 1; break;
        case 'R':
           if (*++argv[0] == '\0') {
              argc--; argv++;
           }
           DPI = atof(argv[0]);
           done = 1;
           break;
        default:
           fatal("%s: %c illegal option\n", myname, c);
        }
      }

   if (argc < 1)
      fatal("Usage: %s [-r] [-Rdpi] size . . .\n", myname);
   
   for ( ; argc; argc--, argv++) {
      arg=atof(argv[0]);
      switch (invert) {
      case 0:
         printf("%d%c", fontsize(arg), argc > 1 ? ' ' : '\n');
         break;
      case 1:
         sz=stepsize(arg);
         if (((int)(10*sz))%10==0)
            printf("%d%c", (int)sz, argc > 1 ? ' ' : '\n');
         else 
            printf("%f%c", sz, argc > 1 ? ' ' : '\n');
      }
   }
   return 0;
}

Here is the call graph for this function:

double stepsize ( double  x)

Definition at line 138 of file mag.c.

{  double s;
   s=(log(x)-log(DPI))/log(1.2);
   if (s>=0) return floor(10*s+0.5)/10;
   return -floor(10*(-s)+0.5)/10;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

float DPI = 300.0

Definition at line 81 of file mag.c.

int invert = 0

Definition at line 80 of file mag.c.