3 // Auto
-fitter
data for blue strings.
5 // Copyright
(C
) 2013-2015 by Werner Lemberg.
7 // This file is part of the ttfautohint library
, and may only be used
,
8 // modified
, and distributed under the terms given
in `COPYING
'. By
9 // continuing to use, modify, or distribute this file you indicate that you
10 // have read `COPYING' and understand
and accept it fully.
12 // The file `COPYING
' mentioned in the previous paragraph is distributed
13 // with the ttfautohint library.
15 // originally file `afblue.dat' (2013-Sep
-22) from FreeType */
18 // This file contains
data specific
to blue zones. It gets processed
by
19 // a script
to simulate `jagged arrays
', with enumeration values holding
20 // offsets into the arrays.
22 // The format of the file is rather simple: A section starts with three
23 // labels separated by whitespace and followed by a colon (everything in a
24 // single line); the first label gives the name of the enumeration template,
25 // the second the name of the array template, and the third the name of the
26 // `maximum' template
, holding the size of the largest array element. The
27 // script
then fills the corresponding templates
(indicated
by `@
'
28 // characters around the name).
30 // A section contains one or more data records. Each data record consists
31 // of two or more lines. The first line holds the enumeration name, and the
32 // remaining lines the corresponding array data.
34 // There are two possible representations for array data.
36 // - A string of characters in UTF-8 encoding enclosed in double quotes,
37 // using C syntax. There can be only one string per line, thus the
38 // starting and ending double quote must be the first and last character
39 // in the line, respectively, ignoring whitespace before and after the
40 // string. Space characters within the string are ignored too. If there
41 // are multiple strings (in multiple lines), they are concatenated to a
42 // single string. In the output, a string gets represented as a series of
43 // singles bytes, followed by a zero byte. The enumeration values simply
44 // hold byte offsets to the start of the corresponding strings.
46 // - Data blocks enclosed in balanced braces, which get copied verbatim and
47 // which can span multiple lines. The opening brace of a block must be
48 // the first character of a line (ignoring whitespace), and the closing
49 // brace the last (ignoring whitespace also). The script appends a comma
50 // character after each block and counts the number of blocks to set the
51 // enumeration values.
53 // A section can contain either strings only or data blocks only.
55 // A comment line starts with `//'; it gets removed. A preprocessor
56 // directive line
(using the standard syntax of `cpp
') starts with `#' and
57 // gets copied verbatim
to both the enumeration
and the array. Whitespace
58 // outside of a string is insignificant.
60 // Preprocessor directives are ignored while the script computes maximum
61 // values
; this essentially means that the maximum values can easily be too
62 // large. Given that the purpose of those values is
to create local
63 // fixed
-size arrays at compile time for further processing of the blue zone
64 // data, this isn
't a problem. Note the the final zero byte of a string is
65 // not counted. Note also that the count holds the number of UTF-8 encoded
66 // characters, not bytes.
69 // The blue zone string data, to be used in the blue stringsets below.
71 TA_BLUE_STRING_ENUM TA_BLUE_STRINGS_ARRAY TA_BLUE_STRING_MAX_LEN:
73 TA_BLUE_STRING_ARABIC_TOP
75 TA_BLUE_STRING_ARABIC_BOTTOM
77 // We don't necessarily have access
to medial forms via Unicode
in case
78 // Arabic presentational forms are missing. The only character that is
79 // guaranteed
to have the same vertical position with joining
(this is
,
80 // non
-isolated
) forms is U
+0640, ARABIC TATWEEL
, which must join both
81 // round and flat curves.
82 TA_BLUE_STRING_ARABIC_JOIN
85 TA_BLUE_STRING_CYRILLIC_CAPITAL_TOP
87 TA_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
89 TA_BLUE_STRING_CYRILLIC_SMALL
91 TA_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
94 // we separate the letters with spaces
to avoid ligatures
;
95 // this is just for convenience
to simplify reading
96 TA_BLUE_STRING_DEVANAGARI_BASE
98 TA_BLUE_STRING_DEVANAGARI_TOP
100 // note that some fonts have extreme variation
in the height of the
101 // round head elements
; for this reason we also define the `base
'
102 // blue zone, which must be always present
103 TA_BLUE_STRING_DEVANAGARI_HEAD
105 TA_BLUE_STRING_DEVANAGARI_BOTTOM
108 TA_BLUE_STRING_GREEK_CAPITAL_TOP
110 TA_BLUE_STRING_GREEK_CAPITAL_BOTTOM
112 TA_BLUE_STRING_GREEK_SMALL_BETA_TOP
114 TA_BLUE_STRING_GREEK_SMALL
116 TA_BLUE_STRING_GREEK_SMALL_DESCENDER
119 TA_BLUE_STRING_HEBREW_TOP
121 TA_BLUE_STRING_HEBREW_BOTTOM
123 TA_BLUE_STRING_HEBREW_DESCENDER
126 TA_BLUE_STRING_LATIN_CAPITAL_TOP
128 TA_BLUE_STRING_LATIN_CAPITAL_BOTTOM
130 TA_BLUE_STRING_LATIN_SMALL_F_TOP
132 TA_BLUE_STRING_LATIN_SMALL
134 TA_BLUE_STRING_LATIN_SMALL_DESCENDER
137 // we separate the letters with spaces to avoid ligatures;
138 // this is just for convenience to simplify reading
139 TA_BLUE_STRING_TELUGU_TOP
141 TA_BLUE_STRING_TELUGU_BOTTOM
144 TA_BLUE_STRING_THAI_TOP
146 TA_BLUE_STRING_THAI_BOTTOM
148 TA_BLUE_STRING_THAI_ASCENDER
150 TA_BLUE_STRING_THAI_LARGE_ASCENDER
152 TA_BLUE_STRING_THAI_DESCENDER
154 TA_BLUE_STRING_THAI_LARGE_DESCENDER
156 TA_BLUE_STRING_THAI_DIGIT_TOP
159 // The blue zone stringsets, as used in the script styles, cf. `tastyles.h'.
161 // The TA_BLUE_PROPERTY_XXX flags are defined
in `tablue.h
'; here some
164 // A blue zone in general is defined by a reference and an overshoot line.
165 // During the hinting process, all coordinate values between those two lines
166 // are set equal to the reference value, provided that the blue zone is not
167 // wider than 0.75 pixels (otherwise the blue zone gets ignored). All
168 // entries must have `TA_BLUE_STRING_MAX' as the final line.
170 // During the glyph analysis
, edges are sorted
from bottom
to top
, and then
171 // sequentially checked
, edge
by edge
, against the blue zones
in the order
178 // Characters
in a blue string are automatically classified as having a flat
179 // (reference
) or a
round (overshoot
) extremum. The blue zone is
then set
180 // up
by the mean values of all flat extrema
and all
round extrema
,
181 // respectively. Only horizontal blue zones
(i.e.
, adjusting vertical
182 // coordinate values
) are supported.
184 // For the latin auto
-hinter
, the overshoot should be larger than the
185 // reference for top zones
, and vice versa for bottom zones.
188 // Take the maximum flat
and round coordinate values of the blue string
189 // characters for computing the blue zone
's reference and overshoot
192 // If not set, take the minimum values.
195 // Ignore round extrema and define the blue zone with flat values only.
196 // Both top and bottom of contours can match. This is useful for
197 // scripts like Devanagari where vowel signs attach to the base
198 // character and are implemented as components of composite glyphs.
200 // If not set, both round and flat extrema are taken into account.
201 // Additionally, only the top or the bottom of a contour can match,
202 // depending on the LATIN_TOP flag.
204 // Neutral blue zones should always follow non-neutral blue zones.
207 // Scale all glyphs vertically from the corresponding script to make the
208 // reference line of this blue zone align on the grid. The scaling
209 // takes place before all other blue zones get aligned to the grid.
210 // Only one blue character string of a script style can have this flag.
213 // Apply an additional constraint for blue zone values: Don't
214 // necessarily use the extremum as
-is but a segment of the topmost
(or
215 // bottommost
) contour that is longer than a heuristic threshold
, and
216 // which is
not too far away vertically
from the real extremum. This
217 // ensures that small bumps
in the outline are ignored
(for example
, the
218 // `vertical serifs
' found in many Hebrew glyph designs).
220 // The segment must be at least EM/25 font units long, and the distance
221 // to the extremum must be smaller than EM/4.
224 TA_BLUE_STRINGSET_ENUM TA_BLUE_STRINGSETS_ARRAY TA_BLUE_STRINGSET_MAX_LEN:
226 TA_BLUE_STRINGSET_ARAB
227 { TA_BLUE_STRING_ARABIC_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
228 { TA_BLUE_STRING_ARABIC_BOTTOM, 0 }
229 { TA_BLUE_STRING_ARABIC_JOIN, TA_BLUE_PROPERTY_LATIN_NEUTRAL }
230 { TA_BLUE_STRING_MAX, 0 }
232 TA_BLUE_STRINGSET_CYRL
233 { TA_BLUE_STRING_CYRILLIC_CAPITAL_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
234 { TA_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 }
235 { TA_BLUE_STRING_CYRILLIC_SMALL, TA_BLUE_PROPERTY_LATIN_TOP |
236 TA_BLUE_PROPERTY_LATIN_X_HEIGHT }
237 { TA_BLUE_STRING_CYRILLIC_SMALL, 0 }
238 { TA_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 }
239 { TA_BLUE_STRING_MAX, 0 }
241 TA_BLUE_STRINGSET_DEVA
242 { TA_BLUE_STRING_DEVANAGARI_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
243 { TA_BLUE_STRING_DEVANAGARI_HEAD, TA_BLUE_PROPERTY_LATIN_TOP }
244 { TA_BLUE_STRING_DEVANAGARI_BASE, TA_BLUE_PROPERTY_LATIN_TOP |
245 TA_BLUE_PROPERTY_LATIN_NEUTRAL |
246 TA_BLUE_PROPERTY_LATIN_X_HEIGHT }
247 { TA_BLUE_STRING_DEVANAGARI_BASE, 0 }
248 { TA_BLUE_STRING_DEVANAGARI_BOTTOM, 0 }
249 { TA_BLUE_STRING_MAX, 0 }
251 TA_BLUE_STRINGSET_GREK
252 { TA_BLUE_STRING_GREEK_CAPITAL_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
253 { TA_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 }
254 { TA_BLUE_STRING_GREEK_SMALL_BETA_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
255 { TA_BLUE_STRING_GREEK_SMALL, TA_BLUE_PROPERTY_LATIN_TOP |
256 TA_BLUE_PROPERTY_LATIN_X_HEIGHT }
257 { TA_BLUE_STRING_GREEK_SMALL, 0 }
258 { TA_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 }
259 { TA_BLUE_STRING_MAX, 0 }
261 TA_BLUE_STRINGSET_HEBR
262 { TA_BLUE_STRING_HEBREW_TOP, TA_BLUE_PROPERTY_LATIN_TOP |
263 TA_BLUE_PROPERTY_LATIN_LONG }
264 { TA_BLUE_STRING_HEBREW_BOTTOM, 0 }
265 { TA_BLUE_STRING_HEBREW_DESCENDER, 0 }
266 { TA_BLUE_STRING_MAX, 0 }
268 TA_BLUE_STRINGSET_LATN
269 { TA_BLUE_STRING_LATIN_CAPITAL_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
270 { TA_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 }
271 { TA_BLUE_STRING_LATIN_SMALL_F_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
272 { TA_BLUE_STRING_LATIN_SMALL, TA_BLUE_PROPERTY_LATIN_TOP |
273 TA_BLUE_PROPERTY_LATIN_X_HEIGHT }
274 { TA_BLUE_STRING_LATIN_SMALL, 0 }
275 { TA_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 }
276 { TA_BLUE_STRING_MAX, 0 }
278 TA_BLUE_STRINGSET_TELU
279 { TA_BLUE_STRING_TELUGU_TOP, TA_BLUE_PROPERTY_LATIN_TOP }
280 { TA_BLUE_STRING_TELUGU_BOTTOM, 0 }
281 { TA_BLUE_STRING_MAX, 0 }
283 TA_BLUE_STRINGSET_THAI
284 { TA_BLUE_STRING_THAI_TOP, TA_BLUE_PROPERTY_LATIN_TOP |
285 TA_BLUE_PROPERTY_LATIN_X_HEIGHT }
286 { TA_BLUE_STRING_THAI_BOTTOM, 0 }
287 { TA_BLUE_STRING_THAI_ASCENDER, TA_BLUE_PROPERTY_LATIN_TOP }
288 { TA_BLUE_STRING_THAI_LARGE_ASCENDER, TA_BLUE_PROPERTY_LATIN_TOP }
289 { TA_BLUE_STRING_THAI_DESCENDER, 0 }
290 { TA_BLUE_STRING_THAI_LARGE_DESCENDER, 0 }
291 { TA_BLUE_STRING_THAI_DIGIT_TOP, 0 }
292 { TA_BLUE_STRING_MAX, 0 }