home *** CD-ROM | disk | FTP | other *** search
/ IBM Presents OS/2 Software Hits 1995 / OS-2_SW_HITS_2ND_EDITION_1995.ISO / i17 / pmx20c1.exe / PMXC1.ZIP / BIN / allfonts.cmd next >
OS/2 REXX Batch file  |  1994-10-31  |  5KB  |  147 lines

  1. /*Rexx*/
  2. /*
  3.  * Oct 1994 -- ALLFONTS.cmd is a REXX program that converts fonts from PMX
  4.  *           X11r5 format to .xfn (OS/2 PM private) format.  The input
  5.  *           directory is the current directory.
  6.  *         The following flags are supported:
  7.  *         Flag         Default    Description
  8.  *         ----         -------    -----------
  9.  *         -bdf           NO        Convert all *.bdf files to .xfn format
  10.  *         -pcf           YES       Convert all *.pcf files to .xfn format
  11.  *         -o directory   CURRENT   Output/target, subdirectory.
  12.  *                                  If not specified, the current directory is used.
  13.  *         -m             NO        Execute MKFONTDR.EXE on output directory.
  14.  *         -erase         NO        Delete converted .pcf fontfiles in output dir.
  15.  *                                  As each font (.bdf and/or .pcf) is converted,
  16.  *                                  under control of the -bdf and -pcf flags, the
  17.  *                                  filename.pcf file is searched for in the output
  18.  *                                  directory.  If found, it is deleted, when the -erase
  19.  *                                  flag is specified.
  20.  *    Note - When -m is specified, only one font format may exist in the same directory.
  21.  *           Therefore the same font in .pcf and .xfn format will cause an error in mkfontdr.exe.
  22.  *           To avoid this, use the -erase flag, or manually move or rename files in the
  23.  *           output directory BEFORE executing mkfontdr.exe.
  24.  */
  25.  
  26. /*trace r*/
  27.  
  28. tempFile = 'temp_dir.tmp'
  29. dobdf = 0
  30. dopcf = 1
  31. domk  = 0
  32. doe   = 0
  33. count = 0
  34. outdir = directory()
  35. startdir = outdir
  36.  
  37. arg arglist
  38. do forever
  39.     parse var arglist nextarg arglist
  40.     select
  41.     when nextarg = '-BDF' then do
  42.         dobdf = 1
  43.         end
  44.     when nextarg = '-PCF' then do
  45.         dopcf = 1
  46.         end
  47.     when nextarg = '-M' then do
  48.         domk = 1
  49.         end
  50.     when nextarg = '-O' then do
  51.         parse var arglist nextarg arglist
  52.         outdir = directory(nextarg)
  53.         if outdir = "" then do
  54.            say "ERROR:  Invalid output directory, " nextarg
  55.            exit 1
  56.         end
  57.          /* Restore original drive:directory */
  58.         call directory(startdir)
  59.         end
  60.     when nextarg = '-ERASE' then do
  61.         doe = 1
  62.         end
  63.     when nextarg = "" then
  64.         leave
  65.     otherwise
  66.         say "ALLFONTS.CMD is a REXX program that converts fonts from PMX "
  67.         say "  X11r5 format to .xfn (OS/2 PM private) format.  The input"
  68.         say "  directory is the current directory."
  69.         say "The following flags are supported:"
  70.         say "Flag         Default    Description"
  71.         say "----         -------    -----------"
  72.         say "-bdf           NO        Convert all *.bdf files to .xfn format"
  73.         say "-pcf           YES       Convert all *.pcf files to .xfn format"
  74.         say "-o directory   CURRENT   Output/target, subdirectory."
  75.         say "-m             NO        Execute MKFONTDR.EXE on output directory."
  76.         say "-erase         NO        Delete converted .pcf fontfiles in output dir."
  77.         say " "
  78.         exit 1
  79.     end /* select */
  80. end
  81.  
  82. if (domk & (\doe)) then do
  83.    say "WARNING:  The MKFONTDR.EXE utility does not permit the same "
  84.    say " font, in different formats (such as .pcf, .xfn), in the "
  85.    say " same directory.  If mkfontdr.exe fails, check for the same "
  86.    say " font in .pcf and .xfn format in the " outdir " directory."
  87.    say " Using the -erase flag with ALLFONTS.CMD will erase any .pcf "
  88.    say " font with a corresponding .xfn format, converted wih ALLFONTS.CMD."
  89.    pause
  90.    end
  91.  
  92. if dopcf then do
  93.    /* -- get a list of all the .PCF files in the current directory:*/
  94.    'dir /b /f *.pcf >' tempFile
  95.  
  96.    fileName = linein(tempFile)
  97.    do while length(fileName)<>0
  98.       parse var fileName fName '.' fType other
  99.    
  100.       /* -- run PCFTOPM on each .pcf file:*/
  101.       'pcftopm -o 'outdir'\'fName'.xfn 'fileName
  102.       count = count + 1
  103.       if (doe & fileexists(outdir'\'fName'.pcf')) then
  104.          'ERASE' outdir'\'fName'.pcf'
  105.       fileName = linein(tempFile)
  106.       end
  107.     /* close the stream */ 
  108.    call LINEOUT(tempFile)  
  109. end
  110.  
  111. if dobdf then do
  112.    /* -- get a list of all the .BDF files in the current directory:*/
  113.    'dir /b /f *.bdf >' tempFile
  114.  
  115.    fileName = linein(tempFile)
  116.    do while length(fileName)<>0
  117.       parse var fileName fName '.' fType other
  118.    
  119.       /* -- run PCFTOPM on each .pcf file:*/
  120.       'bdftopm -o 'outdir'\'fName'.xfn 'fileName
  121.       count = count + 1
  122.       if (doe & fileexists(outdir'\'fName'.pcf')) then
  123.          'ERASE' outdir'\'fName'.pcf'
  124.       fileName = linein(tempFile)
  125.       end
  126.     /* close the stream */ 
  127.    call LINEOUT(tempFile)  
  128. end
  129.  
  130. if domk then do
  131.    /* -- Create the FONTS.DIR file:*/
  132.    'mkfontdr' outdir
  133.    end
  134. else if count > 0 then do
  135.    say "WARNING: MKFONTDR.EXE has NOT executed."
  136.    say "  MKFONTDR.EXE must be run in output directory " outdir
  137.    say "  before the fonts are available for use by PMX."
  138. end
  139.  
  140. 'ERASE' tempFile
  141. return
  142.  
  143. fileexists: procedure
  144. arg file
  145. progname = STREAM(file, 'C', 'QUERY EXISTS')
  146. return progname \= ''
  147.