tuning.c 4.3 KB

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