URI:
       tfont.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tfont.c (1532B)
       ---
            1 # include "e.h"
            2 
            3 void setfont(char *ch1)
            4 {
            5         yyval = ft;
            6         if (strcmp(ch1, "I") == 0) {        /* I and italic mean merely position 2 */
            7                 *ch1 = '2';
            8                 ft = ITAL;
            9         } else if (strcmp(ch1, "B") == 0) {        /* and similarly for B & bold */
           10                 *ch1 = '3';
           11                 ft = BLD;
           12         } else if (strcmp(ch1, "R") == 0) {        /* and R and roman */
           13                 *ch1 = '1';
           14                 ft = ROM;
           15         } else {
           16                 ft = ROM;        /* assume it's a roman style */
           17         }
           18         ftp++;
           19         if (ftp >= &ftstack[10])
           20                 ERROR "font stack overflow (10)" FATAL;
           21         ftp->ft = ft;
           22         if (ch1[1] == 0) {        /* 1-char name */
           23                 ftp->name[0] = *ch1;
           24                 ftp->name[1] = '\0';
           25         } else
           26                 sprintf(ftp->name, "(%s", ch1);
           27         dprintf(".\tsetfont %s %c\n", ch1, ft);
           28 }
           29 
           30 void font(int p1, int p2)
           31 {
           32                 /* old font in p1, new in ft */
           33         yyval = p2;
           34         lfont[yyval] = rfont[yyval] = ft==ITAL ? ITAL : ROM;
           35         ftp--;
           36         ft = p1;
           37 }
           38 
           39 void globfont(void)
           40 {
           41         char temp[20];
           42 
           43         getstr(temp, sizeof(temp));
           44         yyval = eqnreg = 0;
           45         if (strcmp(temp, "I") == 0 || strncmp(temp, "it", 2) == 0) {
           46                 ft = ITAL;
           47                 strcpy(temp, "2");
           48         } else if (strcmp(temp, "B") == 0 || strncmp(temp, "bo", 2) == 0) {
           49                 ft = BLD;
           50                 strcpy(temp, "3");
           51         } else if (strcmp(temp, "R") == 0 || strncmp(temp, "ro", 2) == 0) {
           52                 ft = ROM;
           53                 strcpy(temp, "1");
           54         } else {
           55                 ft = ROM;        /* assume it's a roman style */
           56         }
           57         ftstack[0].ft = ft;
           58         if (temp[1] == 0)        /* 1-char name */
           59                 strcpy(ftstack[0].name, temp);
           60         else
           61                 sprintf(ftstack[0].name, "(%.2s", temp);
           62 }
           63 
           64 void fatbox(int p)
           65 {
           66         extern double Fatshift;
           67 
           68         yyval = p;
           69         printf(".ds %d \\*(%d\\h'-\\w'\\*(%d'u+%gm'\\*(%d\n", p, p, p, Fatshift, p);
           70 }