home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / TSMITH25.LHA / REXX.lha / rexx / Convert.tsrx
Encoding:
Text File  |  1994-08-18  |  4.0 KB  |  141 lines

  1. /* Convert.tsrx */
  2. /* Copyright 1994 Soft-Logik Publishing Corporation */
  3. /* May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4. /* Purpose: Convert a directory of fonts to any format */
  5. /* $VER: 1.0 */
  6.  
  7. /* Make sure rexx support is opened */
  8. IF ~SHOW('L','rexxsupport.library') THEN
  9.    CALL ADDLIB('rexxsupport.library',0,-30)
  10.  
  11. ADDRESS 'TYPESMITH'
  12. OPTIONS RESULTS
  13.  
  14. /* Give Instructions */
  15. to_front
  16. display_alert 'This macro will convert an entire directory of fonts.|Continue|Cancel'
  17. IF RC=5 THEN exit
  18.  
  19. /* Choose the source directory */
  20. get_file 'Select the directory to convert|Convert|TypeSmith:TSfonts|'
  21. if rc=5 then exit
  22. tPath=Result
  23. Div = max(lastpos(':', tPath),lastpos('/', tPath)) +1
  24. parse var tPath cPath =Div dum
  25.  
  26. /* Build the font list */
  27. Files=showdir(cPath,file,'|')
  28. fLength=length(Files)
  29.  
  30. /* Check for valid font files. Only .PFB, .AFM, .PFM, .DMF, .FM, .TYPE, .LIB, .TTF, .RFF are used */
  31. nList=0
  32. do while fLength>0
  33.     cLength=pos('|',Files)
  34.     if cLength=0 then do
  35.         cLength=FLength+1
  36.         fLength=0
  37.     end
  38.     cFile=left(Files,cLength-1)
  39.     eFile=upper(right(cFile,cLength-lastpos('.',cFile)))
  40.     if (eFile='.PFB' | eFile='.AFM' | eFile='.PFM' | eFile='.DMF' | eFile='.FM' | eFile='.TYPE' | eFile='.LIB' | eFile='.TTF' | eFile='.RFF') then do
  41.         nList=nList+1
  42.         List.nList=cFile
  43.     end
  44.     if FLength~=0 then Files=right(Files,fLength-cLength)
  45.     fLength=fLength-cLength
  46. end
  47.  
  48. /* If there aren't any valid files, alert the user and exit */
  49. if nList=0 then do
  50.     display_alert 'There were no files in the directory of the supported types.|Cancel'
  51.     exit
  52. end
  53.  
  54. /* Choose the destionation directory */
  55. get_file 'Select the destination directory|Convert|ram:|'
  56. if rc=5 then exit
  57. tPath=Result
  58. Div = max(lastpos(':', tPath),lastpos('/', tPath)) +1
  59. parse var tPath dPath =Div dum
  60.  
  61. /* Build the font list */
  62. Files=showdir(cPath,file,'|')
  63. fLength=length(Files)
  64.  
  65. /* Choose the destination format. No multiple choice requester, so cheat and use a file requester */
  66. get_file 'Select the format to convert to|Convert|TypeSmith:Rexx/ConvertData|PostScript Type 1'
  67. if rc=5 then exit
  68. fformat=result
  69. fformat=right(fformat,length(fformat)-lastpos('/',fformat))
  70.  
  71. /* Load the fonts and save them out */
  72. i=1
  73. do while i<nList+1
  74.     lcheck=0
  75.     eFont=upper(right(List.i,length(List.i)-lastpos('.',List.i)))
  76.     rFont=left(List.i,length(List.i)-length(eFont)-1)
  77.     if eFont='PFB' then do
  78.         import_pfb cpath||List.i
  79.         if rc>0 then call LoadError(List.i)
  80.         import_afm cpath||rFont||'.afm'
  81.         if rc>0 then do
  82.             import_pfm cpath||rFont||'.pfm'
  83.             if rc>0 then call LoadError(rFont)
  84.         end
  85.         lcheck=1
  86.     end
  87.     if eFont='DMF' then do
  88.         open_dmf cpath||List.i
  89.         if rc>0 then call LoadError(List.i)
  90.         open_fm cpath||rFont||'.fm'
  91.         if rc>0 then call LoadError(rFont)
  92.         lcheck=1
  93.     end
  94.     if eFont='TYPE' | eFont='LIB' then do
  95.         import_if cpath||List.i
  96.         if rc>0 then call LoadError(List.i)
  97.         lcheck=1
  98.     end
  99.     if eFont='TTF' then do
  100.         import_ttf cpath||List.i
  101.         if rc>0 then call LoadError(List.i)
  102.         lcheck=1
  103.     end
  104.     if eFont='RFF' then do
  105.         import_rff cpath||List.i
  106.         if rc>0 then call LoadError(List.i)
  107.         lcheck=1
  108.     end
  109.  
  110.     if lcheck=1 then do
  111.         if fformat='TrueType' then do
  112.             export_ttf dPath||rFont||'.TTF|1'
  113.         end
  114.         if fformat='Compugraphic Intellifont' then do
  115.             export_if dPath||rFont||'.type|1'
  116.         end
  117.         if fformat='IFF RFF' then do
  118.             export_rff dPath||rFont||'.rff'
  119.         end
  120.         if fformat='Soft-Logik DMF' then do
  121.             save_dmf dPath||rFont||'.dmf'
  122.         end
  123.         if fformat='PostScript Type 1' then do
  124.             export_pfb dPath||rFont||'.pfb|1'
  125.             export_afm dPath||rFont||'.afm'
  126.         end
  127.         close_font
  128.     end
  129.     i=i+1
  130. end
  131.  
  132. display_alert 'Font conversion successful!|Thanks'
  133. EXIT
  134.  
  135.  
  136. /* LOAD ERROR */
  137. LOADERROR:
  138. display_alert 'An error occurred while loading '||List.i||'.|Exit'
  139. close_font
  140. EXIT
  141.