home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / m / m242 / 3.ddi / DEMOS1.ZIP / VIEW_VEC.C < prev   
Encoding:
C/C++ Source or Header  |  1989-10-16  |  3.9 KB  |  151 lines

  1. #include "stdio.h"
  2. #include "eg_proto.h"
  3.  
  4. void main(argc,argv)
  5. int argc;
  6. char *argv[];
  7. {
  8.     int recs,j,i,col,row,descender,w,h,base_line;
  9.     int char_color,line_color;
  10.     long bytes;
  11.     float size;
  12.     char ptr[1000],t[80],font[80];
  13.     struct vfont *fk;
  14.     struct egstatus s;
  15.     int mode,dev,rot;
  16.     int scale;
  17.     int height,width;
  18.     float f,ff;
  19.     int option;
  20.  
  21.     if(argc != 2){    
  22.       printf("Calling Sequence is: VIEW \"NAME\"\r\n");
  23.       exit(0);
  24.     }
  25.     
  26.     printf("\nSelect a vector font option :\n");
  27.     printf("     0 - Show font character set (option to scale).\n");
  28.     printf("     1 - Rotate a charater string.\n");
  29.     printf("\nEnter option : ");
  30.     scanf("%d",&option);
  31.  
  32.     printf("\nSelect a device to use\n");
  33.     printf("     0 - setibm\n");
  34.     printf("     1 - setega\n");
  35.     printf("     2 - setvga\n");
  36.     printf("     3 - setherc\n");
  37.     printf("     4 - set_63h\n");
  38.     printf("     5 - set_vid7\n");
  39.     printf("     6 - set_pvga\n");
  40.     printf("     7 - set_256c\n");
  41.     printf("     8 - set_mcga\n");
  42.     printf("     9 - exit\n");
  43.     printf("\nEnter selection : ");
  44.     scanf("%d",&dev);
  45.  
  46.     printf("Enter graphics mode to use :");
  47.     scanf("%d",&mode);
  48.  
  49.     line_color = 14; char_color = 15;
  50.     switch(dev){
  51.         case 0 : setibm(); 
  52.                     if (mode == 6)
  53.                         line_color = char_color = 1;
  54.                     else
  55.                         line_color = 3; char_color = 1; 
  56.                     break;
  57.         case 1 : setega(); break;
  58.         case 2 : setvga(); break;
  59.         case 3 : setherc(2); line_color = char_color = 1; break;
  60.         case 4 : set_63h(); line_color = char_color = 1; break;
  61.         case 5 : set_vid7(); break;
  62.         case 6 : set_pvga(); break;
  63.         case 7 : set_256c(); break;
  64.         case 8 : setmcga(); break;
  65.         case 9 : initgraf(3,0,0); exit(0);
  66.     }
  67.     
  68.     sprintf(font,"%s.vec",argv[1]);
  69.     fk = vfontld(font,&j);
  70.     if (j < 0){
  71.        printf("\r\nvfontld return:%d\r\n",j);
  72.         exit(0);
  73.     }
  74.     if (option == 0){
  75.         printf("Enter 1 if you wish to change (scale) the size of the character : \n");
  76.         scanf("%d",&scale);
  77.  
  78.         size = 1.0;
  79.         if (scale){
  80.             printf("Enter scaling factor as a float # (Eg. 1.5 or 0.70) : \n");
  81.             scanf("%f",&size);
  82.         }
  83.  
  84.         vfscale(fk,(double)size);
  85.         recs = vfchset(fk,ptr);
  86.         sprintf(t,"==>%%.%ds<==\r\n",recs);
  87.         descender = j = 0;
  88.         while(j < recs){
  89.                 vfchinf(fk,ptr[j],&w,&h,&base_line);
  90.                 if (base_line > descender)
  91.                      descender = base_line;
  92.                 j++;
  93.         }
  94.         j = 0;
  95.         f = descender * size + .5;
  96.         descender = f;
  97.         f = fk->maxhigh * size + .5;
  98.         height = f;
  99.         f = fk->maxwidth * size + .5;
  100.         width = f;
  101.  
  102.         while(j < recs){
  103.           row = height + 1;
  104.           initgraf(mode,0,0);
  105.           eg_status(&s);
  106.           while(j < recs){
  107.                  col = 10;
  108.                    eg_line(0,row,s.x_res-1,row,line_color);
  109.                 while(j < recs){
  110.                       i = vfontch(fk,ptr[j],col,row,char_color,0,&col,&row);
  111.                       if (i == -1){
  112.                          initgraf(3,0,0);
  113.                          printf("return error of %d on vfontch\r\n",i);
  114.                           exit(0);
  115.                         }
  116.                       ++j;
  117.                       if(col+width+1 > s.v_x1) break;
  118.                 }
  119.                 row += height + 1 + descender;
  120.                 if(row + descender > s.y_res-1) break;
  121.             }
  122.             putch(7); i = getch();
  123.       }
  124.         initgraf(3,0,0);
  125.         vfontinf(fk,&recs,&size,&bytes);
  126.        printf("           For Font : %s\n\n",font);
  127.         printf("     number of characters in font: %d\r\n",recs);
  128.         printf("          current scaling of font: %5.3f\r\n",size);
  129.         printf("number of bytes used to load font: %ld\r\n",bytes);
  130.         vfontuld(fk);
  131.     }
  132.     else{
  133.         strcpy(ptr,"ABCDEFGHIKLM");
  134.         for (ff = (float).5; ff <= (float)2; ff += (float).5){
  135.                 vfscale(fk,(double)ff);
  136.               for(j = 0; j < 360; j += 30){
  137.                      initgraf(mode,0,0);
  138.                    eg_status(&s);
  139.                    eg_line(s.x_res/2,s.y_res/2-10,s.x_res/2,s.y_res/2+10,line_color);
  140.                     eg_line(s.x_res/2-20,s.y_res/2,s.x_res/2+20,s.y_res/2,line_color);
  141.                     vfsprtc(fk,ptr,s.x_res/2,s.y_res/2,char_color,j);
  142.                     curlocat(24,0); printf("rot:%d scale:%5.2f",j,ff);
  143.                     getch();
  144.                 }
  145.                 ptr[strlen(ptr)-3] = '\0';
  146.         }
  147.         initgraf(3,0,0);
  148.         vfontuld(fk);
  149.     }
  150. }
  151.