home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 432b.lha / EzLib / doc / getfont.doc < prev    next >
Encoding:
Text File  |  1990-11-11  |  2.2 KB  |  65 lines

  1. FUNCTION   getfont()   - open a disk font for use.
  2.  
  3.    struct TextFont *getfont(name size)
  4.               char *name;
  5.               int size;
  6.  
  7.     Getfont() gives you easy access to the disk based fonts of the Amiga.
  8. All you have to do is pass the name (a character string) of the font and
  9. the size you would like.  If opening the font succeeds, you will be able to
  10. immediately SetFont(rp, text_font) in your current window and use it from
  11. then on (with the Text() function).  This function returns NULL if anything
  12. fails.
  13.  
  14.     The name you pass to getfont() can have a ".font" extension or not.  If
  15. it doesn't, then it will be appended.  Also be aware that if you specify a
  16. full pathname for name, that font need NOT be in the current FONTS:
  17. directory.  This is a little known but true fact.
  18.  
  19.     Size should simply be the point size of the font you want.    For example
  20. if you want Times 17, you would use size == 17.
  21.  
  22.     To open a font called "helvetica" in a 23 point size you would do this:
  23.  
  24.     struct Window *wind;    /* assume we opened it earlier */
  25.     struct TextFont *tf;
  26.  
  27.     /* open the font and error check the result */
  28.     tf = getfont("helvetica", 23);
  29.     if (tf == NULL)
  30.       no_font();
  31.  
  32.     SetFont(wind->RPort, tf);    /* from now on we can use the font */
  33.  
  34.       .....      /* do other stuff */
  35.  
  36.     CloseFont(tf);           /* do this BEFORE calling killwindow() */
  37.  
  38.  
  39. NOTE : You should call CloseFont() before calling killwindow().  This will
  40.        prevent fonts from being kept in memory unnecessarily.  It is best
  41.        if you can call CloseFont() as soon as you are done with the font.
  42.        This prevents wasting memory.
  43.  
  44.  
  45.     Essentially, there are 3 steps to using a disk font.  Open the font
  46. with getfont().  Then call SetFont() for the window/screen you wish to use
  47. the font on.  Then use the graphics library text routines for whatever you
  48. want.  Finally call CloseFont() when you are done.  Nice and easy.
  49.  
  50.  
  51.  
  52. TODO : should probably be some sort of resource tracking so that you don't
  53.        have to call CloseFont().
  54.  
  55.        would be nice if there was a single call you could make to open and
  56.        set the font for a window (and then not have to worry about after
  57.        that because of the item above).
  58.  
  59.  
  60. BUGS : ha! c'mon -(;-)    (smiley with a mohawk!)
  61.  
  62. SEE ALSO : makewindow(); makescreen();
  63.  
  64.  
  65.