Annotation of 43BSD/contrib/dipress/src/bin/charset/charset.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *
        !             3:  * Copyright (c) 1984, 1985 Xerox Corp.
        !             4:  *
        !             5:  * HISTORY
        !             6:  * 01-Dec-85  lee at Xerox, WRC
        !             7:  *     Modified to pass lint.
        !             8:  *
        !             9:  *     28-apr-85  ed flint     add conditional code for vax11-c (vms)
        !            10:  *                             now use -s for point size and added -o for
        !            11:  *                             output file
        !            12:  */
        !            13: 
        !            14: #ifdef vax11c
        !            15: #include stdio
        !            16: #include ctype
        !            17: #else
        !            18: # include <stdio.h>
        !            19: # include <ctype.h>
        !            20: # include <sys/file.h>
        !            21: # include <strings.h>
        !            22: #endif
        !            23: 
        !            24: # include "iptokens.h"
        !            25: # include "literal.h"
        !            26: # include "operator.h"
        !            27: 
        !            28: /* frame buffer numbers */
        !            29: # define    F_backgroundfont   1
        !            30: # define    F_font             2
        !            31: # define    F_transform                3
        !            32: 
        !            33: # define    INCH               720
        !            34: # define    Top_margin         (10 * INCH)
        !            35: # define    Left_margin                (INCH * 2)
        !            36: # define    Left_table         (Left_margin + INCH/2)
        !            37: 
        !            38: main(argc, argv)
        !            39: 
        !            40: int  argc;
        !            41: char *argv[];
        !            42: 
        !            43: {
        !            44:     char u_fontname[256];
        !            45:     char buffer[256];
        !            46:     char *outputname= 0;
        !            47:     int ipressfile;
        !            48:     int point_size = 10;
        !            49:     int char_spacing;
        !            50:     int line_spacing;
        !            51:     int x_pos;
        !            52:     int y_pos;
        !            53:     int i;
        !            54:     int num;
        !            55:     int prefix = 0;
        !            56: 
        !            57:     if (argc < 2)
        !            58:     {
        !            59:        fprintf(stderr, "charset: which font?\n");
        !            60:        exit(1);
        !            61:     }
        !            62: 
        !            63:     for ( i= 1 ; i <= argc ; i++ )
        !            64:     {
        !            65:        if ( argv[i][0] == '-' )
        !            66:            switch(argv[i][1])
        !            67:            {
        !            68:                case ('p'):
        !            69:                case ('P'):
        !            70:                    (void) sscanf(&argv[i][2], "%o", &prefix);
        !            71:                    break;
        !            72:                case ('o'):
        !            73:                case ('O'):
        !            74:                    if ( strlen(argv[i]) > 2 )
        !            75:                        outputname= &(argv[i][2]);
        !            76:                    else
        !            77:                        outputname= argv[++i];
        !            78:                    break;
        !            79:                case ('s'):
        !            80:                case ('S'):
        !            81:                    point_size= atoi(&(argv[i][2]));
        !            82:                    break;
        !            83:            }
        !            84:        else
        !            85:            break;
        !            86:     }
        !            87: 
        !            88:     (void) strcpy(u_fontname, "Xerox/XC1-1-1/");
        !            89:     (void) strcat(u_fontname, argv[i]);
        !            90: 
        !            91:     /* set spacing parameters */
        !            92:     line_spacing = (point_size + 2) * 15;
        !            93:     char_spacing = point_size * 30;
        !            94: 
        !            95:     if ( outputname != 0 )
        !            96:     {
        !            97: #ifdef vax11c
        !            98:        if ( (ipressfile= creat(outputname, 0, "rfm=udf")) == -1 )
        !            99: #else
        !           100:        if ( (ipressfile= open(outputname, O_WRONLY | O_CREAT, 0666)) == -1 )
        !           101: #endif
        !           102:        {
        !           103:            perror(outputname);
        !           104:            exit(1);
        !           105:        }
        !           106:     }
        !           107:     else               /* default to stdout */
        !           108:     {
        !           109:        ipressfile= 1;
        !           110:     }
        !           111: 
        !           112:     ip_select(ipressfile);
        !           113: 
        !           114:     AppendOp(OP_beginBlock);
        !           115:     AppendOp(OP_beginBody);
        !           116: 
        !           117:     /* set up the two fonts: the background and the font in question */
        !           118:     SetupFont("Xerox/XC1-1-1/Classic", 100., F_backgroundfont);
        !           119:     SetupFont(u_fontname, point_size * 10., F_font);
        !           120: 
        !           121:     /* set frame[2] to a scaling transform that uses 1/10 point */
        !           122:     /* co-ordiate system */
        !           123:     AppendRational(353L, 10000000);
        !           124:     AppendOp(OP_scale);
        !           125:     AppendInteger((long) F_transform);
        !           126:     AppendOp(OP_fset);
        !           127: 
        !           128:     AppendOp(OP_endBody);      /* end preamble */
        !           129: 
        !           130:     AppendOp(OP_beginBody);    /* page 1 (and only) */
        !           131: 
        !           132:     Fget(F_transform);
        !           133:     AppendOp(OP_concatt);
        !           134:     Setfont(F_backgroundfont);
        !           135:     Setxy((double)Left_margin, (double)Top_margin);
        !           136:     (void) sprintf(buffer, "Xerox/XC1-1-1/%s at %d point, character set %o (octal)",
        !           137:        argv[i], point_size, prefix);
        !           138:     ShowString(buffer);
        !           139: 
        !           140:     buffer[0] = '0';
        !           141:     buffer[1] = '\0';
        !           142:     for (x_pos = Left_table, i = 0; i < 8;
        !           143:         x_pos += char_spacing, i++)
        !           144:     {
        !           145:        Setxy((double)x_pos, (double)(Top_margin - 2 * line_spacing));
        !           146:        ShowString(buffer);
        !           147:        buffer[0] += 1;
        !           148:     }
        !           149: 
        !           150:     for (y_pos = Top_margin - 3 * line_spacing, num = 000; num < 0377;
        !           151:         y_pos -= line_spacing)
        !           152:     {
        !           153:        Setxy((double)Left_margin, (double)y_pos);
        !           154:        (void) sprintf(buffer, "%03o", num);
        !           155:        ShowString(buffer);
        !           156:        Setfont(F_font);
        !           157: 
        !           158:        for (x_pos = Left_table, i = 0; i < 8;
        !           159:             x_pos += char_spacing, i++, num++)
        !           160:        {
        !           161:            Setxy((double)x_pos, (double)y_pos);
        !           162:            if (num != 0377)
        !           163:            {
        !           164:                if (prefix > 0)
        !           165:                {
        !           166:                    (void) sprintf(buffer, "\377%c%c", prefix, num);
        !           167:                    AppendString(buffer);               
        !           168:                }
        !           169:                else
        !           170:                {
        !           171:                    buffer[0] = num;
        !           172:                    buffer[1] = '\0';
        !           173:                    AppendString(buffer);
        !           174:                }
        !           175:                AppendOp(OP_show);
        !           176:            }
        !           177:        }
        !           178:        Setfont(F_backgroundfont);
        !           179:     }
        !           180: 
        !           181:     /* wrap it up */
        !           182:     AppendOp(OP_endBody);
        !           183:     AppendOp(OP_endBlock);
        !           184: 
        !           185:     ip_flush();
        !           186: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.