home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / fasttext.lha / Ftest.c < prev    next >
C/C++ Source or Header  |  2000-01-30  |  3KB  |  133 lines

  1. /*
  2.  * FastText() text demo by Darren M. Greenwald
  3.  * Copyright 1987 - FastText() REV 3.0
  4.  *
  5.  * "C" example of use.
  6.  * 
  7.  * You MUST assemble, and link in the FastText file in order for this to
  8.  * work!!!
  9.  * 
  10.  * Note that all work was done using Manx 3.6
  11.  * I leave it up to you to make adjustments as needed to work with your
  12.  * compiler/assembler.
  13.  *
  14.  * TURN OFF any text speed up programs if you really want to test this
  15.  * program right.  Programs such BLITZFONTS, and MicroSmith's FastFonts
  16.  * only speed up 8 bit wide fonts.  These routines allow you to gain
  17.  * a significant speed up for all size fonts, and the most speed up for
  18.  * 8 bit wide fonts.  Font widths other then 8 bits wide will vary in
  19.  * speed.  Thinner fonts will be drawn more quickly then wider fonts, but
  20.  * you can rest assured that the FastText() routines draw text faster then
  21.  * Text() - generally MUCH faster.
  22.  *
  23.  * If the font cannot be drawn faster (e.g., too wide, too thin, PROP
  24.  * font), then Text() is automatically called.
  25.  * 
  26.  */
  27.  
  28. #include <exec/types.h>
  29. #include <intuition/intuition.h>
  30. #include <exec/memory.h>
  31.  
  32. #define REV 0L
  33. #define SIZE 640L
  34.  
  35. struct IntuitionBase *IntuitionBase = NULL;
  36. struct GfxBase *GfxBase = NULL;
  37. struct Window *Window = NULL;
  38. struct RastPort *rp;
  39. struct Window *OpenWindow();
  40. void *OpenLibrary();
  41.  
  42. struct NewWindow NewWindow =
  43.    { 0,0,640,200,0,1,
  44.      CLOSEWINDOW,ACTIVATE|BORDERLESS|WINDOWDEPTH|WINDOWCLOSE|SMART_REFRESH,
  45.      NULL,NULL,
  46.      (UBYTE *)"FastText Demo Rev 3.0 - Close me!",
  47.      NULL,NULL,0,0,0,0,WBENCHSCREEN
  48.    };
  49.  
  50. void Cleanup();
  51.  
  52.  
  53. void main()
  54. {
  55.  
  56. ULONG MaxRows,fonthght,pixrow,i,j;
  57.  
  58.    IntuitionBase = (struct IntuitionBase *)
  59.       OpenLibrary("intuition.library",REV);
  60.    if(IntuitionBase == NULL) Cleanup();
  61.  
  62.    GfxBase = (struct GfxBase *)
  63.       OpenLibrary("graphics.library",REV);
  64.    if(GfxBase == NULL) Cleanup();
  65.  
  66.    Window = (struct Window *)
  67.       OpenWindow(&NewWindow);
  68.    if(Window == NULL) Cleanup();
  69.  
  70.    rp = Window->RPort;
  71.  
  72.  
  73. /*
  74.  * Wait till the close us down cause we are to lazy to mess with gadgets,
  75.  * or menus!
  76.  */
  77.  
  78.    Wait(1L<<Window->UserPort->mp_SigBit);
  79.  
  80.    SetAPen(rp,1L);
  81.    SetBPen(rp,0L);
  82.  
  83.    InitFastText(rp->Font); /* You could check for a TRUE/FALSE return */
  84.    
  85.       pixrow=32L;
  86.  
  87.       fonthght=(ULONG)rp->Font->tf_YSize;
  88.       MaxRows=(Window->Height-pixrow)/fonthght;
  89.  
  90.       SetWindowTitles(Window,"Drawing via Text()",NULL);
  91.  
  92.       for(i=1;i<MaxRows;i++)  /* do maximum # of times possible */
  93.       {
  94.          for(j=1;j<200;j++)   /* redraw line 300 times per row */
  95.          {
  96.             Move(rp,j+4L,pixrow);
  97.             Text(rp," This is 36 characters of SLOW text!",36L);
  98.          }
  99.          pixrow+=fonthght;
  100.       }
  101.  
  102. dox:  pixrow=32L;
  103.  
  104.       SetWindowTitles(Window,"Drawing via FastText()",NULL);
  105.  
  106.       for(i=1;i<MaxRows;i++)  /* do maximum # of times possible */
  107.       {
  108.          for(j=1;j<200;j++)   /* redraw line 300 times per row */
  109.          {
  110.             Move(rp,j+4L,pixrow);
  111.             FastText(rp," This is 36 characters of FAST text!",36L);
  112.          }
  113.          pixrow+=fonthght;
  114.       }
  115.  
  116.  
  117.    Cleanup();
  118. }
  119.  
  120. void Cleanup()
  121. {
  122.    FreeFastText();
  123.  
  124.    if(Window)           CloseWindow(Window);
  125.  
  126.    if(GfxBase)          CloseLibrary(GfxBase);
  127.    if(IntuitionBase)    CloseLibrary(IntuitionBase);
  128.  
  129.    exit(0L);
  130. }
  131.  
  132.  
  133.