Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!haven!umd5!jonnyg From: jonnyg@umd5.umd.edu (Jon Greenblatt) Newsgroups: comp.graphics Subject: Vector fonts...... Keywords: vector font Message-ID: <4081@umd5.umd.edu> Date: 20 Sep 88 18:12:23 GMT Reply-To: jonnyg@umd5.umd.edu (Jon Greenblatt) Organization: University of Maryland, College Park Lines: 350 Thank you all for the numerous responses to my request for vectorized fonts. The answer was to look at the uunet archives in volume4. In keeping with my tradition of asking questions I am going to post some useful code I have developed to deal with Hershey fonts. The following program will take a font description and print it out in unix plot format. The font descriptions are in the .hmp files. The fonts need to be concatenated in a file hersh.c, see the comments in the code. This should help people isolate fonts into ascii order. I hope I am not repeating work already done but this code is not long. Thanks again for the responses. JonnyG. (jonnyg@rover.umd.edu) (jonnyg@umd5.umd.edu) ----------------------------------------------------------------------------- #include #include #define FONTFILE "hersh.oc" /* * Hersh.c Display the hershy fonts based on the .hmp definitions. * * This program has been converted to work with the unix plot library. * The .hmp discriptions are used to read the occidental fonts only. * All the occidental fonts hersh.oc1-hersh.oc4 need to be concatenated * into hersh.oc. * * Translated to Unix Plot by Jonathan Greenblatt. * (jonnyg@rover.umd.edu) * (jonnyg@umd5.umd.edu) * * Note: This only prints fonts in the .hmp definitions, make the file * "all.hmp" and place the following line in it: * 1-3926 * To print all the characters type "hersh all". * * The oriental characters can be printed by changing the FONTFILE definition. */ /* * *** This is the old comment from the hershey.c program. (Jon Greenblatt) ** * * hershey.c Display all of the Hershey font data in a font file * * This sample program is intended more so the user can see how the * font data is read and used in an (admittedly minimal) application, * than as a useable program. * * Its function is to display all of the hershey font characters on-screen, * in a format 8 characters across and 8 vertical. * * usage: * hershey * * where is the name of a hershey name, e.g. * romancs * italict * scripts * * Translated from Fortran to C and GKS (that's why it looks wierd!) * (PRIOR Data Sciences non-ANSI GKS binding used here. Sorry! * Somebody else is welcome to translate to the ANSI binding) * * */ /* Translated by Pete Holzmann Octopus Enterprises 19611 La Mar Court Cupertino, CA 95014 Original... .. By James Hurt when with .. Deere and Company .. John Deere Road .. Moline, IL 61265 .. now with Cognition, Inc. .. 900 Technology Park Drive .. Billerica, MA 01821 */ #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif float deltac = 12.5, deltar = 12.5, colmax = 100.0; FILE *INfile,*OUTfile,*fopen(); /* some files */ int minx = 999,miny = 999,maxx=-999,maxy=-999; char name[80]; /* * scanint: a function to scan an integer, using n characters of * the input file, ignoring newlines. (scanf won't work * because it also ignores blanks) */ int scanint(file,n) FILE *file; int n; { char buf[20]; int i,c; for (i=0;i 0) { if (n < 0) { int t; t = chars[nchars-1].code; while (t < -n) chars[nchars++].code = ++t; } else chars[nchars++].code = n; } fclose(f); } main(argc,argv) int argc; char **argv; { FILE *kfile; char line[2][256]; int x,y; float col,row; int ipnt,ich,nch,i; for (x = 0; x < MAXCHARS; x++) chars[x].len = 0; if (argc != 2) { printf("usage: hershey file\n"); exit(1); } if (!(kfile = fopen(FONTFILE,"r"))) { fprintf(stderr,"Can't open font file '%s'\n",FONTFILE); exit(1); } readdat(argv[1]); while ((ich = scanint(kfile,5)) > 0) { Achar *achar; char *s; char *malloc(); int j; for (i = 0; i < nchars; i++) if (chars[i].code == ich) break; if (i < nchars) { achar = &chars[i]; achar->len = scanint(kfile,3); s = achar->data = malloc(achar->len * 2); for (i = 0; i < achar->len; i++) { if ((i==32) ||(i==68) ||(i==104) ||(i==140)) fgetc(kfile); /* skip newlines */ *s++ = fgetc(kfile); *s++ = fgetc(kfile); } } else { j = scanint(kfile,3); for (i = 0; i < j; i++) { if ((i==32) ||(i==68) ||(i==104) ||(i==140)) fgetc(kfile); /* skip newlines */ fgetc(kfile); fgetc(kfile); } } fgetc(kfile); } fclose(kfile); col = 0.0; row = 100.0; openpl(); erase(); for (ich = 0; ich < nchars; ich++) { if ((nch = chars[ich].len) == 0) continue; for (i=0; imaxx) maxx = x; if (-y < miny) miny = -y; if (-y >maxy) maxy = -y; draw(x,-y); } } /* for loop */ if( (col += deltac) < colmax ) continue; col = 0.0; if( (row -= deltar) >= deltar ) continue; fflush(stdout); if (getchar() == 'q') exit(0); erase(); col = 0.0; row = 100.0; } /* while true */ fflush(stdout); getchar(); } long power[] ={ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; int start[] ={0,11,14,22,36,42,55,68,73,91,104}; char linedat[]={'R','M','P','N','O','P','O','S','P','U','R','V','T','U', 'U','S','U','P','T','N','R','M','P','O','R','M','R', 'V','O','N','Q','M','S','M','U','N','U','P','T','R','O', 'V','U','V','O','N','Q','M','S','M','U','N','U','P','S','Q', ' ','R','R','Q','S','Q','U','R','U','U','S','V','Q','V','O','U', 'S','M','S','V',' ','R','S','M','N','S','V','S','P', 'M','O','Q','Q','P','R','P','T','Q','U','S','T','U','R','V','Q', 'V','O','U',' ','R','P','M','T','M','T','M','R','M','P','N', 'O','P','O','S','P','U','R','V','T','U','U','S','T','Q','R','P', 'P','Q','O','S','U','M','Q','V',' ','R','O','M','U','M', 'Q','M','O','N','O','P','Q','Q','S','Q','U','P','U','N','S', 'M','Q','M',' ','R','Q','Q','O','R','O','U','Q','V','S','V','U','U', 'U','R','S','Q','U','P','T','R','R','S','P','R','O','P', 'P','N','R','M','T','N','U','P','U','S','T','U','R','V','P','V'}; #define line(a,b) linedat[(b*2+a)] jnumbr( number, iwidth, x0, y0, height ) int number, iwidth; float x0, y0, height; { int ipnt, ipos, ival, idigit; float x, y, scale; float xleft, ylower; scale = height/10.0; xleft = x0; ylower = y0; ival = number; for (ipos = iwidth;ipos>=1;ipos--) { idigit = (ival/power[ipos-1])% 10; skip(); for ( ipnt=start[idigit]; ipnt < start[idigit+1];ipnt++) { if(((char)line(0,ipnt)) == ' ') { skip(); /* next data point is a move */ } else { x=(int)line(0,ipnt) -(int) 'N'; y=(int)line(1,ipnt) -(int) 'V'; draw((int)(xleft+scale*x),(int)(ylower-scale*y)); } } /* data for this digit */ xleft += height; } /* whole string */ }