summaryrefslogtreecommitdiff
path: root/dviware/dvi2pcl/definefont.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/dvi2pcl/definefont.c
Initial commit
Diffstat (limited to 'dviware/dvi2pcl/definefont.c')
-rw-r--r--dviware/dvi2pcl/definefont.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/dviware/dvi2pcl/definefont.c b/dviware/dvi2pcl/definefont.c
new file mode 100644
index 0000000000..b06d4a4239
--- /dev/null
+++ b/dviware/dvi2pcl/definefont.c
@@ -0,0 +1,109 @@
+/* $Log: definefont.c,v $
+ * Revision 0.8 92/11/23 19:46:38 19:46:38 bt (Bo Thide')
+ * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
+ *
+ * Revision 0.7 92/11/13 02:41:22 02:41:22 bt (Bo Thide')
+ * More bug fixes and improvements. Support for PaintJet XL
+ *
+ * Revision 0.6 92/11/10 21:47:38 21:47:38 bt (Bo Thide')
+ * Bug fixes. Added -R option. Better font handling.
+ *
+ * Revision 0.5 92/11/09 16:25:25 16:25:25 bt (Bo Thide')
+ * Rewrite of dospecial.c. Extended \special support
+ *
+ * Revision 0.4 92/11/08 02:45:40 02:45:40 bt (Bo Thide')
+ * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
+ *
+ * Revision 0.3 92/08/24 12:43:18 12:43:18 bt (Bo Thide')
+ * Fixed 8 bit (dc font) support.
+ *
+ * Revision 0.2 92/08/23 17:28:55 17:28:55 bt (Bo Thide')
+ * Source cleaned up. Changed certain function calls. Removed globals.
+ *
+ * Revision 0.1 92/08/22 23:58:47 23:58:47 bt (Bo Thide')
+ * First Release.
+ * */
+
+/*
+ * This subroutine does the necessary things when a 'FNT_DEF' command is
+ * being processed.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "globals.h"
+#include "macros.h"
+
+static char rcsid[] = "$Header: definefont.c,v 0.8 92/11/23 19:46:38 bt Exp $";
+
+void definefont(dvifile, f)
+FILE *dvifile;
+int f;
+{
+ static int knownsize[] = {1,90,130,150,180,210,240,270,300,329,360,
+ 394,432,473,518,568,622,681,746,818,896,981,
+ 1075,1178,1290,1413,1548,1858,2035,2229,2442,
+ 2675,10000};
+ int k;
+ int a,l; /* Font definition parameters */
+ fontfmt *safefont;
+ charfmt *u;
+ int *known;
+ int idealmag;
+ double s;
+
+ if(!inpostamble)
+ {
+ if(f >= MAXFONTS)
+ valerror("Max number of allowed fonts is %3d\n",
+ MAXFONTS);
+ if(fontptr[f] != 0)
+ valerror("Font number %d already defined\n", f);
+ safefont = font;
+ font = (fontfmt *)malloc(sizeof(*font));
+ fontptr[f] = font;
+ font->checksum = getsquad(dvifile);
+ font->scaled_size = getsquad(dvifile);
+ font->design_size = getsquad(dvifile);
+ a = (int)getubyte(dvifile);
+ l = (int)getubyte(dvifile);
+ if((nextnamesfree-names+a+l+2) > NAMESIZE)
+ valerror("Capacity exceeded (name size=%d)\n",NAMESIZE);
+ font->name = nextnamesfree - names;
+ if(verbose)
+ fprintf(stderr,"Font %d: ", f);
+
+ for(k=0; k<a; k++)
+ *nextnamesfree++ = getubyte(dvifile);
+ *nextnamesfree++ = '\0';
+
+ for(k=0; k<l; k++)
+ *nextnamesfree++ = getubyte(dvifile);
+ *nextnamesfree++ = '\0';
+
+ u = font->chr;
+ for(k=0; k<=255; k++) {
+ u->use_count = 0;
+ u++;
+ }
+
+ font->space = font->design_size / 6;
+ font->down = -3;
+ if(verbose)
+ printfont();
+ idealmag = round((double)font->scaled_size/(double)font->design_size*magnification*RESOLUTION*0.001);
+ if((idealmag < 10) || (idealmag > 9999))
+ valerror("Font dpi size %d unrealistic\n", idealmag);
+ known = knownsize;
+ while(*known < idealmag) known++;
+ if(((double) *known/idealmag) > ((double)idealmag/(*(known-1))))
+ known--;
+ s = (double) *known/idealmag;
+ if((s > 1.02) || (s < 0.98))
+ fprintf(stderr,"Warning: Size %d does not exist; substituting %d.\n",
+ idealmag, *known);
+ font->dir_size = *known;
+ font = safefont;
+
+ }
+}