plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

diacrit.c (2301B)


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