1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)vwidth.c	5.1 (Berkeley) 5/15/85";
   9: #endif not lint
  10: 
  11: /*
  12:  *	Creates a width table for troff from a versatec font for a
  13:  *		normal font.
  14:  *	Usage: width font [ point_size ]
  15:  *		where font is the file name of the versatec font and
  16:  *		point_size is it point size.
  17:  *	If the point size is omitted it is taken from the suffix of
  18:  *	the font name, as bocklin.14 => 14 point.
  19:  *	It is better to use as large a point size font as possible
  20:  *	to avoid round off.
  21:  */
  22: 
  23: #include <stdio.h>
  24: 
  25: struct wtable {
  26:     char    charloc;
  27:     char    *name;
  28: } wtable[] = {
  29:     '\214', "space",
  30:     '!',    "!",
  31:     '"',    "\"",
  32:     '#',    "#",
  33:     '$',    "$",
  34:     '%',    "%",
  35:     '&',    "&",
  36:     '\'',   "'",
  37:     '(',    "(",
  38:     ')',    ")",
  39:     '*',    "*",
  40:     '+',    "+",
  41:     ',',    ",",
  42:     '-',    "- hyphen",
  43:     '.',    ".",
  44:     '/',    "/",
  45:     '0',    "0",
  46:     '1',    "1",
  47:     '2',    "2",
  48:     '3',    "3",
  49:     '4',    "4",
  50:     '5',    "5",
  51:     '6',    "6",
  52:     '7',    "7",
  53:     '8',    "8",
  54:     '9',    "9",
  55:     ':',    ":",
  56:     ';',    ";",
  57:     '<',    "<",
  58:     '=',    "=",
  59:     '>',    ">",
  60:     '?',    "?",
  61:     '@',    "@",
  62:     'A',    "A",
  63:     'B',    "B",
  64:     'C',    "C",
  65:     'D',    "D",
  66:     'E',    "E",
  67:     'F',    "F",
  68:     'G',    "G",
  69:     'H',    "H",
  70:     'I',    "I",
  71:     'J',    "J",
  72:     'K',    "K",
  73:     'L',    "L",
  74:     'M',    "M",
  75:     'N',    "N",
  76:     'O',    "O",
  77:     'P',    "P",
  78:     'Q',    "Q",
  79:     'R',    "R",
  80:     'S',    "S",
  81:     'T',    "T",
  82:     'U',    "U",
  83:     'V',    "V",
  84:     'W',    "W",
  85:     'X',    "X",
  86:     'Y',    "Y",
  87:     'Z',    "Z",
  88:     '[',    "[",
  89:     '\\',   "\\",
  90:     ']',    "]",
  91:     '^',    "^",
  92:     '_',    "_",
  93:     '\`',   "\`",
  94:     'a',    "a",
  95:     'b',    "b",
  96:     'c',    "c",
  97:     'd',    "d",
  98:     'e',    "e",
  99:     'f',    "f",
 100:     'g',    "g",
 101:     'h',    "h",
 102:     'i',    "i",
 103:     'j',    "j",
 104:     'k',    "k",
 105:     'l',    "l",
 106:     'm',    "m",
 107:     'n',    "n",
 108:     'o',    "o",
 109:     'p',    "p",
 110:     'q',    "q",
 111:     'r',    "r",
 112:     's',    "s",
 113:     't',    "t",
 114:     'u',    "u",
 115:     'v',    "v",
 116:     'w',    "w",
 117:     'x',    "x",
 118:     'y',    "y",
 119:     'z',    "z",
 120:     '{',    "{",
 121:     '|',    "|",
 122:     '}',    "}",
 123:     '~',    "~",
 124:     '\206', "narrow space",
 125:     '-',    "hyphen",
 126:     '\07',  "bullet",
 127:     '\010', "square",
 128:     '\06',  "3/4 em dash",
 129:     '\05',  "rule",
 130:     '\021', "1/4",
 131:     '\022', "1/2",
 132:     '\023', "3/4",
 133:     '\04',  "minus",
 134:     '\01',  "fi",
 135:     '\02',  "fl",
 136:     '\03',  "ff",
 137:     '\011', "ffi",
 138:     '\012', "ffl",
 139:     '\013', "degree",
 140:     '\014', "dagger",
 141:     '\200', "section (unimplem)",
 142:     '\015', "foot mark",
 143:     '\200', "acute acc (unimplem)",
 144:     '\200', "grave acc (unimplem)",
 145:     '\200', "underrule (unimplem)",
 146:     '\200', "slash (unimplem)",
 147:     '\203', "half narrow space",
 148:     '\200', "null",
 149:     '\200', "null",
 150:     '\200', "null",
 151:     '\200', "null",
 152:     '\200', "null",
 153:     '\200', "null",
 154:     '\200', "null",
 155:     '\200', "null",
 156:     '\200', "null",
 157:     '\200', "null",
 158:     '\200', "null",
 159:     '\200', "null",
 160:     '\200', "null",
 161:     '\200', "null",
 162:     '\200', "null",
 163:     '\200', "null",
 164:     '\200', "null",
 165:     '\200', "null",
 166:     '\200', "null",
 167:     '\200', "null",
 168:     '\200', "null",
 169:     '\200', "null",
 170:     '\200', "null",
 171:     '\200', "null",
 172:     '\200', "null",
 173:     '\200', "null",
 174:     '\200', "null",
 175:     '\200', "null",
 176:     '\200', "null",
 177:     '\200', "null",
 178:     '\200', "null",
 179:     '\200', "null",
 180:     '\200', "null",
 181:     '\200', "null",
 182:     '\200', "null",
 183:     '\200', "null",
 184:     '\200', "null",
 185:     '\200', "null",
 186:     '\200', "null",
 187:     '\200', "null",
 188:     '\200', "null",
 189:     '\200', "null",
 190:     '\200', "null",
 191:     '\200', "null",
 192:     '\200', "null",
 193:     '\200', "null",
 194:     '\200', "null",
 195:     '\200', "null",
 196:     '\200', "null",
 197:     '\200', "null",
 198:     '\200', "null",
 199:     '\200', "null",
 200:     '\200', "null",
 201:     '\200', "null",
 202:     '\200', "null",
 203:     '\200', "null",
 204:     '\200', "null",
 205:     '\200', "null",
 206:     '\200', "null",
 207:     '\200', "null",
 208:     '\200', "null",
 209:     '\200', "null",
 210:     '\200', "null",
 211:     '\200', "null",
 212:     '\200', "null",
 213:     '\200', "null",
 214:     '\200', "null",
 215:     '\200', "null",
 216:     '\200', "null",
 217:     '\200', "null",
 218:     '\200', "null",
 219:     '\017', "registered",
 220:     '\016', "copyright",
 221:     '\200', "null",
 222:     '\020', "cent",
 223:     0,  0
 224: };
 225: 
 226: struct desc {
 227:     short   addr;
 228:     short   nbytes;
 229:     char    up;
 230:     char    down;
 231:     char    left;
 232:     char    right;
 233:     short   width;
 234: } desc[256];
 235: 
 236: main(argc, argv)
 237:     int argc;
 238:     char *argv[];
 239: {
 240:     register int cl;
 241:     register esc;
 242:     register w;
 243:     int i, psize;
 244:     int fd, high;
 245: 
 246:     if (argc != 3 && argc != 2) {
 247:         printf("Usage: vwidth font [pointsize] > font.c\n");
 248:         exit(1);
 249:     }
 250:     fd = open(argv[1], 0);
 251:     if (argc == 3)
 252:         psize = atoi(argv[2]);
 253:     else {
 254:         char *p;
 255:         for (p = argv[1]; *p && *p != '.'; p++)
 256:             ;
 257:         if (*p == 0) {
 258:             psize = 10;
 259:             fprintf(stderr, "Assuming %d point\n", psize);
 260:         } else
 261:             psize = atoi(p+1);
 262:     }
 263:     lseek(fd, 10L, 0);
 264:     read(fd, desc, sizeof desc);
 265:     high = desc['a'].up+1;
 266:     printf("char XXw[256-32] = {\n");
 267:     for (i = 0; wtable[i].charloc != 0; i++) {
 268:         cl = wtable[i].charloc & 0377;
 269:         if (cl & 0200)
 270:             w = cl & 0177;
 271:         else
 272:             w = desc[cl].width*(54./25.)*(6./psize)+.5;
 273:         esc = 0;
 274:         if ((cl >= '0' && cl <= '9') || (cl >= 'A' && cl <= 'Z') ||
 275:             (cl >= 'a' && cl <= 'z')) {
 276:             if (desc[cl].up > high)
 277:                 esc |= 0200;
 278:             if (desc[cl].down > 0)
 279:                 esc |= 0100;
 280:         }
 281:         if (esc)
 282:             printf("%d+0%o,\t/* %s */\n", w, esc, wtable[i].name);
 283:         else
 284:             printf("%d,\t\t/* %s */\n", w, wtable[i].name);
 285:     }
 286:     printf("};\n");
 287: }

Defined functions

main defined in line 236; never used

Defined variables

desc defined in line 234; used 6 times
sccsid defined in line 8; never used
wtable defined in line 28; used 4 times

Defined struct's

desc defined in line 226; never used
wtable defined in line 25; never used
Last modified: 1985-05-15
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 820
Valid CSS Valid XHTML 1.0 Strict