font.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. # include "e.h"
  10. void setfont(char *ch1)
  11. {
  12. yyval = ft;
  13. if (strcmp(ch1, "I") == 0) { /* I and italic mean merely position 2 */
  14. *ch1 = '2';
  15. ft = ITAL;
  16. } else if (strcmp(ch1, "B") == 0) { /* and similarly for B & bold */
  17. *ch1 = '3';
  18. ft = BLD;
  19. } else if (strcmp(ch1, "R") == 0) { /* and R and roman */
  20. *ch1 = '1';
  21. ft = ROM;
  22. } else {
  23. ft = ROM; /* assume it's a roman style */
  24. }
  25. ftp++;
  26. if (ftp >= &ftstack[10])
  27. ERROR "font stack overflow (10)" FATAL;
  28. ftp->ft = ft;
  29. if (ch1[1] == 0) { /* 1-char name */
  30. ftp->name[0] = *ch1;
  31. ftp->name[1] = '\0';
  32. } else
  33. sprintf(ftp->name, "(%s", ch1);
  34. dprintf(".\tsetfont %s %c\n", ch1, ft);
  35. }
  36. void font(int p1, int p2)
  37. {
  38. /* old font in p1, new in ft */
  39. yyval = p2;
  40. lfont[yyval] = rfont[yyval] = ft==ITAL ? ITAL : ROM;
  41. ftp--;
  42. ft = p1;
  43. }
  44. void globfont(void)
  45. {
  46. char temp[20];
  47. getstr(temp, sizeof(temp));
  48. yyval = eqnreg = 0;
  49. if (strcmp(temp, "I") == 0 || strncmp(temp, "it", 2) == 0) {
  50. ft = ITAL;
  51. strcpy(temp, "2");
  52. } else if (strcmp(temp, "B") == 0 || strncmp(temp, "bo", 2) == 0) {
  53. ft = BLD;
  54. strcpy(temp, "3");
  55. } else if (strcmp(temp, "R") == 0 || strncmp(temp, "ro", 2) == 0) {
  56. ft = ROM;
  57. strcpy(temp, "1");
  58. } else {
  59. ft = ROM; /* assume it's a roman style */
  60. }
  61. ftstack[0].ft = ft;
  62. if (temp[1] == 0) /* 1-char name */
  63. strcpy(ftstack[0].name, temp);
  64. else
  65. sprintf(ftstack[0].name, "(%.2s", temp);
  66. }
  67. void fatbox(int p)
  68. {
  69. extern double Fatshift;
  70. yyval = p;
  71. printf(".ds %d \\*(%d\\h'-\\w'\\*(%d'u+%gm'\\*(%d\n", p, p, p, Fatshift, p);
  72. }