home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / choosedlfonts.pprx < prev    next >
Encoding:
Text File  |  1992-08-26  |  3.6 KB  |  140 lines

  1. /*
  2. @BChooseDLFonts  @P@Iby Robin Evans, July, 1992
  3. Allows user to choose which PS fonts will be downloaded
  4. */
  5.  
  6. cr = '0a'x
  7. PSListF = 't:ppuser_fontList'
  8.  
  9.     /* Get name of ps fonts directory */
  10. if exists('s:PPage.ini') then do
  11.     call open(INI, 's:PPage.ini', R)
  12.     pos = seek(ini, -60, 'E')    /* move to 60 bytes from end */
  13.     do until eof(INI)
  14.         parse value readln(INI) with Type PSDir
  15.         if Type = 'PSF' then leave
  16.     end
  17.     if Type ~== 'PSF' then PSDir = 'cgfonts:ps'
  18.     if right(PSDir, 1,1) ~== ':' & right(PSDir, 1,1) ~= '/' then
  19.         PSDir = PSDir'/'
  20.     PSDir = strip(PSDir)
  21. end
  22.  
  23. call 'SafeEndEdit.rexx'
  24.  
  25. pgOnly = ppm_Inform(2, 'List fonts for', 'Document', '  Page   ')
  26. select
  27.     when pgOnly == 1 then pgOpt = ppm_CurrentPage()
  28.     when pgOnly == -1 then exit_msg('Operation cancelled.')
  29.     otherwise PgOpt = ''
  30. end
  31.  
  32.  
  33. call ShowStatus('Preparing font information')
  34.  
  35. interpret "FontsUsed = ppm_sortlist(ppm_getpsfontsused("PgOpt"),0,0)"
  36. parse var FontsUsed NumUsed '0a'x FontsUsed
  37.  
  38.  
  39. DLFonts = translate(ppm_selectfromlist('Pick fonts to download',28, min(16, NumUsed), 1, FontsUsed), ' ', '0a'x)
  40. if DLFonts = '' then exit_msg('Operation cancelled.')
  41.  
  42. if pgOnly == 1 then do     /* Get all fonts in doc now */
  43.     FontsUsed = translate(ppm_getpsfontsused(), ' ', '0a'x)
  44.     parse var FontsUsed NumUsed FontsUsed
  45. end
  46. else
  47.     FontsUsed = translate(FontsUsed, ' ', '0a'x)
  48.  
  49. DontDL = ''
  50. if words(DLFonts) < Numused then do
  51.     do x = 1 for words(FontsUsed)
  52.         CurFont = word(FontsUsed, x)
  53.         if find(DLFonts, CurFont) = 0 then
  54.             DontDL = DontDL CurFont
  55.     end
  56. end
  57.  
  58.     /* With WShell this can be done more efficiently with ExecIO */
  59. address command
  60. 'list quick nohead' PSDir '>'PSListF
  61. address
  62. call open(FontL, PSListF, R)
  63. PSfonts = ''
  64. do until eof(FontL)
  65.     lfont = readln(FontL)
  66.     if lfont ~== '' then do
  67.         parse var lfont lfont '.psfont'
  68.         PSfonts = lfont PSfonts
  69.     end
  70. end
  71.  
  72.  
  73. NotDLReady = ''
  74. DLReady = ''
  75.  
  76. do x = 1 to words(DLFonts)
  77.     call ShowStatus('Checking fonts on' PSDir'.')
  78.     CurFont = word(DLFonts, x)
  79.     if find(PSFonts, CurFont) = 0 then do
  80.         if find(PSFonts, '_'CurFont) > 0 then do
  81.             call rename(PSDir'_'CurFont'.psfont', PSDir || CurFont'.psfont')
  82.             DLReady = DLReady || cr || CurFont
  83.         end
  84.         else
  85.             NotDLReady = NotDLReady || cr || CurFont
  86.     end
  87.     else
  88.         DLReady = DLReady || cr || CurFont
  89. end
  90.  
  91. if words(DontDL) > 0 then
  92.     call ShowStatus('Renaming fonts which won''t be downloaded.')
  93.     do x = 1 for words(DontDL)
  94.         CurFont = word(DontDL, x) || '.psfont'
  95.         if exists(PSDir || CurFont) then
  96.             call rename(PSDir || CurFont, PSDir'_'CurFont)
  97.     end
  98.  
  99. LeaveTran = 0
  100. do TranLoop = 0 until LeaveTran
  101.     call ShowStatus('Checking for font files on other directories.')
  102.     if length(NotDLReady) == 0 then leave TranLoop
  103.     if ppm_Inform(2, 'Fonts not available for DL:'NotDLReady,'Finished','Transfer') then do
  104.         TranRsp = reverse(ppm_getfilename('Choose extra PS files dir',"",""))
  105.         if TranRsp ~= '' then do
  106.             TranFonts = translate(NotDLReady, ' ', '0a'x)
  107.             NotDLReady = ''
  108.             parse var TranRsp foo '/' TranPath
  109.             if foo == TranRsp then do
  110.                 parse var TranRsp foo ':' TranPath
  111.                 TranPath = reverse(TranPath) || ':'
  112.             end
  113.             else
  114.                 TranPath = reverse(TranPath) || '/'
  115.             do x = 1 to words(TranFonts)
  116.                 CurFont = word(TranFonts, x) || '.psfont'
  117.                 if exists(TranPath || CurFont) then do
  118.                     call ShowStatus('Copying' CurFont 'to' PSDir'.')
  119.                     address command 'copy' TranPath || CurFont 'to' PSDir || CurFont
  120.                 end
  121.                 else
  122.                     NotDLReady = NotDLReady || cr || word(TranFonts,x)
  123.             end
  124.             iterate TranLoop    /* Check for fonts to be trans from anther dir */
  125.         end
  126.     end
  127.     LeaveTran = 1
  128. end
  129.  
  130. exit_msg('Finished',)
  131.  
  132. exit_msg: procedure
  133. do
  134.    parse arg message
  135.  
  136.    if message ~= '' then call ppm_Inform(1,message,' Okay ')
  137.     call ppm_ClearStatus()
  138.     exit
  139. end