; ; Program Name: Viewfonts 2 ; Author:       David McMinn ; Last saved:   19/11/98 ; ;   !!! WARNING !!! - Does NOT work with type1.library (Posrscript fonts) ;                     DOES work with ttf.library v0.7 (true-type fonts) ; ; Programming Requirements: ;   Blitz2 ;   Blitzlibs:amigalibs.res as a resident ;     (must be the amigalibsii.res version) ;   RISortLib ;   RIAppLib ;   NeilsReqToolsLib ;   RICommoditiesLib ;   2Mb is enough to compile Blitz (using the minimum external libraries, ;   but probably won't be enough to run Viewfonts 2 through Blitz. Unless ;   you have a *very* minimal working environment. ; ; System Requirements for Viewfonts 2: ;   Amiga with WB2+ ;   bullet.library (WB3+ only, for CG fonts) ;   ttf.library v0.7 (only for true-type fonts) ;   commodities.library ;   diskfont.library ;   reqtools.library v38+ ;   PROBABLY OTHERS!! ; ; To do (in no order): ;   Localisation ;   Reduce executable size ;   Text/field colours ;   Font style ;   Font/directory information ;   CLI interface ;   AREXX interface ;   Shift-selected WB arguments ;   User selectable sample string ;   Colorfont colours handled properly ;   Comment program ;  Ã                                         ; Allow program to start from WB ;CloseEd                                           ; Only used when run from Blitz 2 ;NoCli                                             ; Don't do that any more, as its too big  ; ------------------------- CONSTANT DEFINITIONS -------------------------- #HIGH_TIME    = 5                                 ; Length of time (50ths) to highlight gadgets after keypress  ; * Window IDCMP flags #IDCMP        = #IDCMP_NEWSIZE + #IDCMP_MOUSEMOVE + #IDCMP_RAWKEY #IDCMP =#IDCMP+ #IDCMP_GADGETDOWN + #IDCMP_GADGETUP + #IDCMP_MENUPICK #IDCMP =#IDCMP+ #IDCMP_CLOSEWINDOW + #IDCMP_INTUITICKS + #IDCMP_VANILLAKEY  ; * Menu and menu item IDs #MID_PROJECT  = 0 #MID_ABOUT    = 0 #MID_HIDE     = 1 #MID_QUIT     = 3  #MID_FONTS    = 1 #MID_SELALL   = 0 #MID_UNSELALL = 1 #MID_READDRAW = 2 #MID_COPYFONT = 3 #MID_DELETFNT = 4  #MID_HELP     = 2 #MID_HTUH     = 0 #MID_CONTENTS = 2 #MID_USING    = 3  #FONTNUMS=1000                                  ; Able to handle 1000 sizes of 1000 fonts   ; --------------------------- NEWTYPE DEFINITIONS ----------------------- .env                                       ; Holds data pertaining to the environment, i.e.   *_screen._Screen                                 ; Address of public screen   *_window._Window                                 ; Address of VF2 window   *_imenus.Menu                                   ; Address of intuition menus   *_gadget.Gadget                                 ; Pointer to start of gadget list   _visual.l                                       ; Result of visual info call   execver.w                                       ; Exec version    .list                                      ; Type for listview entries   pad.w   text.s                                          ; Text to show in listview    .tooltypes                                 ; Type for holding tooltype settings   popup.w                                         ; CX_POPUP 0=no, -1=yes   hotkey.s                                        ; Commodity hotkey   offline.s                                       ; Default destination drawer   drawer.s                                        ; Default source drawer   userpub.s                                       ; Public screen name (DEFAULT, FRONT, <NAME>)   iconify.w                                       ; Hide gui method 0=icon, -1=menu   helppath.s                                      ; Path to help file, used to be set in tooltypes, now just PROGDIR:     ; ----------------------------- ERROR HANDLER ---------------------------  rt_taglist.TagItem(7)                         ; Array of tag items for NeilsReqToolsLib 3.env environ                               ; Holds data about intiotion environment  Ž                                            ; Error handler routine: shows requester then ends   dummy=("Viewfonts 2:"+Ü(10)+"Fatal Error","_Quit",&rt_taglist(2))    bigerror  Ž   ; ------------- GLOBAL VARIABLE DEFINITIONS DEFTYPES THEN DIMS -------------- 3.w                                         ; Set default variable type  3.s def_fontname                            ; Name of screen font 3.w def_fontsize                            ; Size of screen font  3.w ww, wh, wx, wy                          ; Window width, height, xpos & ypos 3.w min_wh                                  ; Minimum window height (dependant on font) 3.l min_ww                                  ; Minimum window width 3.w wb2lvfix                                ; Fix for WB2 ListViews 3.w quit_flag                               ; Shows when program is to exit  3.w lv_avail                                ; Listview for available font names 3.w lv_sizes                                ; Listview for sizes of current font 3.w lv_selec                                ; Listview for user selected fonts 3.w st_fname                                ; String for current font name 3.w in_fsize                                ; Integer for current font size 3.w bu_selec                                ; Button to select fonts 3.w st_sourc                                ; String for source path 3.w sh_sourc                                ; Shape for showing source path requestor 3.w sh_destn                                ; Shape for showing dest path requestor 3.w st_destn                                ; String for destination path 3.w bu_copyf                                ; Button to copy selected fonts from source to dest 3.w bu_delet                                ; Button to delete selected fonts from dest  3.l ev                                      ; Intuition events 3.l ce                                      ; Commodity events 3.l cx                                      ; Message from Exchange program  3.w modified                                ; Flag shows whether drawer contents changed 3.l appitem                                 ; Address of newly created appitem (needs to be here as AddAppIcon screws                                                   ; local variable base)  3.tooltypes options                         ; Holds tooltype settings 3.l AGBase                                  ; AmigaGuide library base 3.l AG_Context                              ; Handle for AmigaGuide 3.l AmigaGuideMask                          ; Used to check if messages have been recieved 3.NewAmigaGuide AG_NewGuide                 ; Holds information about how AmigaGuide will open 3.s copycmd                                 ; A copy of the command sent to AmigaGuide 3.l AGPending                               ; Pointer to copy of amigaguide command 3.s currentfont                             ; name of current font 3.s temp1                                   ; Temporary string for during startup / anytime   wtags.TagItem(16)                             ; Array to hold tags for window   ³ available.list(#FONTNUMS)                ; List of available font names  ³ sizes.list(#FONTNUMS)                    ; Sizes of current font  ³ selected.list(#FONTNUMS)                 ; Names of user selected fonts   ; REQTOOL TAGLIST ; rt_taglist(0)\ti_Tag=#RT_LockWindow,Œ          ; Flag to lock window and display busypointer rt_taglist(2)\ti_Tag=#RTEZ_Flags,#EZREQF_CENTERTEXT;Centres all text within requester rt_taglist(3)\ti_Tag=#RT_ReqPos,#REQPOS_TOPLEFTSCR; Requester appears in top left of screen rt_taglist(4)\ti_Tag=#RTEZ_ReqTitle,?program      ; Title of requester rt_taglist(5)\ti_Tag=#RT_Underscore,95            ; Symbol to signal an underscore character in gadget text (_) rt_taglist(6)\ti_Tag=#TAG_END,#TAG_DONE           ; Signals end of tag list  ; ------------------------ FUNCTIONS AND STATEMENTS ------------------------- ; **************************************************************************** ; * Procedure Name  : tooltypes ; * Parameters      : None ; * Returns         : None ; * Description     : Finds the tooltypes from the Viewfonts2 icon. ; ****************************************************************************  tooltypes{}                 options                     ; Get access to structure for tooltypes   3.l           success                     ; Result of searching for tooltypes   3.DiskObject  *object                     ; Information file for icon  ; * Try to load icon information and set defaults for tooltype options   *object=õ("Viewfonts2")   options\popup=-1,"ctrl lalt v","SYS:Offline","FONTS:","DEFAULT",-1  ; * If the icon information was loaded, check for each tooltype and then ; * set the option according to tooltype string    *object<>0     success=õ(*object\do_ToolTypes,"CX_POPUP")      success B Ü(Ú$(success))="NO" ! options\popup=0      success=õ(*object\do_ToolTypes,"CX_HOTKEY")      success B Ú$(success)<>"" ! options\hotkey=Ú$(success)      success=õ(*object\do_ToolTypes,"DEST")      success B Ú$(success)<>"" ! options\offline=Ú$(success)      success=õ(*object\do_ToolTypes,"SOURCE")      success B Ú$(success)<>"" ! options\drawer=Ú$(success)      success=õ(*object\do_ToolTypes,"PUBSCREEN")      success B Ú$(success)<>"" ! options\userpub=Ú$(success)      success=õ(*object\do_ToolTypes,"ICONIFY")      success B Ü(Ú$(success))="ICON" ! options\iconify=0  ; * Remove the icon information from memory     õ *object         ; **************************************************************************** ; * Procedure Name  : highlight ; * Parameters      : gadno.w - The ID of the gadget to highlight ; * Returns         : None ; * Description     : This statement highlights a gadget for a length (in 50ths ; *                   of a second) of time. Only needed to be used on keypresses. ; ****************************************************************************  highlight{gadno.w}   Æ 0,gadno,-1   Æ 0,gadno   þ #HIGH_TIME   Æ 0,gadno,0   Æ 0,gadno     ; **************************************************************************** ; * Name        : findlibbase ; * Parameters  : libname$ - Name of library to find ; * Returns     : 0 for library not found, therefore you need to open it ; *               or address of library base ; * Description : Finds the address of the library base specified by the ; *               name passed to the function. ; **************************************************************************** 	.l findlibbase{libname$}   3.ExecBase  *execbase                     ; Pointer to exec base   3.Node      *head,*ptr                    ; Node pointers for lists   3.l         libbase                       ; Address of library base    *execbase = Ú.l(4)                           ; Get address of exec base   *head = *execbase\LibList\lh_Head               ; Get address of head of library list   *ptr = *head                                    ; Move to head of list    (*ptr\ln_Succ <> 0 B libbase = 0)       ; While library not found     memlib$ = Ú$(*ptr\ln_Name)                 ; Get library name from exec list      Ü(memlib$) = Ü(libname$)         ; If same as specified library       libbase = *ptr                              ; Remember address           *ptr=*ptr\ln_Succ                             ; Move to next library   Á    	  libbase                         ; Return base address of library  	   ; **************************************************************************** ; * Name        : getpubscreen ; * Parameters  : userpub$ - Name of public screen to find ; * Returns     : Long     - Pointer to address of public screen, or 0 if no ; *               screen can be found. ; * Description : Finds the address of the public screen specified. If the ; *               screen cannot be found, the default screen is used. If this ; *               cannot be found, the Workbench is used, or 0 will be returned ; **************************************************************************** 	.l getpubscreen{userpub$}   3.l             pscrname                  ; Pointer to name of pubscreen   3._IntuitionBase *intuibase               ; Pointer to intuition base   3.List          *psl                      ; Pointer to list of pubscreens   3.PubScreenNode *psn                      ; Working pointer for list   3._Screen        *scr                     ; Pointer to first intuition screen   3._Screen        *myscreen                ; Pointer to found public screen    *intuibase=findlibbase{"intuition.library"}     ; Get intuition library base    Ü(userpub$)="FRONT"                     ; If user wants to open on front public screen     *psl=ÿÓ                       ; then find out name of front public screen      *psl<>0                                    ; Lock public screen list       *scr=*intuibase\FirstScreen                 ; Get address of first screen       *psn=*psl\lh_Head                           ; Get head of list of public screens        *psn<>0                               ; Traverse list of public screens          *psn\psn_Screen=*scr                   ; If address of public screen = address of first screen           pscrname=*psn\psn_Node\ln_Name          ; Store address of name of public screen                   *psn=*psn\psn_Node\ln_Succ                ; Move to next public screen       Á           ÿÔ                          ; Unlock public screen list   "                                            ; If user doesn't want to open on front screen ; * Pointer to name of public screen is address of name string, if not DEFAULT      Ü(userpub$)<>"DEFAULT" ! pscrname=&userpub$        *myscreen=ÿÑ(pscrname)              ; Try to lock public screen (so it cannot close)     (*myscreen=0 B pscrname<>0)                ; If could not lock screen but a name was specified (not DEFAULT)     *myscreen=ÿÑ(0)                   ; Try to lock default public screen      ; * If default public screen not found, try to lock the Workbench screen    *myscreen=0 ! *myscreen=ÿÑ("Workbench")  ; * If a screen was locked, Poke it into the BB2 screen struct (for use with windows)    *myscreen<>0     Ú.l ž Ï(0),*myscreen     , Ï 0        	  *myscreen                       ; Return address of screen locked  	   ; **************************************************************************** ; * Name        : gtmenus ; * Parameters  : newmenu.l - Address of NewMenu data ; *               *e.env    - Pointer to environment data ; * Returns     : *e\_imenus will reflect the result. 0 for an error or the ; *               address of the intuition menu. ; * Description : Sets up the GTMenus, for intuition. *e\_visual should be set ; *               up before calling this routine. ; ****************************************************************************  gtmenus{newmenu.l,*e.env}   3.l   nlm_flag                            ; Flag for NewLookMenus   3.l   menupen                             ; Colour for menu text            nm_taglist.TagItem(1)               ; Menus taglist     *e\execver>=39                               ; Set up colours for WB3+     nlm_flag=Œ     menupen=1        nm_taglist(0)\ti_Tag=#GTMN_FrontPen,menupen     ; Set colours in taglist   nm_taglist(1)\ti_Tag=#TAG_DONE,#TAG_END   *e\_imenus=ö(newmenu,&nm_taglist(0)); Create menus from newmenu struct  ; * If menus created, set up flag for WB3+ and get intuition to set out the menus    *e\_imenus<>0     nm_taglist(0)\ti_Tag=#GTMN_NewLookMenus,nlm_flag     ö *e\_imenus,*e\_visual,&nm_taglist(0)         ; **************************************************************************** ; * Name        : gadgets ; * Parameters  : *e.env       - Pointer to base of environment settings ; *               *o.tooltypes - Pointer to the tooltype settings ; * Returns     : *e\_gadget will be changed to point to the start of the gadgetlist ; * Description : Sets up the GadTools gadgets. ; ****************************************************************************  gadgets{*e.env, *o.tooltypes}    lv_avail, lv_sizes, lv_selec, st_fname, in_fsize, bu_selec, st_sourc    sh_sourc, sh_destn, st_destn, bu_copyf, bu_delet     available(),sizes(),selected()    3.s temp_name                             ; Temporarily holds name of font   3.s temp_sorc                             ;       "       "   source drawer   3.s temp_dest                             ;       "       "   dest drawer   3.w temp_size                             ;       "       "   size of font    3.l textlen                               ; Length of longest text    3.w gadheight                             ; Height of each gadget   3.w iw, ih                                ; Inner width and height of window   3.w xm                                    ; Middle of window   3.w wlo, wto                              ; Window left and top borders    gadheight=Ú.w(ž Ã(0)+4)+ 6        ; Work out height of single line gadgets  ; * Work out left and top window borders, and the innerwidth and innerheight of the window   wlo=*e\_window\BorderLeft   wto=*e\_window\BorderTop   iw=*e\_window\Width - *e\_window\BorderRight - wlo   ih=*e\_window\Height - *e\_window\BorderBottom - wto  ; * Use the screen's font   , Ã 0   Å
 0  ; * Work out various dimensions for putting gadgets onto window   xm = iw/2 + wlo   y1=53*ih/100   y2=ih-2*gadheight-10    y2<y1+15 ! y1=y2-15   textlen=ÿ(*e\_window\RPort,"Source",6)  ; * If the gadget list already exists    *e\_gadget ;   * Store the current strings in the string gadgets     temp_sorc=Æ(0,st_sourc)     temp_name=Æ(0,st_fname)     temp_size=Æ(0,in_fsize)     temp_dest=Æ(0,st_destn) ;   * Remove the old gadgets and clean up the window     Æ 0     ÿÈ *e\_window     Å/     + Æ 0     *e\_gadget=0   "                                            ; If this is the first time gadgets ;   * Set the drawer strings to reflect the tooltype settings     temp_sorc=*o\drawer     temp_dest=*o\offline      ; * Define the gadgets (using sizes and positions relative to window size)   Æ 0,lv_avail,4,1+gadheight,4+(xm-20)*2/3,y1-5-2*gadheight,"_Available Fonts",$4,available()   Æ 0,lv_sizes,(xm-28)*2/3+16,1+gadheight,(xm-20)*1/3,y1-5-2*gadheight,"S_izes",$4,sizes()   Æ 0,lv_selec,xm+12,1+gadheight,iw-18-xm,y1-5-2*gadheight,"Selected Fonts",$4,selected()    Æ   0,st_fname,4,y1-4-gadheight,4+(xm-20)*2/3,gadheight,"",$1,192   Æ  0,in_fsize,(xm-28)*2/3+16,y1-4-gadheight,(xm-20)*1/3,gadheight,"",$1,0    Æ   0,bu_selec,xm+12,y1-4-gadheight,iw-18-xm,gadheight,"Select current _font",$10   Æ   0,st_sourc,10+textlen,y2+6,25*iw/50-20-textlen,gadheight,"_Source",$1,192    Æ  0,sh_sourc,25*iw/50-9,y2+6,0,1   Æ  0,sh_destn,25*iw/50-9,y2+8+gadheight,0,1    Æ   0,st_destn,10+textlen,y2+8+gadheight,25*iw/50-20-textlen,gadheight,"D_est",$1,192   Æ   0,bu_copyf,xm+26,y2+6,iw-32-xm,gadheight,"_Copy fonts",$10   Æ   0,bu_delet,xm+26,y2+8+gadheight,iw-32-xm,gadheight,"_Delete fonts",$10  ; * Attach GT list and get address   Æ 0,0   *e\_gadget=Ú.l(ž Æ(0))  ; * Set the string gadgets to what they used to be   Æ 0,st_sourc,temp_sorc   Æ 0,st_destn,temp_dest   Æ 0,st_fname,temp_name   Æ 0,in_fsize,temp_size  ; * Draw bevelled boxes round the shape gadgets to complete button 'look'   Æ 0,25*iw/50-6,y2+6+wto,20,gadheight,0   Æ 0,25*iw/50-6,y2+8+wto+gadheight,20,gadheight,0     ; **************************************************************************** ; * Name        : getdrawer ; * Parameters  : gad_ID.w - ID of string gadget to use ; * Returns     : Word - (Boolean) 0 for user selected cancel, true otherwise ; * Description : Displays a requester to get a drawer from the user, and sets ; *               the string gadget depending upon the result. ; **************************************************************************** 	.w getdrawer{gad_ID.w}   3.s temp                                  ; Holds result of requester   
 2,Æ(0,gad_ID) ; Set default directory to what was in string gadget   temp=("Select a drawer")         ; Put up path requester    temp<>""                                     ; If cancel not selected     Æ 0,gad_ID,temp                     ; Set string gadget to new directory     	  -1                            ; Return true   "     	  0                             ; Otherwise return false      	   ; **************************************************************************** ; * Name        : cleanupwin ; * Parameters  : *e.env - Pointer to environment settings. ; * Returns     : None ; * Description : Closes window and frees any memory used, changes environment ; *               settings to reflect closed windows, screens etc. ; ****************************************************************************  cleanupwin{*e.env}    *e\_imenus                                   ; If menus exist     ÿ *e\_window                    ; Remove from window     ö *e\_imenus     *e\_imenus=0         *e\_gadget                                   ; If gadget list exists     Æ 0                                ; Remove from window     + Æ 0     *e\_gadget=0         *e\_window                                   ; If window is open     Å< 0                                 ; Close window     *e\_window=0         *e\_visual                                   ; If visual info for screen is still held     ö *e\_visual                    ; Free it     *e\_visual=0         *e\_screen                                   ; If screen is still locked     ÿÒ 0,*e\_screen                 ; Unlock public screen     *e\_screen=0         ; **************************************************************************** ; * Name        : hidegui ; * Parameters  : title.l   - Title of AppMenuItem or AppIcon ; *               iconify.w - Place to iconify to; 0=AppIcon, 1=AppMenu ; * Returns     : Word - Used to determine if the program is to quit ; * Description : Hides the window, sets up AppMenu/Icon and waits for a ; *               hotkey press or commodity event. ; **************************************************************************** 	.w hidegui{title.l,iconify.w}    available(),sizes(),selected(),appitem   3.l           port                        ; Address for message port   3.l           ae, ce, cx                  ; Variables to hold the various messages   3.w           exit                        ; Shows when loop should be exited from   3.w           quit                        ; Tells main loop if program should quit   3.DiskObject  *object                     ; Icon information pointer    À available()                           ; Clear and reset lists   À sizes()   À selected()    *object=õ("Viewfonts2")            ; Try to get icon information   port=þâ                             ; Create a message port for all appevents    iconify=0 B *object                        ; Create AppIcon if possible and requested     ~.l a4,-(a7)     appitem=î(0,0,title,port,0,*object,0)     ~.l (a7)+,a4   "     appitem=î(0,0,title,port,0)    ; Add an app menu item        »     þ 5                                      ; Big delay (might help in multi tasking)     ae=þŽ(port)                              ; get messages from our port     ce=¬                             ; Get commodity messages      ¬=0 ! exit=1                    ; Check hotkey      cx=¬                            ; Check messages from Exchange      cx        ¬                                 ; If 'Remove'         exit=1                                    ; exit from iconify loop         quit=1                                    ; set program quit flag         ¬                               ; If 'Show Interface'         exit=1                                    ; exit from iconify loop         ¬         exit = 1         Œ (ae  exit)                              ; Loop until message from AppXXXX or exit flag set     iconify=0 B *object                        ; Remove appropriate App object     î appitem   "     î appitem        þã port                             ; Remove message port    *object ! õ *object         ; Free icon information if exists    	  quit                            ; Return program quit flag   	   ; **************************************************************************** ; * Name        : getminwidth ; * Parameters  : None ; * Returns     : Long - the minimum width of the window ; * Description : Gets the minimum width of the window, without needing the ; *               window opened or windowfont x called. ; **************************************************************************** 	.l getminwidth{}   3._RastPort  rp                           ; Rastport to use font on   3.TextFont  *tf                           ; Pointer to font data   3.s         min_string                    ; The string for the minimum width    ÿ &rp                               ; Initialize a rastport   *tf.TextFont=Ú.l(ž Ã(0)+8)        ; Get window font textfont struct   ÿ &rp, *tf                               ; Set font for rastport  ; * Return length of minimum string in pixels   min_string="Available Fonts Sizes Select current font"   	  ÿ(&rp,&min_string,Ü(min_string))  	   ; **************************************************************************** ; * Name        : updatesizes ; * Parameters  : None ; * Returns     : None ; * Description : Shows the correct list of sizes for any new font ; ****************************************************************************  updatesizes{}    lv_sizes,in_fsize,st_sourc    available(),sizes()   3.s drawer                                ; Name of drawer to search for font sizes   3.l dirlock                               ; Pointer to a BCPL directory lock   3.l winlock                               ; Window lock, used with RTUnlockWindow   3.FileInfoBlock *diskfib                  ; Information for examined files   3.w count                                 ; Number of items added to list   3.w temp                                  ; Fontname as number (probably font if contains a number)   3.w found                                 ; Used to show where in list to insert size    Æ 0,lv_sizes                         ; Detach list from listview   À sizes()                               ; Clear list of sizes  ; * Sort out path to font sizes   drawer=Æ(0,st_sourc)    Ü(drawer,1)<>":" B Ü(drawer,1)<>"/" ! drawer=drawer+"/"   drawer=drawer+available()\text  ; * Attempt to get a lock on that directory   dirlock=þ
(&drawer,-2)    dirlock     *diskfib = þ (#DOS_FIB,0)      *diskfib        þ(dirlock,*diskfib)                  ; If the lock is successful         winlock=(0)                     ; Lock window and display busy-pointer          ;  Read in successive files from the directory until all files are read         ; or the list is full. If a value can be obtained from the filename         ; it is probably a font size, so add to the list if possible.         ;  Count is always increased, even if an item could not be added to the         ; list when it should be (no memory etc), so that the loop will always         ; quit eventually.          (þ(dirlock,*diskfib)<>0 B count<#FONTNUMS)            ; If the directory entry is a file            *diskfib\fib_DirEntryType<0             temp=Œ(Ú$(&*diskfib\fib_FileName))  ; Get value of filename              ; If value of filename is not zero then it is probably a font file,             ; so set up list to be searched for correct position to insert it.              temp<>0               found = 0               À sizes()                ; While position to be inserted has not been found.                found=0                  ; If there is another item in the list, go to it.                  À(sizes())                    ; If the new item is bigger than the size to be inserted                    temp<Œ(sizes()\text)                     found=1                         ; Set flag for position found                      ; If there was an item before this one, i.e. new size must be inserted                     ; somewhere in the middle of the list                      À(sizes())                       ; Add new size to list and increase number of items in list                        À(sizes()) ! sizes()\text = Ý(temp)                       count = count +1                     "                       ; If not an item before this one, then the new font size                       ; must be inserted at the head of the list. Add item and                       ; increase number of fonts in list.                        À(sizes()) ! sizes()\text = Ý(temp)                       count = count +1                                                            "                   ; If not another item in list, then set flag to escape from loop,                   ; and then add an item to the (end of) the list, and increase                   ; number of items in list.                   found = temp                    À(sizes()) ! sizes()\text = Ý(temp)                   count = count +1                                  Á                                      Á           0,winlock                    ; Unlock window and restore pointer               þ! #DOS_FIB,*diskfib              þ dirlock                                 ; Unlock directory  ; * Attach list of size to listview and set integer gadget to first size ; * in list, or 30 if a CG font   Æ 0,lv_sizes,sizes()    À(sizes())     Æ 0,in_fsize,Œ(sizes()\text)   "     Æ 0,in_fsize,30         ; **************************************************************************** ; * Name        : readdrawer ; * Parameters  : drawer.s - the drawer that was previously selected ; * Returns     : String   - the drawer that was actually read ; * Description : Reads the font files from a drawer and fills up the lists ; **************************************************************************** 	.s readdrawer{drawer.s}    lv_avail, lv_sizes, lv_selec, st_sourc, st_fname, in_fsize    available(), sizes(), selected(),currentfont    3.s             prevdrawer                ; Previous drawer that was read in   3.s             filename                  ; Name of current file in directory   3.l             dirlock                   ; DOS Lock on directory   3.l             winlock                   ; Lock on window, for busy pointer + blocking input   3.FileInfoBlock *diskfib                  ; Information on current entry in directory   3.w             count                     ; Number of items added to list    ; Get name of previous drawer and new drawer from gadget   prevdrawer=drawer   drawer=Æ(0,st_sourc)    ; Try to get a DOS lock on directory   dirlock=þ
(&drawer,-2)    dirlock     *diskfib = þ (#DOS_FIB,0)      *diskfib        þ(dirlock,*diskfib)         ; If successfully locked directory and there is something in it,         ; block window from input/show busy pointer and get drawer name ready for use         winlock=(0)          Ü(drawer,1)<>":" B Ü(drawer,1)<>"/" ! drawer=drawer+"/"          ; Detach lists from listview gadgets then clear and reset lists         Æ 0,lv_avail         Æ 0,lv_sizes         Æ 0,lv_selec         À available()         À sizes()         À selected()          ;  While there are more entries in the directory, and the list is not full         ; List checking needs to be done this way, as if the item could be added,         ; but there are no more entries in directory then we would need to remove         ; last item in list (but we won't know which condition failed), so we         ; can't blindly delete an item from the list         ;  Count is always increased when an item should be added to the list,         ; even if it couldn't be (no memory etc), so that the loop will always         ; eventually quit.          (þ(dirlock,*diskfib)<>0 B count<#FONTNUMS)           count = count + 1                         ; Increase number of items in list            À(available())                   ; Add an item to the list              *diskfib\fib_DirEntryType<0           ; If the directory entry is a file               filename=Ú$(&*diskfib\fib_FileName)                Ü(Ü(filename,5))=".FONT" ; ending in `.font'                 available()\text = Ü(filename,5)  ; Store filename without .font extension               "                 À available()                ; Otherwise delete item added                                                ; to list             "               À available()                                   Á                                        ; Move onto next item          ;  If there are any items in the list, sort them, put the first font         ; into the gadget and update the list for sizes.         ;  Else, blank out the font and size gadgets          À(available())            available(),/.list,2           Æ 0,st_fname,available()\text           currentfont=available()\text           updatesizes{}         "           Æ 0,st_fname,""           Æ 0,in_fsize,0                    ; Attach lists to listview gadgets and leave window free for input         Æ 0,lv_avail,available()         Æ 0,lv_sizes,sizes()         Æ 0,lv_selec,selected()          0,winlock               þ! #DOS_FIB,*diskfib         "     ; If couldn't open new drawer, set to last one read     drawer=prevdrawer        ; Unlock any DOS locks that may exist and return name of drawer read   þ dirlock   	  drawer  	   ; **************************************************************************** ; * Name        : load_font ; * Parameters  : drawer.s - the drawer to look for the font in. ; * Returns     : None ; * Description : Loads the font in the string gadget at the size specified ; *               in the integer gadget. ; ****************************************************************************  load_font{drawer.s}    st_fname,in_fsize                        ; Gadget IDs for name and size   3.s fontname                              ; Name of font to load   3.w fontsize                              ; Size of font to load   3.l winlock                               ; Used in blocking input to window    ; Get font name and size from gadgets, and free old font displayed   fontname=Æ(0,st_fname)   fontsize=Æ(0,in_fsize)    Ú.l(ž Ã(1)) <> 0 ! + Ã 1    ; If there is a font name and size to load    (fontname<>"" B fontsize>0)      fontsize>128       fontsize=128       Æ 0,in_fsize,fontsize           ; Block user input while loading the font     winlock=(0)     Ã 1,drawer+fontname+".font",fontsize      0,winlock         ; **************************************************************************** ; * Name        : drawfont ; * Parameters  : *e.env - Address of environment descriptors. ; * Returns     : None ; * Description : Erases the previous font, draws the new font, redraws all ; *               gadgets that may have been affected and draws a box for the ; *               font. ; ****************************************************************************  drawfont{*e.env}   3.w gadheight                             ; Height of each gadget   3.s text                                  ; Text to preview   3.Rectangle   myrect                      ; Bounds of a rectangle which encloses preview   3.Region      *new_region, *old_region    ; Two regions, used for clipping the text to the Rectangle   3._RastPort   *mycliprp                   ; The rastport with the clipping region set up in it   3.TextFont    *myfont                     ; Font to be previewed   3.DrawInfo    *sdi                        ; Screen draw info    ; Height of gadgets is used in finding bounds of rectangle and text to preview   gadheight=Ú.w(ž Ã(0)+4)+ 6   text = "1234 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"    ; Work out upper and lower bounds of rectangle   y1=53*(*e\_window\Height - *e\_window\BorderBottom - *e\_window\BorderTop)/100   y2=(*e\_window\Height - *e\_window\BorderBottom - *e\_window\BorderTop)-2*gadheight-10    y2<y1+15 ! y1=y2-15    ; If there is a valid font to be previewed    Ú.l(ž Ã(1)+8)<>0     ; Set the font in the rastport, set up rectangle and clipped rastport     Å
 1     *mycliprp = *e\_window\RPort     myrect\MinX = *e\_window\BorderLeft + 4     myrect\MinY = *e\_window\BorderTop + y1     myrect\MaxX = *e\_window\Width - *e\_window\BorderRight - 4     myrect\MaxY = myrect\MinY + y2 - y1      ; Create a new region, and if successfully created, set the bounds of it (from rectangle)     *new_region = ÿR      *new_region        ÿQ(*new_region, &myrect)         ; Get screen draw info, font and old clipping region in window while installing         ; new clipping region.         *sdi=ÿí(*e\_screen)         *myfont = *e\_window\RPort\Font         *old_region = ô(*e\_window\WLayer, *new_region)          ; ALL graphics.library COMMANDS ARE NOW CLIPPED!!         ; Clear rastport to a solid colour         ÿ# *mycliprp, Ú.w(*sdi\dri_Pens + /.w * #BACKGROUNDPEN)          ; Set colour of text and display it in correct position         ÿ5 *mycliprp, Ú.w(*sdi\dri_Pens + /.w * #TEXTPEN)         ÿ$ *mycliprp, myrect\MinX, (myrect\MaxY + myrect\MinY + *myfont\tf_YSize)/2 ; + *myfont\tf_Baseline/2         ÿ *mycliprp, &text, Ü(text)          ; Draw a bevelled box at the limits of the clipping region         ÿ5 *mycliprp, Ú.w(*sdi\dri_Pens + /.w * #SHADOWPEN)         ÿ$ *mycliprp, myrect\MinX, myrect\MaxY         ÿ% *mycliprp, myrect\MinX, myrect\MinY         ÿ% *mycliprp, myrect\MaxX, myrect\MinY         ÿ5 *mycliprp, Ú.w(*sdi\dri_Pens + /.w * #SHINEPEN)         ÿ$ *mycliprp, myrect\MaxX, myrect\MinY         ÿ% *mycliprp, myrect\MaxX, myrect\MaxY         ÿ% *mycliprp, myrect\MinX, myrect\MaxY          ; Restore old clipping region and free the newer one.         *new_region = ô(*e\_window\WLayer, *old_region)         ÿî *e\_screen,*sdi:*sdi=0               ÿU *new_region       *new_region = 0               ; **************************************************************************** ; * Name        : checkforfont ; * Parameters  : None ; * Returns     : None ; * Description : Checks that the font in the string gadget is actually in the ; *               available fonts list. Used when the user types a fontname or ; *               and presses return or when the select font gadget is pressed ; *               without return being pressed. ; **************************************************************************** 	.w checkforfont{}    available(),selected(),sizes()           ; See descriptions at top    st_fname,currentfont,options,environ     ; See descriptions at top   3.s fontname                              ; Name of font to find in list   3.w found                                 ; Flag to show if found    ; Get font name from gadget, move to start of list and clear flag.   fontname=Æ(0,st_fname)   À available()   found=Œ    ; Go through each item in list. If the fontname is in the list,   ; set the flag and put the exact case match for the font in the gadget.   ; If this this is a different font from the current font, update the   ; size list and load and display the font.    À(available())      Ü(available()\text)=Ü(fontname)       found=Œ       fontname=available()\text       Æ 0,st_fname,fontname        currentfont<>fontname         updatesizes{}         currentfont=fontname         load_font{options\drawer}:drawfont{&environ}                 Á   	  found  	   ; **************************************************************************** ; * Name        : selectone ; * Parameters  : None ; * Returns     : None ; * Description : Adds the current font to the selected list, unless it is ; *               already there, in which case it is removed. ; ****************************************************************************  selectone{}    available(),selected(),sizes()    lv_avail,lv_sizes,lv_selec,st_fname,in_fsize,currentfont   3.s fontname   3.w found    found=checkforfont{}    found=Œ     fontname=Æ(0,st_fname)     À selected()     Æ 0,lv_selec     found=Œ      (À(selected()) B found=Œ)        selected()\text=fontname         À selected()         found=Œ             Á       found=Œ        À(selected())         selected()\text=fontname                     selected(),/.list,2     Æ 0,lv_selec,selected()   "     Æ 0,st_fname,currentfont         ; **************************************************************************** ; * Name        : depthdir ; * Parameters  : dirname.s - Full path of directory to create ; * Returns     : Word - True for directory existing after call to this ; *                      statement, false for not existing. ; * Description : Recursively creates directories to any depth (or checks that ; *               they exist). ; **************************************************************************** 	.w depthdir{dirname.s}   3.w i   3.w count    Ü(Ü(dirname,Ü("/")),1)=":"     i=Ü(Ü(dirname,Ü("/")))   "     dirname=Ü(dirname,Ü("/"))     i=Ü(dirname)       Ý ""    (Ü(dirname,i,1)<>"/" B i<>0) ;    Print Mid$(dirname,i,1)     i=i-1     count+1   Á    count>0      depthdir{Ü(dirname,i)}       	  (Ÿ(dirname)  ¶(dirname))     "       	  0         "     	  -1      	   ; **************************************************************************** ; * Name        : mycopyfile ; * Parameters  : source.s ; *               dest.s ; * Returns     : true for success, false for failure ; * Description : Checks if the source file is there before copying because ; *               dumb Elmore lib CopyFile crashes big style if it can't find ; *               the source file ; **************************************************************************** 	.w mycopyfile{sourcefile$, destfile$}   3.l   sourcelock   3.w   retval    sourcelock = þ
(&sourcefile$, #ACCESS_READ)    sourcelock     retval = ¶(sourcefile$, destfile$)     þ lock   "     retval = Œ        	  retval  	    ; **************************************************************************** ; * Name        : copyfonts ; * Parameters  : source.s - Full path to source directory ; *               dest.s   - Full path of destination directory ; * Returns     : None ; * Description : Copies the fonts (in the selected fonts list) from the source ; *               directory to the destination directory. ; ****************************************************************************  copyfonts{source.s, dest.s}    available(),selected()   3.l winlock,dirlock   3.s file_1, file_2   3.FileInfoBlock *diskfib   3.s fontsize,drawer   3.w found     Ü(dest,1)<>":" B Ü(dest,1)<>"/" ! dest=dest+"/"    depthdir{dest}     À selected()     winlock=(0)     *diskfib = þ (#DOS_FIB,0)      *diskfib        À(selected())         À available()         found = Œ          found=Œ            Ü(available()\text) <> Ü(selected()\text)             À available()           "             found = Œ                     Á          file_1=source+available()\text         file_2=dest+available()\text         part1=mycopyfile{file_1+".font",file_2+".font"}          drawer=file_1         dirlock=þ
(&drawer,-2)          dirlock           part1=part1 B depthdir{file_2}            part1              þ(dirlock,*diskfib)                þ(dirlock,*diskfib)<>0                  *diskfib\fib_DirEntryType<0                   fontsize=Ú$(&*diskfib\fib_FileName)                   part1=part1 B mycopyfile{file_1+"/"+fontsize,file_2+"/"+fontsize}                                 Á                                    "           part1=part1 B mycopyfile{file_1+".otag",file_2+".otag"}           part1=part1 B depthdir{dest+"_bullet_outlines"}            part1             file_1=source+"_bullet_outlines/"+available()\text+".type"             file_2=dest+"_bullet_outlines/"+available()\text+".type"             part1=part1 B mycopyfile{file_1,file_2}           "             Ÿ dest+available()\text+".otag"                               þ dirlock           part1=0 ! Ÿ dest+available()\text+".font"       Á       þ! #DOS_FIB,*diskfib            0,winlock         ; **************************************************************************** ; * Name        : deletefonts ; * Parameters  : source.s - Full path to source directory ; * Returns     : None ; * Description : Deletes the fonts (in the selected font list) from the ; *               source directory. ; ****************************************************************************  deletefonts{source.s}    rt_taglist(),modified    available(),selected()   3.l winlock   3.s fontsize,drawer   3.l dirlock   3.FileInfoBlock *diskfib     Ÿ(source)      (À(selected()) B ("Delete selected fonts."+Ü(10)+"Are you sure?","_Yes|_No",&rt_taglist(0)))       modified=1        Ü(source,1)<>":" B Ü(source,1)<>"/" ! source=source+"/"       winlock=(0)       *diskfib = þ (#DOS_FIB,0)        *diskfib         À selected()          À(selected())           À available()            (À(available()) B available()\text <> selected()\text)           Á           Ÿ source+available()\text+".font"            drawer=source+available()\text           dirlock=þ
(&drawer,-2)            dirlock              þ(dirlock,*diskfib)                þ(dirlock,*diskfib)<>0                  *diskfib\fib_DirEntryType<0                   fontsize=Ú$(&*diskfib\fib_FileName)                   Ÿ drawer+"/"+fontsize                                 Á                          "             Ÿ source+"_bullet_outlines/"+available()\text+".type"             Ÿ source+available()\text+".otag"                        þ dirlock           Ÿ drawer          Á         þ! #DOS_FIB,*diskfib                0,winlock               ; **************************************************************************** ; * Name        : showaguide ; * Parameters  : filename.l  - Pointer to null terminated string for name of ; *                             file to load ; *               agport.l    - Pointer to null terminated string for name of ; *                             AmigaGuide's port. ; *               basename.l  - Pointer to null terminated string (reason?) ; *               cmd.s       - Command for AmigaGuide, e.g. "LINK contents" ; *               pubscreen.l - Public screen that AmigaGuide is to open on. ; * Returns     : Word        - Error return code or true for success ; * Description : If AmigaGuide is already open it sends the command to it, ; *               but if AmigaGuide is not open, it gets opened and a copy of ; *               the command is taken so that it can be sent once AG opens. ; * ; *               I'd like to thank Eddy Carroll here, as this code has been ; *               mangled and Blitzed from Snoopdos. And its a very poor ; *               immitation, as I don't use OS Wait_ loops (but in a later ; *               release...) ; **************************************************************************** 	.w showaguide{filename.l,agport.l,basename.l,cmd.s,pubscreen.l}    AG_Context,AG_NewGuide,copycmd,AGPending    AGBase,AmigaGuideMask,rt_taglist()    ; Make sure that amigaguide.library is open. Not sure what happens if its   ; unavailable, as Blitz does lib stuff at startup, but it'll probably get   ; screwed before it gets here.    AGBase=0     AGBase=þÏ("amigaguide.library",34)      AGBase=0       dummy=("Unable to open amigaguide.library!"+Ü(10)+"No help is available.","_Ok",&rt_taglist(0))       	  0              ; If Amigaguide is already open (by us), but not on the same screen, then close it    (AG_Context B AG_NewGuide\nag_Screen<>pubscreen)     ü AG_Context     AG_Context=0     AmigaGuideMask=0        ; If Amigaguide has not been opened by us (or recently closed)    AG_Context=0     AG_NewGuide\nag_Lock    = 0                   ; Probably a lock on the directory of the file??     AG_NewGuide\nag_Name    = filename            ; Ahh, guide file to open     AG_NewGuide\nag_Screen    = pubscreen         ; Screen to open on     AG_NewGuide\nag_ClientPort  = agport          ; The message port we use to get signals from AG     AG_NewGuide\nag_BaseName  = basename          ; ??     AG_NewGuide\nag_Flags   = #HTF_CACHE_NODE     ; ??      ; Try to open an asynchronous version of Amigeguide (runs at same time)     AG_Context=ü(&AG_NewGuide,0)      ; If couldn't open it      AG_Context=0       dummy=("Error while opening AmigaGuide!"+Ü(10)+"No help currently available","_Ok",&rt_taglist(0))       	  0            ; Get the port signal bits and take a copy of the command we want to send it.     ; The reason for this is that Amigagude will take a while to     AmigaGuideMask=ü(AG_Context)     copycmd=cmd     AGPending=&copycmd     	  Œ       ü AG_Context,&cmd,0   	  Œ   	   ; **************************************************************************** ; * Name        : cleanupaguide ; * Parameters  : None ; * Returns     : None ; * Description : Resets all variables used for AmigaGuide and closes all ; *               resources associated with it. ; * ; *               I'd like to thank Eddy Carroll here, as this code has been ; *               mangled and Blitzed from Snoopdos. ; ****************************************************************************  cleanupaguide{}    AG_Context,AGBase,AmigaGuideMask    ; If Amigaguide is open, close it    AG_Context     ü AG_Context     AG_Context=0        ; If the amigaguide.library is open (by us), close it    AGBase     þ» AGBase     AGBase=0        ; Clear (Wait) signal mask, to ignore amigaguide function calls   AmigaGuideMask=0     ; **************************************************************************** ; * Name        : handleaguidemsgs ; * Parameters  : None ; * Returns     : None ; * Description : Checks the AmigaGuide messages and handles appropriately. ; *               (Used to send the command once AG has completed loading.) ; * ; *               I'd like to thank Eddy Carroll here, as this code has been ; *               mangled and Blitzed from Snoopdos. ; ****************************************************************************  handleaguidemsgs{}    AG_Context, AGBase, copycmd, AGPending, rt_taglist()    3.AmigaGuideMsg *agm                      ; Message recieved from Amigaguide   3.w             unloadhelp                ; Flag to show if we need to close amigaguide   3.s             error                     ; Error string from amigaguide    ; If the amigaguide.library and amigaguide are open    (AGBase B AG_Context)     ; Get the next amigaguide message and while it exists     *agm=ü(AG_Context)      *agm       ; Do some action based on the type of message        *agm\agm_Type          #ActiveToolID           ; Amigaguide has just been loaded, so send it the previously stored command            AGPending<>0             ü AG_Context,AGPending,0             AGPending=0                       #ToolCmdReplyID           ; Command has completed, but if agm_Pri_Ret field is set, an error occured            *agm\agm_Pri_Ret             ; If error is can't find file, then display error and set flag to unload amigaguide              *agm\agm_Sec_Ret=#HTERR_CANT_OPEN_DATABASE               error=error+"Unable to find help file (Viewfonts2.guide)."+Ü(10)               error=error+"If you want online help, the help file must"+Ü(10)               error=error+"be in the same directory as the program."               unloadhelp=1             "               ; Otherwise, display error from amigaguide               error="AmigaGuide error:"+Ü(10)               error=error+Ú$(ü(*agm\agm_Sec_Ret))                           dummy=(error,"_Ok",rt_taglist(0))             AGPending=0                       #ToolStatusID           ; Status message, if agm_Pri_Ret field is set, an error occured            *agm\agm_Pri_Ret             ; If error is can't find file, then display error and set flag to unload amigaguide              *agm\agm_Sec_Ret=#HTERR_CANT_OPEN_DATABASE               error=error+"Unable to find help file (Viewfonts2.guide)."+Ü(10)               error=error+"If you want online help, the help file must"+Ü(10)               error=error+"be in the same directory as the program."               unloadhelp=1             "               ; Otherwise, display error from amigaguide               error="AmigaGuide error:"+Ü(10)               error=error+Ú$(ü(*agm\agm_Sec_Ret))                           dummy=(error,"_Ok",rt_taglist(0))             AGPending=0                       #ShutdownMsgID           ; Amigaguide has done something and wants us to close it.            *agm\agm_Pri_Ret             ; If error is can't find file, then display error and set flag to unload amigaguide              *agm\agm_Sec_Ret=#HTERR_CANT_OPEN_DATABASE               error=error+"Unable to find help file (Viewfonts2.guide)."+Ü(10)               error=error+"If you want online help, the help file must"+Ü(10)               error=error+"be in the same directory as the program."               unloadhelp=1             "               ; Otherwise, display error from amigaguide               error="AmigaGuide error:"+Ü(10)               error=error+Ú$(ü(*agm\agm_Sec_Ret))                           dummy=(error,"_Ok",rt_taglist(0))             AGPending=0                            ; Reply to that message and get next one       ü	 *agm       *agm=ü(AG_Context)     Á      unloadhelp ! cleanupaguide{}         ; **************************************************************************** ; * Name        : menuhelp ; * Parameters  : *e.env - Viewfonts 2 environment stuff ; *               r.l    - The eventcode returned by Intuition ; * Returns     : String to pass to amigaguide (MUST match a @NODE xxx in guide) ; * Description :  Converts the text in the menus to something usable for a ; *               link in Amigaguide. ; * ; *               I'd like to thank Eddy Carroll here, as the ideas have been ; *               mangled and Blitzed from Snoopdos. ; **************************************************************************** 	.s menuhelp{*e.env,r.l}   3.s copycmd    ; Work out menu, item and subitem number from full number (returned by intuition)   mn.b=r&$1F   in.b=(r E 5)    in <> -1 ! in=in&$3F   sn.b=r E 11    ; If anything = -1 then it was not selected when help was pressed.    in<>-1      mn<>2       ; If menu was not Help menu, find the menu and item that caused       ; help message.       *mnu_ptr.Menu=*e\_imenus        i.w=1  mn         *mnu_ptr=*mnu_ptr\NextMenu              *itm_ptr.MenuItem=*mnu_ptr\_FirstItem        i=1  in         *itm_ptr=*itm_ptr\_NextItem               ; Get text from item and replace all spaces with _'s, allowing the       ; resulting string to be used as a link in an Amigaguide file.       *item_text.IntuiText=*itm_ptr\ItemFill       copycmd=Ú$(*item_text\IText)       copycmd="mnu_"+Ü(copycmd," ","_")     "       ; If it was help menu, then give specific help on something.        in          0  ; How to use help           copycmd="help"          1  ; ~~~~~~~~~~~~~~~           copycmd="mnu_"          2  ; Contents           copycmd="main"          3  ; Using Viewfonts           copycmd="using"                 "     ; If no menu was selected when Help was pressed, show standard "usage" help     copycmd="using"       	  copycmd  	   ; -------------------------- PROGRAM START ------------------------------- environ\execver=à                       ; Get version of exec  environ\execver<36 !                     ; Exit if using WB1.3 or less  =0 !                     ; Check for reqtools.library AGBase=findlibbase{"amigaguide.library"}   0                                   ; Direction to sort lists into (ascending) Í 0,?gtshape_data                      ; Extract shape data from program code  ; --------------------------- GADGET IDS ----------------------------- wb2lvfix=0  environ\execver<39 ! wb2lvfix=#FONTNUMS     ; Needed for WB2 listviews lv_avail = 0+wb2lvfix lv_sizes = 1+wb2lvfix*2 lv_selec = 2+wb2lvfix*3 st_fname = 3+wb2lvfix*3 in_fsize = 4+wb2lvfix*3 bu_selec = 5+wb2lvfix*3 st_sourc = 6+wb2lvfix*3 sh_sourc = 7+wb2lvfix*3 sh_destn = 8+wb2lvfix*3 st_destn = 9+wb2lvfix*3 bu_copyf =10+wb2lvfix*3 bu_delet =11+wb2lvfix*3  ; ------------------------COMMODITY STUFF --------------------------------  ¬(Ú$(?program),Ú$(?ptit),"Manages drawers of fonts")=0 ;  dummy=RTRequest("Viewfonts 2 already loaded","_Ok",&rt_taglist(2))       tooltypes{} options\helppath="PROGDIR:Viewfonts2.guide"  µ    µ >= 1      Ü(Ü(µ(1),5)) = ".font"       temp1 = Ü(µ(1),5)       modified = 0        Ü(temp1,Ü(temp1)-modified,1) <> "/" B Ü(temp1,Ü(temp1)-modified,1) <> ":"         modified + 1       Á       temp1 = Ü(temp1, modified)        options\drawer = Ü(µ(1),6)        Ü(options\drawer,1) <> "/" B Ü(options\drawer,1) <> ":"         options\drawer = Ü(options\drawer,1)       Á     "       temp1 = ""       options\drawer = µ(1)             Œ(µ(2)) > 0 ! modified = Œ(µ(2))         ¬(0,options\hotkey)=0   dummy=("Could not add hotkey","_Quit",&rt_taglist(2))       ; ----------------------- LOAD PREFERENCES ------------------------- ww=474:wh=235:wx=70:wy=11  Ÿ(0,"ENV:Viewfonts.prefs")   Ÿ 0   ww=Ü(Ý(2))   wh=Ü(Ý(2))   wx=Ü(Ý(2))   wy=Ü(Ý(2))   Ÿ 0   Ò
    wflags.l=#WFLG_SIZEGADGET+#WFLG_DRAGBAR+#WFLG_DEPTHGADGET+#WFLG_CLOSEGADGET+#WFLG_ACTIVATE  environ\execver>=39 ! wflags=wflags+#WFLG_NEWLOOKMENUS  environ\execver>=37 ! #IDCMP=#IDCMP+#IDCMP_MENUHELP  ; --------------------------- MAIN GUI LOOP ---------------------------  options\popup=0 ! quit_flag=hidegui{?program,options\iconify}  quit_flag=0   environ\_screen=getpubscreen{options\userpub}    environ\_screen=0     cleanupwin{&environ}            ÿŠ environ\_screen  ; Load screen font if possible   def_fontname=Ú$(environ\_screen\Font\ta_Name)   def_fontsize=environ\_screen\Font\ta_YSize    Ÿ("FONTS:"+def_fontname)=0     def_fontname="topaz.font"      def_fontsize<>9 ! def_fontsize=8       Ã 0,def_fontname,def_fontsize    min_ww = getminwidth{} + 72   min_wh = environ\_screen\Font\ta_YSize + 5*def_fontsize + 65    (min_ww>environ\_screen\Width  min_wh>environ\_screen\Height)     def_fontname="topaz.font"     def_fontsize=8     Ã 0,def_fontname,def_fontsize     min_ww = getminwidth{} + 72     min_wh = environ\_screen\Font\ta_YSize + 5*def_fontsize + 65        ww<min_ww ! ww=min_ww    wh<min_wh ! wh=min_wh  ; These two if loops sort out the dimensions and position of the window ; if they are not within the screen area    ww>environ\_screen\Width ! ww=environ\_screen\Width    wh>environ\_screen\Height ! wh=environ\_screen\Height    wx+ww>environ\_screen\Width ! wx=environ\_screen\Width-ww    wy+wh>environ\_screen\Height ! wy=environ\_screen\Height-wh    wtags(0)\ti_Tag=#WA_PubScreen,environ\_screen   wtags(1)\ti_Tag=#WA_DetailPen,0   wtags(2)\ti_Tag=#WA_BlockPen,1   wtags(3)\ti_Tag=#WA_IDCMP,#IDCMP   wtags(4)\ti_Tag=#WA_Flags,wflags   wtags(5)\ti_Tag=#WA_Title,?ptit   wtags(6)\ti_Tag=#WA_MinWidth,min_ww   wtags(7)\ti_Tag=#WA_MinHeight,min_wh   wtags(8)\ti_Tag=#WA_MaxWidth,environ\_screen\Width   wtags(9)\ti_Tag=#WA_MaxHeight,environ\_screen\Height   wtags(10)\ti_Tag=#WA_Left,wx   wtags(11)\ti_Tag=#WA_Top,wy   wtags(12)\ti_Tag=#WA_Width,ww   wtags(13)\ti_Tag=#WA_Height,wh   wtags(14)\ti_Tag=#TAG_END,#TAG_DONE    environ\execver>=37     wtags(14)\ti_Tag=#WA_MenuHelp,Œ     wtags(15)\ti_Tag=#TAG_END,#TAG_DONE        Í 0,1   » 1,1,(Ú.w(ž Ã(0)+4)+6)/14    Å #IDCMP   ÅE 0,wflags,Ú$(?ptit)+" <"+options\hotkey+">",&wtags(0)   environ\_window=Ú.l(ž Å(0))   Å 0    rt_taglist(1)\ti_Tag=#RT_Window,environ\_window   environ\_visual = ö(environ\_screen,0)   gtmenus{?MENUDEF,&environ}   gadgets{&environ, &options}   ÿš environ\_window,environ\_imenus   options\drawer=readdrawer{options\drawer}     temp1 <> "" ! currentfont=temp1 ; If temp1 is not empty then use it as startup font    Æ 0,st_sourc,options\drawer   Æ 0,st_fname,currentfont     checkforfont{}=0      À(available())       Æ 0,st_fname,available()\text       updatesizes{}     "       Æ 0,st_fname,""       Æ 0,in_fsize,0           currentfont=Æ(0,st_fname)         temp1 <> "" ! Æ 0,in_fsize,modified   temp1 = ""                                      ; Make sure this font is only used at startup   modified=0   load_font{options\drawer}:drawfont{&environ}    (environ\_window B quit_flag=0)      ; Collect messages, needed to do it like this because I didn't know     ; how to use Wait_, and that would mean converting everything to OS     ; functions. In a future release...     »       þ 3       ev=Å       ce=¬        AmigaGuideMask ! handleaguidemsgs{}     Œ (ev  ce)      ; If hotkey is hit (when window is open) bring it to front.      ¬=0       ÿŠ environ\_screen       ÿ° environ\_window       ÿÇ environ\_window             ev        #IDCMP_NEWSIZE         gadgets{&environ, &options}         drawfont{&environ}         #IDCMP_GADGETUP          Å            lv_avail             À available()              i=0  Å@               À available()                           currentfont<>available()\text               Æ 0,st_fname,available()\text               currentfont=available()\text               updatesizes{}               load_font{options\drawer}:drawfont{&environ}                           lv_sizes             À sizes()              i=0  Å@               À sizes()                          Æ 0,in_fsize,Œ(sizes()\text)             load_font{options\drawer}:drawfont{&environ}             lv_selec             À selected()              i=0  Å@               À selected()                          À available()              (À(available()) B available()\text<>selected()\text)             Á              currentfont<>available()\text               Æ 0,st_fname,selected()\text               currentfont=available()\text               updatesizes{}               load_font{options\drawer}:drawfont{&environ}                           bu_selec             selectone{}             st_sourc              (options\drawer<>Æ(0,st_sourc)  modified=1)               options\drawer=readdrawer{options\drawer}               modified=0               Æ 0,st_sourc,options\drawer               load_font{options\drawer}:drawfont{&environ}                           sh_sourc              getdrawer{st_sourc}=-1                (options\drawer<>Æ(0,st_sourc)  modified=1)                 options\drawer=readdrawer{options\drawer}                 modified=0                 Æ 0,st_sourc,options\drawer                 load_font{options\drawer}:drawfont{&environ}                                           bu_delet             Æ 0,st_sourc,options\drawer             deletefonts{options\drawer}             options\drawer=readdrawer{options\drawer}             load_font{options\drawer}:drawfont{&environ}             st_fname              checkforfont{}=Œ               load_font{options\drawer}:drawfont{&environ}                           in_fsize             load_font{options\drawer}:drawfont{&environ}             bu_copyf             Æ 0,st_sourc,options\drawer             copyfonts{options\drawer,Æ(0,st_destn)}             st_destn            sh_destn             dummy=getdrawer{st_destn}                   #IDCMP_MENUPICK          Å            #MID_PROJECT              Å                #MID_ABOUT                 dummy=(Ú$(?ptit)+Ú$(?abouttext),"_More",&rt_taglist(0))                 dummy=(Ú$(?thnxtext),"_Ok",&rt_taglist(0))                 #MID_HIDE                 ww=environ\_window\Width                 wh=environ\_window\Height                 wx=environ\_window\LeftEdge                 wy=environ\_window\TopEdge                 cleanupwin{&environ}                 quit_flag=hidegui{?program,options\iconify}                 #MID_QUIT                 ww=environ\_window\Width                 wh=environ\_window\Height                 wx=environ\_window\LeftEdge                 wy=environ\_window\TopEdge                 quit_flag=1                           #MID_FONTS              Å                #MID_SELALL                 Æ 0,lv_selec                 À selected()                 À available()                  À(available())                    À(selected())                     selected()\text=available()\text                                     Á                 Æ 0,lv_selec,selected()                 #MID_UNSELALL                 Æ 0,lv_selec                 À selected()                 Æ 0,lv_selec,selected()                 #MID_READDRAW                 options\drawer=readdrawer{options\drawer}                 Æ 0,st_sourc,options\drawer                 load_font{options\drawer}:drawfont{&environ}                 #MID_COPYFONT                 Æ 0,st_sourc,options\drawer                 copyfonts{options\drawer,Æ(0,st_destn)}                #MID_DELETFNT                 Æ 0,st_sourc,options\drawer                 deletefonts{options\drawer}                 options\drawer=readdrawer{options\drawer}                 load_font{options\drawer}:drawfont{&environ}                            #MID_HELP              Å                #MID_HTUH                 dummy=showaguide{&options\helppath,?AG_PName,?program,"LINK help",environ\_screen}                #MID_CONTENTS                 dummy=showaguide{&options\helppath,?AG_PName,?program,"LINK contents",environ\_screen}                #MID_USING                 dummy=showaguide{&options\helppath,?AG_PName,?program,"LINK using",environ\_screen}                                 #IDCMP_CLOSEWINDOW         ww=environ\_window\Width         wh=environ\_window\Height         wx=environ\_window\LeftEdge         wy=environ\_window\TopEdge         cleanupwin{&environ}         quit_flag=hidegui{?program,options\iconify}         #IDCMP_INTUITICKS         #IDCMP_RAWKEY          Å@=$5F                          ; HELP is pressed           dummy=showaguide{&options\helppath,?AG_PName,?program,"LINK help",environ\_screen}                   #IDCMP_VANILLAKEY          Ü(Ü(Å@))            "A"; A, available fonts             Æ 0,st_fname             "C"; C, copy fonts             highlight{bu_copyf}             copyfonts{options\drawer,Æ(0,st_destn)}             "D"; D, delete fonts             highlight{bu_delet}             deletefonts{options\drawer}             options\drawer=readdrawer{options\drawer}             load_font{options\drawer}:drawfont{&environ}             "E"; E, dest string             Æ 0,st_destn             "F"; F, select current font             highlight{bu_selec}             selectone{}             "I"; I, sizes             Æ 0,in_fsize             "S"; S, source string             Æ 0,st_sourc                   #IDCMP_MENUHELP         dummy=showaguide{&options\helppath,?AG_PName,?program,"LINK "+menuhelp{&environ,Å@},environ\_screen}             cx=¬      cx        ¬         cleanupwin{&environ}         ¬         ww=environ\_window\Width         wh=environ\_window\Height         wx=environ\_window\LeftEdge         wy=environ\_window\TopEdge         cleanupwin{&environ}         quit_flag=hidegui{?program,options\iconify}         ¬         ÿŠ environ\_screen         ÿ° environ\_window         ÿÇ environ\_window         ¬         ww=environ\_window\Width         wh=environ\_window\Height         wx=environ\_window\LeftEdge         wy=environ\_window\TopEdge         quit_flag=1          Á Á  ; ------------------------------ SAVE PREFS ------------------------  Ÿ(0,"ENVARC:Viewfonts.prefs")   Ÿ 0   Ý Ü(ww),Ü(wh),Ü(wx),Ü(wy)   Ÿ 0   Ò "   dummy=("Could not save prefs to ENVARC:","_Ok",&rt_taglist(2))     Ÿ(0,"ENV:Viewfonts.prefs")   Ÿ 0   Ý Ü(ww),Ü(wh),Ü(wx),Ü(wy)   Ÿ 0   Ò "   dummy=("Could not save prefs to ENV:","_Ok",&rt_taglist(2))    bigerror: cleanupwin{&environ} cleanupaguide{} À available()                           ; Clear and reset lists À sizes() À selected()    ; ---------------------------- DATA BLOCKS -------------------------- ' ptit:%.b "Viewfonts v2.02 ",169," David McMinn",0 program:%.b "Viewfonts 2",0 AG_PName:%.b "VF2_Help",0 MNU0:%.b "Project",0 MNU1:%.b "?",0,"About",0 MNU2:%.b "H",0,"Hide",0 MNU3:%.b "Q",0,"Quit",0 MNU4:%.b "Fonts",0 MNU5:%.b "S",0,"Select all",0 MNU6:%.b "U",0,"Unselect all",0 MNU7:%.b "R",0,"Read drawer",0 MNU8:%.b "C",0,"Copy fonts",0 MNU9:%.b "D",0,"Delete fonts",0 MNUA:%.b "Help",0 MNUB:%.b "How to use help",0 MNUC:%.b "Contents",0 MNUD:%.b "Using Viewfonts",0 '  MENUDEF %.b #NM_TITLE: %.l MNU0,0        : %.w 0: %.l 0,#MID_PROJECT %.b #NM_ITEM : %.l MNU1+2,MNU1   : %.w 0: %.l 0,#MID_ABOUT %.b #NM_ITEM : %.l MNU2+2,MNU2   : %.w 0: %.l 0,#MID_HIDE %.b #NM_ITEM : %.l #NM_BARLABEL,0: %.w 0: %.l 0,0 %.b #NM_ITEM : %.l MNU3+2,MNU3   : %.w 0: %.l 0,#MID_QUIT  %.b #NM_TITLE: %.l MNU4,0        : %.w 0: %.l 0,#MID_FONTS %.b #NM_ITEM : %.l MNU5+2,MNU5   : %.w 0: %.l 0,#MID_SELALL %.b #NM_ITEM : %.l MNU6+2,MNU6   : %.w 0: %.l 0,#MID_UNSELALL %.b #NM_ITEM : %.l MNU7+2,MNU7   : %.w 0: %.l 0,#MID_READDRAW %.b #NM_ITEM : %.l MNU8+2,MNU8   : %.w 0: %.l 0,#MID_COPYFONT %.b #NM_ITEM : %.l MNU9+2,MNU9   : %.w 0: %.l 0,#MID_DELETFNT  %.b #NM_TITLE: %.l MNUA,0        : %.w 0: %.l 0,#MID_HELP %.b #NM_ITEM : %.l MNUB,0        : %.w 0: %.l 0,#MID_HTUH %.b #NM_ITEM : %.l #NM_BARLABEL,0: %.w 0: %.l 0,0 %.b #NM_ITEM : %.l MNUC,0        : %.w 0: %.l 0,#MID_CONTENTS %.b #NM_ITEM : %.l MNUD,0        : %.w 0: %.l 0,#MID_USING %.b #NM_END  : %.l 0,0           : %.w 0: %.l 0,0 '  ERR0:%.b "Could not copy font",10,0  abouttext: %.b 10,10 %.b "Registered to everybody",10,10 %.b "Contact me at:",10,10 %.b "d.mcminn@eee.rgu.ac.uk",0  thnxtext: %.b "Thanks go to:",10,10 %.b "Acid for Blitz Basic II",10,10 %.b "Eddy Carroll for the",10 %.b "freely distributable",10 %.b "Snoopdos3 source",10,10 %.b "Peter Traskalik",10 %.b "and Mark Tiffany",10 %.b "for all their help",0 version:%.b 0,"$VER: Viewfonts v2.02 (19/11/98)",0 '  gtshape_data:* "browse.shp" 