1 /* This header file gives the metrics for the vector fonts. */
2 
3 /* Our choice for stroke width, in terms of virtual pixels.  This number is
4    magic: just slightly greater than sqrt(2), so that adjacent strokes that
5    are inclined at a 45 degree angle will overlap as they should.
6 
7    (According to ``Calligraphy for Computers'', the Hershey fonts were
8    designed to be drawn by an electron beam the intensity of which fell to
9    50% at a transverse displacement of one unit.) */
10 
11 #define HERSHEY_STROKE_WIDTH 1.42
12 
13 /* This value gives good results for the Japanese characters (Kana and
14    Kanji). */
15 #define HERSHEY_ORIENTAL_STROKE_WIDTH 1.175
16 
17 /* According to Allen Hershey, 1 em = 32 virtual pixels for his alphabets
18    of principal size.  But taking into account the width of the strokes
19    (nominally 1 virtual pixel), if the characters are thought of as resting
20    on a baseline, the baseline (and the capline, etc.) should be located at
21    half-integer values of the vertical coordinate.  That changes things
22    slightly (an em should be 33 virtual pixels, not 32).
23 
24    Incidentally his recommended spacing between lines is 40 pixels (24 for
25    indexical size), i.e., 1.2 em or so (1 em is the minimum possible
26    spacing).
27 */
28 
29 /* Dimensions for characters in principal [large] size.  The `centerline'
30    is located at y=0, in the original coordinate system.  The `topline' and
31    `bottomline' are determined by the tallest characters, which are
32    parentheses, brackets, and braces. */
33 
34 #define HERSHEY_LARGE_BASELINE (-9.5)	/* relative to centerline */
35 #define HERSHEY_LARGE_CAPLINE 12.5	/* relative to centerline */
36 #define HERSHEY_LARGE_TOPLINE 16.5	/* relative to centerline */
37 #define HERSHEY_LARGE_BOTTOMLINE -16.5 /* relative to centerline */
38 
39 #define HERSHEY_LARGE_CAPHEIGHT 22 /* i.e. capline - baseline */
40 #define HERSHEY_LARGE_ASCENT 26	/* i.e. topline - baseline */
41 #define HERSHEY_LARGE_DESCENT 7	/* i.e. baseline - bottomline */
42 #define HERSHEY_LARGE_HEIGHT (HERSHEY_LARGE_ASCENT + HERSHEY_LARGE_DESCENT)
43 #define HERSHEY_LARGE_EM 33
44 
45 /* Dimensions for characters in indexical [medium] size.  The `centerline'
46    is located at y=0, in the original coordinate system.  The `topline' and
47    `bottomline' are determined by the tallest characters, which are
48    parentheses, brackets, and braces. */
49 
50 #define HERSHEY_MEDIUM_BASELINE (-6.5)	/* relative to centerline */
51 #define HERSHEY_MEDIUM_CAPLINE 7.5	/* relative to centerline */
52 #define HERSHEY_MEDIUM_TOPLINE 10.5	/* relative to centerline */
53 #define HERSHEY_MEDIUM_BOTTOMLINE -10.5 /* relative to centerline */
54 
55 #define HERSHEY_MEDIUM_CAPHEIGHT 14	/* i.e. capline - baseline */
56 #define HERSHEY_MEDIUM_ASCENT 17	/* i.e. topline - baseline */
57 #define HERSHEY_MEDIUM_DESCENT 4	/* i.e. baseline - bottomline */
58 #define HERSHEY_MEDIUM_HEIGHT (HERSHEY_MEDIUM_ASCENT + HERSHEY_MEDIUM_DESCENT)
59 #define HERSHEY_MEDIUM_EM 21
60 
61 /* Dimensions for characters in cartographic [small] size.  The
62    `centerline' is located at y=0, in the original coordinate system.  The
63    `topline' and `bottomline' are determined by the tallest characters,
64    which are parentheses, brackets, and braces.  In the cartographic size
65    there are only parentheses, and unlike the other two sizes they are not
66    symmetric about y=0 (since they will surround only upper-case letters;
67    there are no lower-case letters in cartographic). */
68 
69 #define HERSHEY_SMALL_BASELINE (-4.5)	/* relative to centerline */
70 #define HERSHEY_SMALL_CAPLINE 5.5	/* relative to centerline */
71 #define HERSHEY_SMALL_TOPLINE 6.5	/* relative to centerline */
72 #define HERSHEY_SMALL_BOTTOMLINE -5.5 /* relative to centerline */
73 
74 #define HERSHEY_SMALL_CAPHEIGHT 10	/* i.e. capline - baseline */
75 #define HERSHEY_SMALL_ASCENT 11	/* i.e. topline - baseline */
76 #define HERSHEY_SMALL_DESCENT 1	/* i.e. baseline - bottomline */
77 #define HERSHEY_SMALL_HEIGHT (HERSHEY_SMALL_ASCENT + HERSHEY_SMALL_DESCENT)
78 #define HERSHEY_SMALL_EM 12
79 
80 /* Vertical positionings (in alabel_str.c) are now based on the assumption
81    that all characters we are dealing with are of principal [large] size.
82    I see no graceful way to handle positionings relative to the baseline
83    for the other two sizes.  Of course, centered positioning will work
84    perfectly, since the Hershey glyphs were designed for that. */
85 
86 #define HERSHEY_BASELINE HERSHEY_LARGE_BASELINE
87 #define HERSHEY_ASCENT HERSHEY_LARGE_ASCENT
88 #define HERSHEY_DESCENT HERSHEY_LARGE_DESCENT
89 #define HERSHEY_HEIGHT HERSHEY_LARGE_HEIGHT
90 #define HERSHEY_EM HERSHEY_LARGE_EM
91 
92 /* PAUL MURRELL
93    I have converted HERSHEY_UNITS_TO_USER_UNITS into
94    HERSHEY_X_UNITS_TO_USER_UNITS and HERSHEY_Y_UNITS_TO_USER_UNITS
95    (Not sure how the original authors got away with ignoring
96    the distinction ?)
97    ... and added HERSHEY_UNITS_TO_DEVICE_UNITS
98    ... and replaced HERSHEY_EM with HERSHEY_LARGE_CAPHEIGHT
99 */
100 
101 /* The scaling between distances in Hershey units and distances in user
102    coordinates.  Idea is that the font size (i.e. the nominal minimum
103    inter-line spacing) corresponds to HERSHEY_LARGE_CAPHEIGHT Hershey units. */
104 
105 #define HERSHEY_X_UNITS_TO_USER_UNITS(size) \
106 	((size)*((gc->ps * gc->cex / 72.27) / (dd->dev)->ipr[0])/(HERSHEY_LARGE_HEIGHT))
107 
108 #define HERSHEY_Y_UNITS_TO_USER_UNITS(size) \
109 	((size)*((gc->ps * gc->cex / 72.27) / (dd->dev)->ipr[1])/(HERSHEY_LARGE_HEIGHT))
110 
111 /*
112  * R Graphics Engine line width of 1 is approx 1/96 inches (0.75 points)
113  * We calculate Hershey line width in points and then multiply by 4/3 to
114  * convert to R Graphics Engine line width units
115  */
116 #define HERSHEY_LINE_WIDTH_TO_LWD(width) \
117 	((width)*((4/3)*(gc->ps * gc->cex))/(HERSHEY_LARGE_HEIGHT))
118 
119 /************************************************************************/
120 
121 /* Some miscellaneous information on typesetting mathematics, taken from
122    Allen Hershey's 1969 TR (see g_her_glyph.c):
123 
124    Subscripts and superscripts, in math text, should be in indexical size.
125    The centerline of subscripts/superscripts would be lowered/raised by 10
126    vertical units.
127 
128    [In principal size the centerline is 9.5 units above the baseline; in
129    indexical size the centerline is 6.5 units above the baseline.  So when
130    going to subscripts, the baseline should be lowered by 7 units; when
131    going to superscripts, the baseline should be raised by 13 units.  This
132    is not actually the scheme we use; see alabel_str.c.  -- rsm]
133 
134    In math text the quantity being supplied with a sub/superscript is
135    typically an italic character.  The transitions principal->superscript
136    and subscript->principal are accordingly accompanied by 2 add'l units of
137    horizontal space.
138 
139    In math text, conjuctive/predicative signs should be given a extra
140    spacing of 1/2 en (i.e. 1/4 em), i.e. 8 units in principal size, to
141    either side.  This is accomplished by glyph 2198 (or 1198, in indexical
142    size).
143 
144    Case fractions (e.g. \frac34) are formed by raising/lowering
145    indexical-size characters by 12 vertical units; in mathematical text,
146    they should be given a small (4-unit) spacing to either side.
147 
148    Simple limits, for sum and integral signs, are in indexical size, and
149    are raised/lowered by 24 units. */
150 
151 /************************************************************************/
152