home *** CD-ROM | disk | FTP | other *** search
- #include "stdio.h"
- #include "eg_proto.h"
-
- void main(argc,argv)
- int argc;
- char *argv[];
- {
- int recs,j,i,col,row,descender,w,h,base_line;
- int char_color,line_color;
- long bytes;
- float size;
- char ptr[1000],t[80],font[80];
- struct vfont *fk;
- struct egstatus s;
- int mode,dev,rot;
- int scale;
- int height,width;
- float f,ff;
- int option;
-
- if(argc != 2){
- printf("Calling Sequence is: VIEW \"NAME\"\r\n");
- exit(0);
- }
-
- printf("\nSelect a vector font option :\n");
- printf(" 0 - Show font character set (option to scale).\n");
- printf(" 1 - Rotate a charater string.\n");
- printf("\nEnter option : ");
- scanf("%d",&option);
-
- printf("\nSelect a device to use\n");
- printf(" 0 - setibm\n");
- printf(" 1 - setega\n");
- printf(" 2 - setvga\n");
- printf(" 3 - setherc\n");
- printf(" 4 - set_63h\n");
- printf(" 5 - set_vid7\n");
- printf(" 6 - set_pvga\n");
- printf(" 7 - set_256c\n");
- printf(" 8 - set_mcga\n");
- printf(" 9 - exit\n");
- printf("\nEnter selection : ");
- scanf("%d",&dev);
-
- printf("Enter graphics mode to use :");
- scanf("%d",&mode);
-
- line_color = 14; char_color = 15;
- switch(dev){
- case 0 : setibm();
- if (mode == 6)
- line_color = char_color = 1;
- else
- line_color = 3; char_color = 1;
- break;
- case 1 : setega(); break;
- case 2 : setvga(); break;
- case 3 : setherc(2); line_color = char_color = 1; break;
- case 4 : set_63h(); line_color = char_color = 1; break;
- case 5 : set_vid7(); break;
- case 6 : set_pvga(); break;
- case 7 : set_256c(); break;
- case 8 : setmcga(); break;
- case 9 : initgraf(3,0,0); exit(0);
- }
-
- sprintf(font,"%s.vec",argv[1]);
- fk = vfontld(font,&j);
- if (j < 0){
- printf("\r\nvfontld return:%d\r\n",j);
- exit(0);
- }
- if (option == 0){
- printf("Enter 1 if you wish to change (scale) the size of the character : \n");
- scanf("%d",&scale);
-
- size = 1.0;
- if (scale){
- printf("Enter scaling factor as a float # (Eg. 1.5 or 0.70) : \n");
- scanf("%f",&size);
- }
-
- vfscale(fk,(double)size);
- recs = vfchset(fk,ptr);
- sprintf(t,"==>%%.%ds<==\r\n",recs);
- descender = j = 0;
- while(j < recs){
- vfchinf(fk,ptr[j],&w,&h,&base_line);
- if (base_line > descender)
- descender = base_line;
- j++;
- }
- j = 0;
- f = descender * size + .5;
- descender = f;
- f = fk->maxhigh * size + .5;
- height = f;
- f = fk->maxwidth * size + .5;
- width = f;
-
- while(j < recs){
- row = height + 1;
- initgraf(mode,0,0);
- eg_status(&s);
- while(j < recs){
- col = 10;
- eg_line(0,row,s.x_res-1,row,line_color);
- while(j < recs){
- i = vfontch(fk,ptr[j],col,row,char_color,0,&col,&row);
- if (i == -1){
- initgraf(3,0,0);
- printf("return error of %d on vfontch\r\n",i);
- exit(0);
- }
- ++j;
- if(col+width+1 > s.v_x1) break;
- }
- row += height + 1 + descender;
- if(row + descender > s.y_res-1) break;
- }
- putch(7); i = getch();
- }
- initgraf(3,0,0);
- vfontinf(fk,&recs,&size,&bytes);
- printf(" For Font : %s\n\n",font);
- printf(" number of characters in font: %d\r\n",recs);
- printf(" current scaling of font: %5.3f\r\n",size);
- printf("number of bytes used to load font: %ld\r\n",bytes);
- vfontuld(fk);
- }
- else{
- strcpy(ptr,"ABCDEFGHIKLM");
- for (ff = (float).5; ff <= (float)2; ff += (float).5){
- vfscale(fk,(double)ff);
- for(j = 0; j < 360; j += 30){
- initgraf(mode,0,0);
- eg_status(&s);
- eg_line(s.x_res/2,s.y_res/2-10,s.x_res/2,s.y_res/2+10,line_color);
- eg_line(s.x_res/2-20,s.y_res/2,s.x_res/2+20,s.y_res/2,line_color);
- vfsprtc(fk,ptr,s.x_res/2,s.y_res/2,char_color,j);
- curlocat(24,0); printf("rot:%d scale:%5.2f",j,ff);
- getch();
- }
- ptr[strlen(ptr)-3] = '\0';
- }
- initgraf(3,0,0);
- vfontuld(fk);
- }
- }