home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 16 / 16.iso / w / w023 / 2.ddi / VESAPOC.001 / ALLFONTS.POC next >
Encoding:
Text File  |  1990-11-06  |  1.7 KB  |  112 lines

  1. #define TRUE 1
  2. #define FALSE 0
  3. #define Success 0
  4. #define ESC 0x1b
  5.  
  6. int sw,sh;
  7. char *abcs =
  8.     "abcdefghijklmnopqrstuvwxyz"
  9.     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  10.     "1234567890"
  11.     "!@#$%^&*()_-+={[]}\\|;:'\",<.>/?";
  12. char ofname[80];
  13. char odir[80];
  14.  
  15. see_font(char *name)
  16. {
  17. int fh;
  18. int occolor;
  19.  
  20. fh = FontHeight()+2;
  21. occolor = GetColor();
  22. Clear();
  23. Box(0,0,4+StringWidth(name),fh);
  24. SetColor(0);
  25. Text(2,2,name);
  26. SetColor(occolor);
  27. WordWrap(0, fh, sw, sh-fh, abcs);
  28. }
  29.  
  30. display_font(char *name)
  31. {
  32. if (LoadFont(name) < Success)
  33.     return;
  34. see_font(name);
  35. }
  36.  
  37. do_all_fonts(Boolean step)
  38. {
  39. char font_dir[80];
  40. char font_name[80];
  41. char **flist;
  42. int fcount;
  43. int i;
  44. int x,y,l,r,k;
  45.  
  46. GetFontDir(font_dir);
  47. SetDir(font_dir);
  48. if ((fcount = DirList(&flist, "*.*", 0)) <= Success)
  49.     return;
  50. for (i=0; i<fcount; i++)
  51.     {
  52.     display_font(flist[i]);
  53.     if (step)
  54.         {
  55.         WaitClick(&x,&y,&l,&r,&k);
  56.         if (r || (k&0xff) == ESC)
  57.             break;
  58.         }
  59.     }
  60. FreeDirList(&flist);    
  61. }
  62.  
  63. char *choices[] = 
  64.     {
  65.     "Step through fonts",
  66.     "Run through fonts",
  67.     "See current font",
  68.     "Font Requestor",
  69.     "Exit",
  70.     };
  71.  
  72. main()
  73. {
  74. Screen *oscreen;
  75. ErrCode err;
  76.  
  77. GetSize(&sw,&sh);
  78. if ((err = AllocScreen(&oscreen,sw,sh)) < Success)
  79.     {
  80.     Qerror(err, "Can't save current screen");
  81.     return;
  82.     }
  83. CopyScreen(GetPicScreen(), oscreen);
  84. GetFontName(ofname);
  85. GetDir(odir);
  86. for (;;)
  87.     {
  88.     switch (Qmenu(choices, 5, "Quick font tester"))
  89.         {
  90.         case 0:
  91.             goto OUT;
  92.         case 1:
  93.             do_all_fonts(TRUE);
  94.             break;
  95.         case 2:
  96.             do_all_fonts(FALSE);
  97.             break;
  98.         case 3:
  99.             see_font(ofname);
  100.             break;
  101.         case 4:
  102.             Qfont();
  103.             break;
  104.         }
  105.     }
  106. OUT:
  107. SetDir(odir);
  108. LoadFont(ofname);
  109. CopyScreen(oscreen,GetPicScreen());
  110. FreeScreen(&oscreen);
  111. }
  112.