3 // Auto-fitter data for blue strings.
5 // Copyright 2013, 2014 by
6 // David Turner, Robert Wilhelm, and Werner Lemberg.
8 // This file is part of the FreeType project, and may only be used,
9 // modified, and distributed under the terms of the FreeType project
10 // license, LICENSE.TXT. By continuing to use, modify, or distribute
11 // this file you indicate that you have read the license and
12 // understand and accept it fully.
15 // This file contains data specific to blue zones. It gets processed by
16 // a script to simulate `jagged arrays', with enumeration values holding
17 // offsets into the arrays.
19 // The format of the file is rather simple: A section starts with three
20 // labels separated by whitespace and followed by a colon (everything in a
21 // single line); the first label gives the name of the enumeration template,
22 // the second the name of the array template, and the third the name of the
23 // `maximum' template, holding the size of the largest array element. The
24 // script then fills the corresponding templates (indicated by `@'
25 // characters around the name).
27 // A section contains one or more data records. Each data record consists
28 // of two or more lines. The first line holds the enumeration name, and the
29 // remaining lines the corresponding array data.
31 // There are two possible representations for array data.
33 // - A string of characters in UTF-8 encoding enclosed in double quotes,
34 // using C syntax. There can be only one string per line, thus the
35 // starting and ending double quote must be the first and last character
36 // in the line, respectively, ignoring whitespace before and after the
37 // string. Space characters within the string are ignored too. If there
38 // are multiple strings (in multiple lines), they are concatenated to a
39 // single string. In the output, a string gets represented as a series of
40 // singles bytes, followed by a zero byte. The enumeration values simply
41 // hold byte offsets to the start of the corresponding strings.
43 // - Data blocks enclosed in balanced braces, which get copied verbatim and
44 // which can span multiple lines. The opening brace of a block must be
45 // the first character of a line (ignoring whitespace), and the closing
46 // brace the last (ignoring whitespace also). The script appends a comma
47 // character after each block and counts the number of blocks to set the
48 // enumeration values.
50 // A section can contain either strings only or data blocks only.
52 // A comment line starts with `//'; it gets removed. A preprocessor
53 // directive line (using the standard syntax of `cpp') starts with `#' and
54 // gets copied verbatim to both the enumeration and the array. Whitespace
55 // outside of a string is insignificant.
57 // Preprocessor directives are ignored while the script computes maximum
58 // values; this essentially means that the maximum values can easily be too
59 // large. Given that the purpose of those values is to create local
60 // fixed-size arrays at compile time for further processing of the blue zone
61 // data, this isn't a problem. Note the the final zero byte of a string is
62 // not counted. Note also that the count holds the number of UTF-8 encoded
63 // characters, not bytes.
66 // The blue zone string data, to be used in the blue stringsets below.
68 AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
70 AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
72 AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
74 AF_BLUE_STRING_CYRILLIC_SMALL
76 AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
79 // we separate the letters with spaces to avoid ligatures;
80 // this is just for convenience to simplify reading
81 AF_BLUE_STRING_DEVANAGARI_BASE
83 AF_BLUE_STRING_DEVANAGARI_TOP
85 // note that some fonts have extreme variation in the height of the
86 // round head elements; for this reason we also define the `base'
87 // blue zone, which must be always present
88 AF_BLUE_STRING_DEVANAGARI_HEAD
90 AF_BLUE_STRING_DEVANAGARI_BOTTOM
93 AF_BLUE_STRING_GREEK_CAPITAL_TOP
95 AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM
97 AF_BLUE_STRING_GREEK_SMALL_BETA_TOP
99 AF_BLUE_STRING_GREEK_SMALL
101 AF_BLUE_STRING_GREEK_SMALL_DESCENDER
104 AF_BLUE_STRING_HEBREW_TOP
106 AF_BLUE_STRING_HEBREW_BOTTOM
108 AF_BLUE_STRING_HEBREW_DESCENDER
111 AF_BLUE_STRING_LATIN_CAPITAL_TOP
113 AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
115 AF_BLUE_STRING_LATIN_SMALL_F_TOP
117 AF_BLUE_STRING_LATIN_SMALL
119 AF_BLUE_STRING_LATIN_SMALL_DESCENDER
122 // we separate the letters with spaces to avoid ligatures;
123 // this is just for convenience to simplify reading
124 AF_BLUE_STRING_TELUGU_TOP
127 AF_BLUE_STRING_TELUGU_BOTTOM
130 #ifdef AF_CONFIG_OPTION_CJK
132 AF_BLUE_STRING_CJK_TOP
141 AF_BLUE_STRING_CJK_BOTTOM
151 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
153 AF_BLUE_STRING_CJK_LEFT
162 AF_BLUE_STRING_CJK_RIGHT
172 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
174 #endif /* AF_CONFIG_OPTION_CJK */
177 // The blue zone stringsets, as used in the script styles, cf. `afstyles.h'.
179 // The AF_BLUE_PROPERTY_XXX flags are defined in `afblue.h'; here some
182 // A blue zone in general is defined by a reference and an overshoot line.
183 // During the hinting process, all coordinate values between those two lines
184 // are set equal to the reference value, provided that the blue zone is not
185 // wider than 0.75 pixels (otherwise the blue zone gets ignored). All
186 // entries must have `AF_BLUE_STRING_MAX' as the final line.
188 // During the glyph analysis, edges are sorted from bottom to top, and then
189 // sequentially checked, edge by edge, against the blue zones in the order
196 // Characters in a blue string are automatically classified as having a flat
197 // (reference) or a round (overshoot) extremum. The blue zone is then set
198 // up by the mean values of all flat extrema and all round extrema,
199 // respectively. Only horizontal blue zones (i.e., adjusting vertical
200 // coordinate values) are supported.
202 // For the latin auto-hinter, the overshoot should be larger than the
203 // reference for top zones, and vice versa for bottom zones.
206 // Take the maximum flat and round coordinate values of the blue string
207 // characters for computing the blue zone's reference and overshoot
210 // If not set, take the minimum values.
213 // Ignore round extrema and define the blue zone with flat values only.
214 // Both top and bottom of contours can match. This is useful for
215 // scripts like Devanagari where vowel signs attach to the base
216 // character and are implemented as components of composite glyphs.
218 // If not set, both round and flat extrema are taken into account.
219 // Additionally, only the top or the bottom of a contour can match,
220 // depending on the LATIN_TOP flag.
222 // Neutral blue zones should always follow non-neutral blue zones.
225 // Scale all glyphs vertically from the corresponding script to make the
226 // reference line of this blue zone align on the grid. The scaling
227 // takes place before all other blue zones get aligned to the grid.
228 // Only one blue character string of a script style can have this flag.
231 // Apply an additional constraint for blue zone values: Don't
232 // necessarily use the extremum as-is but a segment of the topmost (or
233 // bottommost) contour that is longer than a heuristic threshold, and
234 // which is not too far away vertically from the real extremum. This
235 // ensures that small bumps in the outline are ignored (for example, the
236 // `vertical serifs' found in many Hebrew glyph designs).
238 // The segment must be at least EM/25 font units long, and the distance
239 // to the extremum must be smaller than EM/4.
245 // Characters in a blue string are *not* automatically classified. Instead,
246 // first come the characters used for the overshoot value, then the
247 // character `|', then the characters used for the reference value. The
248 // blue zone is then set up by the mean values of all reference values and
249 // all overshoot values, respectively. Both horizontal and vertical blue
250 // zones (i.e., adjusting vertical and horizontal coordinate values,
251 // respectively) are supported.
253 // For the cjk auto-hinter, the overshoot should be smaller than the
254 // reference for top zones, and vice versa for bottom zones.
257 // Take the maximum flat and round coordinate values of the blue string
258 // characters. If not set, take the minimum values.
261 // A synonym for CJK_TOP. If CJK_HORIZ is set, this flag indicates the
262 // right blue zone, taking horizontal maximum values.
265 // Define a blue zone for horizontal hinting (i.e., vertical blue
266 // zones). If not set, this is a blue zone for vertical hinting.
269 AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
271 AF_BLUE_STRINGSET_CYRL
272 { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
273 { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 }
274 { AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
275 AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
276 { AF_BLUE_STRING_CYRILLIC_SMALL, 0 }
277 { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 }
278 { AF_BLUE_STRING_MAX, 0 }
280 AF_BLUE_STRINGSET_DEVA
281 { AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
282 { AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
283 { AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
284 AF_BLUE_PROPERTY_LATIN_NEUTRAL |
285 AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
286 { AF_BLUE_STRING_DEVANAGARI_BASE, 0 }
287 { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 }
288 { AF_BLUE_STRING_MAX, 0 }
290 AF_BLUE_STRINGSET_GREK
291 { AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
292 { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 }
293 { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
294 { AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
295 AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
296 { AF_BLUE_STRING_GREEK_SMALL, 0 }
297 { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 }
298 { AF_BLUE_STRING_MAX, 0 }
300 AF_BLUE_STRINGSET_HEBR
301 { AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
302 AF_BLUE_PROPERTY_LATIN_LONG }
303 { AF_BLUE_STRING_HEBREW_BOTTOM, 0 }
304 { AF_BLUE_STRING_HEBREW_DESCENDER, 0 }
305 { AF_BLUE_STRING_MAX, 0 }
307 AF_BLUE_STRINGSET_LATN
308 { AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
309 { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 }
310 { AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
311 { AF_BLUE_STRING_LATIN_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
312 AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
313 { AF_BLUE_STRING_LATIN_SMALL, 0 }
314 { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 }
315 { AF_BLUE_STRING_MAX, 0 }
317 AF_BLUE_STRINGSET_TELU
318 { AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
319 { AF_BLUE_STRING_TELUGU_BOTTOM, 0 }
320 { AF_BLUE_STRING_MAX, 0 }
322 #ifdef AF_CONFIG_OPTION_CJK
324 AF_BLUE_STRINGSET_HANI
325 { AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP }
326 { AF_BLUE_STRING_CJK_BOTTOM, 0 }
327 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
328 { AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ }
329 { AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
330 AF_BLUE_PROPERTY_CJK_RIGHT }
331 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
332 { AF_BLUE_STRING_MAX, 0 }
334 #endif /* AF_CONFIG_OPTION_CJK */