home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / net / qptol < prev    next >
Internet Message Format  |  1986-05-30  |  3KB

  1. From colonel@ellie.UUCP (Col. G. L. Sicherman) Thu May 29 11:54:25 1986
  2. Path: seismo!rochester!rocksanne!sunybcs!ellie!colonel
  3. From: colonel@ellie.UUCP (Col. G. L. Sicherman)
  4. Newsgroups: net.sources
  5. Subject: qptol - convert QMS portrait to landscape
  6. Message-ID: <1109@ellie.UUCP>
  7. Date: 29 May 86 15:54:25 GMT
  8. Organization: Jack of Clubs Precision Instruments
  9. Lines: 104
  10. Keywords: qms, font, orientation, portrait, landscape
  11.  
  12. Some time ago I promised to post this so people could use "qtox" on
  13. portrait fonts.  It converts QMS-1200 portrait fonts to landscape fonts.
  14. As with the other programs, it uses libqfont.
  15. ---------- TEAR OFF THE TOP OF YOUR TERMINAL AND SEND IT IN ----------
  16. /*
  17.  *    qptol - QMS portrait to landscape.
  18.  *    Copyright 1985 by Col. G. L. Sicherman.
  19.  *    You may use and alter this software freely for noncommercial ends
  20.  *    so long as you leave this message alone.
  21.  */
  22.  
  23. #include <stdio.h>
  24. #include <local/qfont.h>
  25.  
  26. int    raslen;
  27.  
  28. bomb()
  29. {
  30.     fprintf(stderr,"usage: qptol [file]\n");
  31.     exit(1);
  32. }
  33.  
  34. main(argc,argv)
  35. int argc;
  36. char **argv;
  37. {
  38.     extern qfonterror;
  39.     FILE *In;
  40.     float atof();
  41.     struct q_header qh, newqh;
  42.     struct q_glyph qg;
  43.     int save_spacing, save_width, save_hoffset;
  44.     while (--argc) {
  45.         if ('-'==**++argv) switch (*++*argv) {
  46. /*
  47.  *    space for future options.
  48.  */
  49.         default:
  50.             bomb();
  51.         }
  52.         else break;
  53.     }
  54.     if (!argc) In=stdin;
  55.     else {
  56.         if (--argc) bomb();
  57.         if (!(In=fopen(*argv,"r"))) {
  58.             fprintf(stderr,"qptol: cannot read %s\n",*argv);
  59.             exit(1);
  60.         }
  61.     }
  62.     if (qreadh(In,&qh)) {
  63.         fprintf(stderr,"qptol: format error %d on input\n",
  64.             qfonterror);
  65.         exit(1);
  66.     }
  67.     if (qh.q_orientation != 'P') {
  68.         fprintf(stderr,"qptol: input not portrait\n");
  69.         exit(1);
  70.     }
  71.     newqh = qh;        /* Copy the header */
  72.     newqh.q_orientation = 'L';
  73.     qwriteh(stdout,&newqh);
  74.     raslen = (qh.q_fheight + 7)/8;
  75.     while (!qread(In,&qh,&qg)) {
  76.         save_spacing = qg.q_spacing;
  77. /*
  78.  *    The output width must be an even number of BYTES.
  79.  */
  80.         if (((qg.q_width+7)/8)%2) {
  81.             unsigned char *pad;
  82.             pad = (unsigned char *)malloc(raslen * (8+qg.q_width));
  83. /* Berkeley stuff - fake it if you don't have it */
  84.             bcopy(qg.q_bitmap, pad, raslen * qg.q_width);
  85.             bzero(pad+raslen*qg.q_width, raslen*8);
  86.             qg.q_width += 8;
  87.             free(qg.q_bitmap);
  88.             qg.q_bitmap = pad;
  89.         }
  90.         save_width = qg.q_width;
  91.         qrotate(&qg, 0);
  92. /*
  93.  *    left qtrim adjusts the horizontal offset - but we don't want that!
  94.  */
  95.         save_hoffset = qg.q_hoffset;
  96.         qtrim(&qg, 0);
  97.         qtrim(&qg, 1);
  98.         qg.q_hoffset = save_hoffset;
  99. /*
  100.  *    restore the dimensions.  qrotate thinks it's still portrait;
  101.  *    it exchanges the width and height, and kludges the spacing.
  102.  */
  103.         qg.q_spacing = save_spacing;
  104.         qg.q_height = qg.q_width;    /* the width has been trimmed */
  105.         qg.q_width = save_width;
  106.         qwrite(stdout,&newqh,&qg);
  107.     }
  108.     qend(stdout);
  109.     exit(0);
  110. }
  111. -- 
  112. Col. G. L. Sicherman
  113. UU: ...{rocksvax|decvax}!sunybcs!colonel
  114. CS: colonel@buffalo-cs
  115. BI: csdsicher@sunyabva
  116.  
  117.  
  118.