/
hinting.xgf
228 lines (190 loc) · 6.02 KB
/
hinting.xgf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?xml version="1.0" encoding="UTF-8"?>
<xgridfit xmlns="http://xgridfit.sourceforge.net/Xgridfit2">
<constant name="sqrt2" value="1.414213562" />
<control-value name="stem" value="128" />
<!--
The stem size rounded up to the nearest integer multiple of the grid size.
The value is set in the pre-program.
-->
<control-value name="rounded-stem" value="0" />
<!--
The x and y components of the diagonal stem size.
The value is set in the pre-program.
-->
<control-value name="diag-proj" value="0" />
<!--
The x and y components of the diagonal stem size rounded up to the nearest integer multiple of half
the grid size.
The value is set in the pre-program.
-->
<control-value name="rounded-diag-proj" value="0" />
<!--
rounded-diag-proj - 0.5
The value is set in the pre-program.
-->
<control-value name="rounded-diag-proj-minus-half" value="0" />
<!--
rounded-diag-proj - 1.0
The value is set in the pre-program.
-->
<control-value name="rounded-diag-proj-minus-one" value="0" />
<pre-program>
<!-- Turns off drop-out-control -->
<set-dropout-control flags="0" threshold="0" />
<set-dropout-type value="2" />
<with-round-state round="to-grid">
<set-control-value name="rounded-stem" unit="pixel" value="round(control-value(stem))" />
</with-round-state>
<!--
The size of every stem is the length of its projection onto a line orthogonal to it.
Let D be a vector orthogonal to a diagonal stem.
Let the magnitude of D be the same as the size of the diagonal stem.
Then x-comp(D)^2 + y-comp(D)^2 = mag(D)^2.
Since every diagonal stem is at an angle that is an integer multiple of 45 degrees then it holds
that x-comp(D) = y-comp(D).
Let a = x-comp(D) = y-comp(D). Let d = mag(D).
Then a^2 + a^2 = d^2.
Then 2 * a^2 = d^2.
Then sqrt(2) * a = d.
Then a = d / sqrt(2).
The goal is to have the size of every stem be the same.
This size is going to be the control value named 'rounded-stem'.
Hence it is required that d = rounded-stem. Hence a = rounded-stem / sqrt(2).
The control value diag-proj is going to be used to control the x and y components of the size of
the diagonal stem.
-->
<set-control-value name="diag-proj" unit="pixel" value="(control-value(rounded-stem)) / sqrt2" />
<with-round-state round="to-double-grid">
<set-control-value name="rounded-diag-proj" unit="pixel"
value="round(control-value(diag-proj))" />
</with-round-state>
<set-control-value name="rounded-diag-proj-minus-half" unit="pixel"
value="control-value(rounded-diag-proj) - 0.5" />
<set-control-value name="rounded-diag-proj-minus-one" unit="pixel"
value="control-value(rounded-diag-proj) - 1.0" />
</pre-program>
<glyph ps-name="exclam">
<!-- square -->
<with-vectors axis="x">
<move>
<point num="18" />
<shift>
<point num="19" />
</shift>
</move>
<move distance="rounded-stem" round="no">
<reference>
<point num="18" />
</reference>
<point num="21" />
<shift>
<point num="20" />
</shift>
</move>
</with-vectors>
<!-- diagonal line -->
<with-vectors axis="x">
<move round="to-half-grid">
<point num="14" />
<shift>
<point num="15" />
<point num="16" />
<point num="17" />
</shift>
</move>
</with-vectors>
<with-vectors axis="y">
<move round="to-grid">
<point num="14" />
<shift>
<point num="15" />
<point num="16" />
<point num="17" />
</shift>
</move>
</with-vectors>
<line name="diagonal-line">
<point num="14" />
<point num="17" />
</line>
<with-freedom-vector to-line="orthogonal">
<line ref="diagonal-line" />
<with-projection-vector axis="x">
<move distance="rounded-diag-proj-minus-half" min-distance="0.5" round="no">
<reference>
<point num="14" />
</reference>
<point num="15" />
</move>
<move distance="rounded-diag-proj-minus-half" min-distance="0.5" round="no">
<reference>
<point num="17" />
</reference>
<point num="16" />
</move>
</with-projection-vector>
</with-freedom-vector>
</glyph>
<glyph ps-name="quotedbl">
<!-- square -->
<with-vectors axis="x">
<move>
<point num="18" />
<shift>
<point num="19" />
</shift>
</move>
<move distance="rounded-stem" round="no">
<reference>
<point num="18" />
</reference>
<point num="21" />
<shift>
<point num="20" />
</shift>
</move>
</with-vectors>
<!-- diagonal line -->
<with-vectors axis="x">
<move round="to-grid">
<point num="14" />
<shift>
<point num="15" />
<point num="16" />
<point num="17" />
</shift>
</move>
</with-vectors>
<with-vectors axis="y">
<move round="to-grid">
<point num="14" />
<shift>
<point num="15" />
<point num="16" />
<point num="17" />
</shift>
</move>
</with-vectors>
<line name="diagonal-line">
<point num="14" />
<point num="17" />
</line>
<with-freedom-vector to-line="orthogonal">
<line ref="diagonal-line" />
<with-projection-vector axis="x">
<move distance="rounded-diag-proj-minus-one" min-distance="no" round="no">
<reference>
<point num="14" />
</reference>
<point num="15" />
</move>
<move distance="rounded-diag-proj-minus-one" min-distance="no" round="no">
<reference>
<point num="17" />
</reference>
<point num="16" />
</move>
</with-projection-vector>
</with-freedom-vector>
</glyph>
</xgridfit>