home *** CD-ROM | disk | FTP | other *** search
- From colonel@ellie.UUCP (Col. G. L. Sicherman) Thu May 29 11:54:25 1986
- Path: seismo!rochester!rocksanne!sunybcs!ellie!colonel
- From: colonel@ellie.UUCP (Col. G. L. Sicherman)
- Newsgroups: net.sources
- Subject: qptol - convert QMS portrait to landscape
- Message-ID: <1109@ellie.UUCP>
- Date: 29 May 86 15:54:25 GMT
- Organization: Jack of Clubs Precision Instruments
- Lines: 104
- Keywords: qms, font, orientation, portrait, landscape
-
- Some time ago I promised to post this so people could use "qtox" on
- portrait fonts. It converts QMS-1200 portrait fonts to landscape fonts.
- As with the other programs, it uses libqfont.
- ---------- TEAR OFF THE TOP OF YOUR TERMINAL AND SEND IT IN ----------
- /*
- * qptol - QMS portrait to landscape.
- * Copyright 1985 by Col. G. L. Sicherman.
- * You may use and alter this software freely for noncommercial ends
- * so long as you leave this message alone.
- */
-
- #include <stdio.h>
- #include <local/qfont.h>
-
- int raslen;
-
- bomb()
- {
- fprintf(stderr,"usage: qptol [file]\n");
- exit(1);
- }
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- extern qfonterror;
- FILE *In;
- float atof();
- struct q_header qh, newqh;
- struct q_glyph qg;
- int save_spacing, save_width, save_hoffset;
- while (--argc) {
- if ('-'==**++argv) switch (*++*argv) {
- /*
- * space for future options.
- */
- default:
- bomb();
- }
- else break;
- }
- if (!argc) In=stdin;
- else {
- if (--argc) bomb();
- if (!(In=fopen(*argv,"r"))) {
- fprintf(stderr,"qptol: cannot read %s\n",*argv);
- exit(1);
- }
- }
- if (qreadh(In,&qh)) {
- fprintf(stderr,"qptol: format error %d on input\n",
- qfonterror);
- exit(1);
- }
- if (qh.q_orientation != 'P') {
- fprintf(stderr,"qptol: input not portrait\n");
- exit(1);
- }
- newqh = qh; /* Copy the header */
- newqh.q_orientation = 'L';
- qwriteh(stdout,&newqh);
- raslen = (qh.q_fheight + 7)/8;
- while (!qread(In,&qh,&qg)) {
- save_spacing = qg.q_spacing;
- /*
- * The output width must be an even number of BYTES.
- */
- if (((qg.q_width+7)/8)%2) {
- unsigned char *pad;
- pad = (unsigned char *)malloc(raslen * (8+qg.q_width));
- /* Berkeley stuff - fake it if you don't have it */
- bcopy(qg.q_bitmap, pad, raslen * qg.q_width);
- bzero(pad+raslen*qg.q_width, raslen*8);
- qg.q_width += 8;
- free(qg.q_bitmap);
- qg.q_bitmap = pad;
- }
- save_width = qg.q_width;
- qrotate(&qg, 0);
- /*
- * left qtrim adjusts the horizontal offset - but we don't want that!
- */
- save_hoffset = qg.q_hoffset;
- qtrim(&qg, 0);
- qtrim(&qg, 1);
- qg.q_hoffset = save_hoffset;
- /*
- * restore the dimensions. qrotate thinks it's still portrait;
- * it exchanges the width and height, and kludges the spacing.
- */
- qg.q_spacing = save_spacing;
- qg.q_height = qg.q_width; /* the width has been trimmed */
- qg.q_width = save_width;
- qwrite(stdout,&newqh,&qg);
- }
- qend(stdout);
- exit(0);
- }
- --
- Col. G. L. Sicherman
- UU: ...{rocksvax|decvax}!sunybcs!colonel
- CS: colonel@buffalo-cs
- BI: csdsicher@sunyabva
-
-
-