home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / CreativeComputers.iso / shareware / text / dvi_3.62 / source / dvisrc.lha / dviarexx.c < prev    next >
C/C++ Source or Header  |  1994-02-01  |  3KB  |  88 lines

  1. /*
  2. ** Datei: DVIAREXX.C
  3. ** Autor: Markus Zahn
  4. */
  5.  
  6. #include <math.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10.  
  11. #include <proto/dos.h>
  12. #include <dos/dostags.h>
  13.  
  14. #include "dvi.h"
  15. #include "dviarexx.h"
  16.  
  17. /* Verwendete Funktionen aus "dvirdpk.c" */
  18. extern void fnt_pkname( char *name, char *schab, char *fn, int isize, int rsize    );
  19. extern FILE *fnt_pklocate(fnt_t *f);
  20. extern BPTR out_handle;
  21.  
  22. FILE *fnt_arexxlocate( fnt_t *f )
  23. {
  24.   /*
  25.    * Die Optionsvariable CALLMF kann mit einem ARexx-Script
  26.    * belegt werden, das die Fonterzeugung oder die Erstellung
  27.    * eines dazu geeigneten Batchfiles uebernimmt.
  28.    * ( analog zur PasTeX-Implementation :-)
  29.    */
  30.   FILE *pk = NULL;
  31.   double size = (double)f->s*dvi_info.mag / 1e3 / (double)f->d;
  32.   int dbl_magstep; /* magstep * 2 um auch halbe magsteps zu erfassen */
  33.   int isize = iround( size * 1000.0 );
  34.   int rsize = iround( size * (double)op.hres );
  35.   char command[256] = "SYS:Rexxc/rx "; /* fuer das aufzurufende ARexx-Script */
  36.   char pkname[MAX_PATH_LEN];
  37.   long error;
  38.  
  39.   if( *op.pk_callmf != '\0' )
  40.   {
  41.     dbl_magstep = iround( 2.0 * log( size ) / log( 1.2 ) );
  42.     if( fabs( exp( (double)dbl_magstep / 2.0 * log( 1.2 ) ) - size ) > 5e-4    )
  43.       dbl_magstep = -1;
  44.     else
  45.     {
  46.       size = exp( (double)dbl_magstep / 2.0 * log( 1.2 ) );
  47.       isize = iround( size * 1000.0 );
  48.       rsize = iround( size * (double)op.hres );
  49.     }
  50.     fnt_pkname( pkname, op.pk_path, f->n, isize, rsize );
  51.     strcat( command, op.pk_callmf );
  52.     /* 
  53.      * Jetzt noch das MakePKFont.rexx Anhaengsel:
  54.      * Fontname, magstep / magnification, dpi und pkfullname
  55.      */
  56.     if( dbl_magstep != -1 )
  57.     {
  58.       sprintf( command + strlen( command ),
  59.       " font=%s magstep=%.1lf dpi=%d hres=%d vres=%d pkfull=%s",
  60.       f->n, (double)dbl_magstep / 2.0, rsize, op.hres, op.vres, pkname );
  61.     }
  62.     else
  63.     {
  64.       sprintf( command + strlen( command ),
  65.       " font=%s mag=%.10lf dpi=%d hres=%d vres=%d pkfull=%s",
  66.       f->n, size, rsize, op.hres, op.vres, pkname );
  67.     }
  68.     print( "Creating new font %s...", pkname );
  69.  
  70.     if( DOSBase && ( DOSBase->dl_lib.lib_Version > 36 ) )
  71.     {
  72.       if( BADDR( out_handle ) != NULL )
  73.         error = SystemTags( command, SYS_UserShell, TRUE,
  74.           SYS_Output, out_handle, TAG_DONE );
  75.       else
  76.         error = SystemTags( command, SYS_UserShell, TRUE, TAG_DONE );
  77.     }
  78.     else
  79.       /* externes Programm starten */
  80.       error = system( command );
  81.  
  82.     if( error == 0 )
  83.       pk = fnt_pklocate( f );
  84.  
  85.   }
  86.   return( pk );
  87. }
  88.