]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/eqn/tuning.c
ndb/dns: remove single-ip-address assuptions
[plan9front.git] / sys / src / cmd / eqn / tuning.c
1 #include "e.h"
2
3 /*
4
5 This file contains parameter values for many of the
6 tuning parameters in eqn.  Names are defined words.
7
8 Strings are plugged in verbatim.
9 Floats are usually in ems.
10
11 */
12
13 /* In main.c: */
14
15 double  BeforeSub = 1.2;        /* line space before a subscript */
16 double  AfterSub  = 0.2;        /* line space after a subscript */
17
18 /* diacrit.c: */
19
20 double  Dvshift = 0.25;         /* vertical shift for diacriticals on tall letters */
21 double  Dhshift = 0.025;        /* horizontal shift for tall letters */
22 double  Dh2shift = 0.05;        /* horizontal shift for small letters */
23 double  Dheight = 0.25;         /* increment to height for diacriticals */
24 double  Barv    = 0.68;         /* vertical shift for bar */
25 double  Barh    = 0.05;         /* 1/2 horizontal shrink for bar */
26 double  Ubarv   = 0.1;          /* shift underbar up this much ems */
27 double  Ubarh   = 0.05;         /* 1/2 horizontal shrink for underbar */
28
29 /* Also:
30         Vec, Dyad, Hat, Tilde, Dot, Dotdot, Utilde */
31
32 /* eqnbox.c: */
33
34 char    *IRspace = "\\^";       /* space between italic & roman boxes */
35
36 /* fat.c: */
37
38 double  Fatshift = 0.05;        /* fattening shifts by Fatshift ems */
39
40 /* funny.c: */
41
42 int     Funnyps = 5;            /* point size change (== 5 above) */
43 double  Funnyht = 0.2;          /* height correction */
44 double  Funnybase = 0.3;        /* base correction */
45
46 /* integral.c: */
47
48 int     Intps   = 4;            /* point size change for integral (== 4 above) */
49 double  Intht   = 1.15;         /* ht of integral in ems */
50 double  Intbase = 0.3;          /* base in ems */
51 double  Int1h   = 0.4;          /* lower limit left */
52 double  Int1v   = 0.2;          /* lower limit down */
53 double  Int2h   = 0.05;         /* upper limit right was 8 */
54 double  Int2v   = 0.1;          /* upper limit up */
55
56 /* matrix.c: */
57
58 char    *Matspace = "\\ \\ ";   /* space between matrix columns */
59
60 /* over.c: */
61
62 double  Overgap = 0.3;          /* gap between num and denom */
63 double  Overwid = 0.5;          /* extra width of box */
64 double  Overline = 0.1;         /* extra length of fraction bar */
65
66 /* paren.c* */
67
68 double  Parenbase = 0.4;        /* shift of base for even count */
69 double  Parenshift = 0.13;      /* how much to shift parens down in left ... */
70                                 /* ignored unless postscript */
71 double  Parenheight = 0.3;      /* extra height above builtups */
72
73 /* pile.c: */
74
75 double  Pilegap = 0.4;          /* gap between pile elems */
76 double  Pilebase = 0.5;         /* shift base of even # of piled elems */
77
78 /* shift.c: */
79
80 double  Subbase = 0.2;          /* subscript base belowe main base */
81 double  Supshift = 0.4;         /* superscript .4 up main box */
82 char    *Sub1space = "\\|";     /* italic sub roman space */
83 char    *Sup1space = "\\|";     /* italic sup roman space */
84 char    *Sub2space = "\\^";     /* space after subscripted thing */
85 char    *SS1space = "\\^";      /* space before sub in x sub i sup j */
86 char    *SS2space = "\\^";      /* space before sup */
87
88 /* sqrt.c: */
89         /* sqrt is hard!  punt for now. */
90         /* part of the problem is that every typesetter does it differently */
91         /* and we have several typesetters to run. */
92
93 /* text.c: */
94         /* ought to be done by a table */
95
96 struct tune {
97         char    *name;
98         char    *cval;
99 } tune[]        ={
100   /* diacrit.c */
101         "vec_def",      "\\f1\\v'-.5m'\\s-3\\(->\\s0\\v'.5m'\\fP",      /* was \s-2 & .45m */
102         "dyad_def",     "\\f1\\v'-.5m'\\s-3\\z\\(<-\\|\\(->\\s0\\v'.5m'\\fP",
103         "hat_def",      "\\f1\\v'-.05m'\\s+1^\\s0\\v'.05m'\\fP",        /* was .1 */
104         "tilde_def",    "\\f1\\v'-.05m'\\s+1~\\s0\\v'.05m'\\fP",
105         "dot_def",      "\\f1\\v'-.67m'.\\v'.67m'\\fP",
106         "dotdot_def",   "\\f1\\v'-.67m'..\\v'.67m'\\fP",
107         "utilde_def",   "\\f1\\v'1.0m'\\s+2~\\s-2\\v'-1.0m'\\fP",
108   /* funny.c */
109         "sum_def",      "\\|\\v'.3m'\\s+5\\(*S\\s-5\\v'-.3m'\\|",
110         "union_def",    "\\|\\v'.3m'\\s+5\\(cu\\s-5\\v'-.3m'\\|",
111         "inter_def",    "\\|\\v'.3m'\\s+5\\(ca\\s-5\\v'-.3m'\\|",
112         "prod_def",     "\\|\\v'.3m'\\s+5\\(*P\\s-5\\v'-.3m'\\|",
113   /* integral.c */
114         "int_def",      "\\v'.1m'\\s+4\\(is\\s-4\\v'-.1m'",
115         0, 0
116 };
117
118 tbl     *ftunetbl[TBLSIZE];     /* user-defined names */
119
120 char *ftunes[] ={       /* this table intentionally left small */
121         "Subbase",
122         "Supshift",
123         0
124 };
125
126 void init_tune(void)
127 {
128         int i;
129
130         for (i = 0; tune[i].name != NULL; i++)
131                 install(deftbl, tune[i].name, tune[i].cval, 0);
132         for (i = 0; ftunes[i] != NULL; i++)
133                 install(ftunetbl, ftunes[i], (char *) 0, 0);
134 }
135
136 #define eq(s, t) (strcmp(s,t) == 0)
137
138 void ftune(char *s, char *t)    /* brute force for now */
139 {
140         double f = atof(t);
141         double *target;
142
143         while (*t == ' ' || *t == '\t')
144                 t++;
145         if (eq(s, "Subbase"))
146                 target = &Subbase;
147         else if (eq(s, "Supshift"))
148                 target = &Supshift;
149         if (t[0] == '+' || t[0] == '-')
150                 *target += f;
151         else
152                 *target = f;
153 }