diacrit.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include "y.tab.h"
  11. extern double Dvshift, Dhshift, Dh2shift, Dheight, Barv, Barh, Ubarv, Ubarh;
  12. void diacrit(int p1, int type)
  13. {
  14. int c, t;
  15. c = salloc();
  16. t = salloc();
  17. nrwid(p1, ps, p1);
  18. printf(".nr 10 %gm\n", max(REL(eht[p1]-ebase[p1]-1,ps), 0)); /* vert shift if high */
  19. if (type == HIGHBAR)
  20. printf(".nr 10 \\n(10+%gm\n", Dvshift);
  21. else if (type == LOWBAR)
  22. printf(".nr 10 0\n");
  23. else
  24. printf(".if \\n(ct>1 .nr 10 \\n(10+%gm\n", Dvshift);
  25. printf(".nr %d %gm\n", t, Dhshift); /* horiz shift if high */
  26. printf(".if \\n(ct>1 .nr %d %gm\n", t, Dh2shift); /* was .1 and .15 */
  27. switch (type) {
  28. case VEC:
  29. printf(".ds %d %s\n", c, lookup(deftbl, "vec_def")->cval);
  30. break;
  31. case DYAD:
  32. printf(".ds %d %s\n", c, lookup(deftbl, "dyad_def")->cval);
  33. break;
  34. case HAT:
  35. printf(".ds %d %s\n", c, lookup(deftbl, "hat_def")->cval);
  36. break;
  37. case TILDE:
  38. printf(".ds %d %s\n", c, lookup(deftbl, "tilde_def")->cval);
  39. break;
  40. case DOT:
  41. printf(".ds %d %s\n", c, lookup(deftbl, "dot_def")->cval);
  42. break;
  43. case DOTDOT:
  44. printf(".ds %d %s\n", c, lookup(deftbl, "dotdot_def")->cval);
  45. break;
  46. case BAR:
  47. case LOWBAR:
  48. case HIGHBAR:
  49. printf(".ds %d \\v'%gm'\\h'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n",
  50. c, -Barv, Barh, p1, 2*Barh, Barh, Barv);
  51. break;
  52. case UNDER:
  53. printf(".ds %d \\v'%gm'\\l'\\n(%du-%gm\\(ul'\\h'%gm'\\v'%gm'\n",
  54. c, -Ubarv, p1, Ubarh, Ubarh, Ubarv);
  55. /* printf(".ds %d \\v'-%gm'\\l'\\n(%du\\(ul'\\v'%gm'\n",
  56. c, Ubarv, p1, Ubarv);
  57. */
  58. printf(".nr %d 0\n", t);
  59. printf(".nr 10 0-.1m-%gm\n", REL(ebase[p1],ps));
  60. printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-.1m\n");
  61. break;
  62. case UTILDE:
  63. printf(".ds %d %s\n", c, lookup(deftbl, "utilde_def")->cval);
  64. printf(".nr %d 0\n", t);
  65. printf(".nr 10 0-%gm\n", REL(ebase[p1],ps));
  66. printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-%gm\n", 0.1);
  67. break;
  68. }
  69. nrwid(c, ps, c);
  70. if (lfont[p1] != ITAL)
  71. printf(".nr %d 0\n", t);
  72. printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d",
  73. p1, p1, c, t, c);
  74. printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t);
  75. if (type != UNDER && type != UTILDE)
  76. eht[p1] += EM(Dheight, ps); /* was .15 */
  77. dprintf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%g, b=%g\n",
  78. type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]);
  79. sfree(c); sfree(t);
  80. }