Back to index

tetex-bin  3.0
Functions | Variables
makefont.c File Reference
#include "dvips.h"
#include <math.h>
#include "protos.h"

Go to the source code of this file.

Functions

char * getenv ()
int system ()
static int magstep P2C (register int, n, register int, bdpi)
void makefont P3C (char *, name, int, dpi, int, bdpi)

Variables

int quiet
int filter
int dontmakefont
Boolean secure
char * mfmode
static char * defcommand = "MakeTeXPK %n %d %b %m"
char * command = 0
static char buf [125]

Function Documentation

char* getenv ( )
static int magstep P2C ( register  int,
n  ,
register  int,
bdpi   
) [static]

Definition at line 87 of file makefont.c.

{
   register float t ;
   int neg = 0 ;

   if (n < 0) {
      neg = 1 ;
      n = -n ;
   }
   if (n & 1) {
      n &= ~1 ;
      t = 1.095445115 ;
   } else
      t = 1.0 ;
   while (n > 8) {
      n -= 8 ;
      t = t * 2.0736 ;
   }
   while (n > 0) {
      n -= 2 ;
      t = t * 1.2 ;
   }
   if (neg)
      return((int)floor(0.5 + bdpi / t)) ;
   else
      return((int)floor(0.5 + bdpi * t)) ;
}

Here is the call graph for this function:

void makefont P3C ( char *  ,
name  ,
int  ,
dpi  ,
int  ,
bdpi   
)

Definition at line 144 of file makefont.c.

{
   register char *p, *q ;
   register int m, n ;
   int modegiven = 0 ;
#if defined MSDOS || defined OS2 || defined(ATARIST)
   double t;
#endif

   if (command == 0)
      if (secure == 0 && (command=getenv("MAKETEXPK")))
         command = newstring(command) ;
      else 
         command = defcommand ;
   for (p=command, q=buf; *p; p++)
      if (*p != '%')
         *q++ = *p ;
      else {
         switch (*++p) {
case 'n' : case 'N' :
            (void)strcpy(q, name) ;
            break ;
case 'd' : case 'D' :
            (void)sprintf(q, "%d", dpi) ;
            break ;
case 'b' : case 'B' :
            (void)sprintf(q, "%d", bdpi) ;
            break ;
case 'o' : case 'O' :
            (void)sprintf(q, "%s", mfmode ? mfmode : "default") ;
            modegiven = 1 ;
            break ;
case 'm' : case 'M' :
/*
 *   Here we want to return a string.  If we can find some integer
 *   m such that floor(0.5 + bdpi * 1.2 ^ (m/2)) = dpi, we write out
 *      magstep(m/2)
 *   where m/2 is a decimal number; else we write out
 *      dpi/bdpi
 *   We do this for the very slight improvement in accuracy that
 *   magstep() gives us over the rounded dpi/bdpi.
 */
            m = 0 ;
            if (dpi < bdpi) {
               while (1) {
                  m-- ;
                  n = magstep(m, bdpi) ;
                  if (n == dpi)
                     break ;
                  if (n < dpi || m < -40) {
                     m = 9999 ;
                     break ;
                  }
               }
            } else if (dpi > bdpi) {
               while (1) {
                  m++ ;
                  n = magstep(m, bdpi) ;
                  if (n == dpi)
                     break ;
                  if (n > dpi || m > 40) {
                     m = 9999 ;
                     break ;
                  }
               }
            }
#if defined MSDOS || defined OS2
/* write out magnification as decimal number */
            if (m == 9999) {
               t = (double)dpi/bdpi;
            } else {
               if (m < 0)
                    n = -m;
               else
                    n = m;
               if (n & 1) {
                    n &= ~1 ;
                    t = 1.095445115 ;
               } else
                    t = 1.0 ;
               while (n > 0) {
                    n -= 2 ;
                    t = t * 1.2 ;
               }
               if (m < 0)
                    t = 1 / t ;
            }
            (void)sprintf(q, "%12.9f", t) ;
#else
#ifndef ATARIST
            if (m == 9999) {
#else
            {
#endif
               (void)sprintf(q, "%d+%d/%d", dpi/bdpi, dpi%bdpi, bdpi) ;
            } else if (m >= 0) {
               (void)sprintf(q, "magstep\\(%d.%d\\)", m/2, (m&1)*5) ;
            } else {
               (void)sprintf(q, "magstep\\(-%d.%d\\)", (-m)/2, (m&1)*5) ;
            }
#endif
            break ;
case 0 :    *q = 0 ;
            break ;
default:    *q++ = *p ;
            *q = 0 ;
            break ;
         }
         q += strlen(q) ;
      }
   *q = 0 ;
   if (mfmode && !modegiven) {
      strcpy(q, " ") ;
      strcat(q, mfmode) ;
   }
#ifdef OS2
   if ((_osmode == OS2_MODE) && filter)
      (void)strcat(buf, quiet ? " >nul" : " 1>&2") ;
#else
#ifndef VMCMS   /* no filters and no need to print to stderr */
#ifndef MVSXA
#ifndef MSDOS
#ifndef ATARIST
   if (filter)
      (void)strcat(buf, quiet ? " >/dev/null" : " 1>&2") ;
#endif
#endif
#endif
#endif
#endif

#if defined MSDOS || defined OS2
   if (! quiet && mfjobname == (char *)NULL)
      (void)fprintf(stderr, "- %s\n", buf) ;
   if (dontmakefont == 0) {
      if (mfjobname != (char *)NULL)
         mfjobout(name,t);
      else
         (void)system(buf) ;
   }
#else
   if (! quiet)
      (void)fprintf(stderr, "- %s\n", buf) ;
   if (dontmakefont == 0)
      (void)system(buf) ;
#endif
   else {
      static FILE *fontlog = 0 ;

      if (fontlog == 0) {
         fontlog = fopen("missfont.log", "a") ;
         if (fontlog != 0) {
            (void)fprintf(stderr,
#ifndef VMCMS
                  "Appending font creation commands to missfont.log\n") ;
#else
  "\nMissing font data will be passed to DVIPS EXEC via MISSFONT LOG\n");
#endif
         }
      }
      if (fontlog != 0) {
         (void)fprintf(fontlog, "%s\n", buf) ;
         (void)fflush(fontlog) ;
      }
   }
}

Here is the call graph for this function:

int system ( )

Variable Documentation

char buf[125] [static]

Definition at line 142 of file makefont.c.

char* command = 0

Definition at line 137 of file makefont.c.

char* defcommand = "MakeTeXPK %n %d %b %m" [static]

Definition at line 131 of file makefont.c.

Definition at line 114 of file loadfont.c.

Definition at line 159 of file dvips.c.

char* mfmode

Definition at line 175 of file dvips.c.

Definition at line 158 of file dvips.c.

Definition at line 67 of file dvips.c.