home *** CD-ROM | disk | FTP | other *** search
- /* Convert.tsrx */
- /* Copyright 1994 Soft-Logik Publishing Corporation */
- /* May not be distributed without Soft-Logik Publishing Corporation's express written permission */
- /* Purpose: Convert a directory of fonts to any format */
- /* $VER: 1.0 */
-
- /* Make sure rexx support is opened */
- IF ~SHOW('L','rexxsupport.library') THEN
- CALL ADDLIB('rexxsupport.library',0,-30)
-
- ADDRESS 'TYPESMITH'
- OPTIONS RESULTS
-
- /* Give Instructions */
- to_front
- display_alert 'This macro will convert an entire directory of fonts.|Continue|Cancel'
- IF RC=5 THEN exit
-
- /* Choose the source directory */
- get_file 'Select the directory to convert|Convert|TypeSmith:TSfonts|'
- if rc=5 then exit
- tPath=Result
- Div = max(lastpos(':', tPath),lastpos('/', tPath)) +1
- parse var tPath cPath =Div dum
-
- /* Build the font list */
- Files=showdir(cPath,file,'|')
- fLength=length(Files)
-
- /* Check for valid font files. Only .PFB, .AFM, .PFM, .DMF, .FM, .TYPE, .LIB, .TTF, .RFF are used */
- nList=0
- do while fLength>0
- cLength=pos('|',Files)
- if cLength=0 then do
- cLength=FLength+1
- fLength=0
- end
- cFile=left(Files,cLength-1)
- eFile=upper(right(cFile,cLength-lastpos('.',cFile)))
- if (eFile='.PFB' | eFile='.AFM' | eFile='.PFM' | eFile='.DMF' | eFile='.FM' | eFile='.TYPE' | eFile='.LIB' | eFile='.TTF' | eFile='.RFF') then do
- nList=nList+1
- List.nList=cFile
- end
- if FLength~=0 then Files=right(Files,fLength-cLength)
- fLength=fLength-cLength
- end
-
- /* If there aren't any valid files, alert the user and exit */
- if nList=0 then do
- display_alert 'There were no files in the directory of the supported types.|Cancel'
- exit
- end
-
- /* Choose the destionation directory */
- get_file 'Select the destination directory|Convert|ram:|'
- if rc=5 then exit
- tPath=Result
- Div = max(lastpos(':', tPath),lastpos('/', tPath)) +1
- parse var tPath dPath =Div dum
-
- /* Build the font list */
- Files=showdir(cPath,file,'|')
- fLength=length(Files)
-
- /* Choose the destination format. No multiple choice requester, so cheat and use a file requester */
- get_file 'Select the format to convert to|Convert|TypeSmith:Rexx/ConvertData|PostScript Type 1'
- if rc=5 then exit
- fformat=result
- fformat=right(fformat,length(fformat)-lastpos('/',fformat))
-
- /* Load the fonts and save them out */
- i=1
- do while i<nList+1
- lcheck=0
- eFont=upper(right(List.i,length(List.i)-lastpos('.',List.i)))
- rFont=left(List.i,length(List.i)-length(eFont)-1)
- if eFont='PFB' then do
- import_pfb cpath||List.i
- if rc>0 then call LoadError(List.i)
- import_afm cpath||rFont||'.afm'
- if rc>0 then do
- import_pfm cpath||rFont||'.pfm'
- if rc>0 then call LoadError(rFont)
- end
- lcheck=1
- end
- if eFont='DMF' then do
- open_dmf cpath||List.i
- if rc>0 then call LoadError(List.i)
- open_fm cpath||rFont||'.fm'
- if rc>0 then call LoadError(rFont)
- lcheck=1
- end
- if eFont='TYPE' | eFont='LIB' then do
- import_if cpath||List.i
- if rc>0 then call LoadError(List.i)
- lcheck=1
- end
- if eFont='TTF' then do
- import_ttf cpath||List.i
- if rc>0 then call LoadError(List.i)
- lcheck=1
- end
- if eFont='RFF' then do
- import_rff cpath||List.i
- if rc>0 then call LoadError(List.i)
- lcheck=1
- end
-
- if lcheck=1 then do
- if fformat='TrueType' then do
- export_ttf dPath||rFont||'.TTF|1'
- end
- if fformat='Compugraphic Intellifont' then do
- export_if dPath||rFont||'.type|1'
- end
- if fformat='IFF RFF' then do
- export_rff dPath||rFont||'.rff'
- end
- if fformat='Soft-Logik DMF' then do
- save_dmf dPath||rFont||'.dmf'
- end
- if fformat='PostScript Type 1' then do
- export_pfb dPath||rFont||'.pfb|1'
- export_afm dPath||rFont||'.afm'
- end
- close_font
- end
- i=i+1
- end
-
- display_alert 'Font conversion successful!|Thanks'
- EXIT
-
-
- /* LOAD ERROR */
- LOADERROR:
- display_alert 'An error occurred while loading '||List.i||'.|Exit'
- close_font
- EXIT
-