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_CYRILLIC_CAPITAL_TOP
75 TA_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
77 TA_BLUE_STRING_CYRILLIC_SMALL
79 TA_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
82 // we separate the letters with spaces to avoid ligatures;
83 // this is just for convenience to simplify reading
84 TA_BLUE_STRING_DEVANAGARI_BASE
86 TA_BLUE_STRING_DEVANAGARI_TOP
88 // note that some fonts have extreme variation in the height of the
89 // round head elements; for this reason we also define the `base'
90 // blue zone
, which must be always present
91 TA_BLUE_STRING_DEVANAGARI_HEAD
93 TA_BLUE_STRING_DEVANAGARI_BOTTOM
96 TA_BLUE_STRING_GREEK_CAPITAL_TOP
98 TA_BLUE_STRING_GREEK_CAPITAL_BOTTOM
100 TA_BLUE_STRING_GREEK_SMALL_BETA_TOP
102 TA_BLUE_STRING_GREEK_SMALL
104 TA_BLUE_STRING_GREEK_SMALL_DESCENDER
107 TA_BLUE_STRING_HEBREW_TOP
109 TA_BLUE_STRING_HEBREW_BOTTOM
111 TA_BLUE_STRING_HEBREW_DESCENDER
114 TA_BLUE_STRING_LATIN_CAPITAL_TOP
116 TA_BLUE_STRING_LATIN_CAPITAL_BOTTOM
118 TA_BLUE_STRING_LATIN_SMALL_F_TOP
120 TA_BLUE_STRING_LATIN_SMALL
122 TA_BLUE_STRING_LATIN_SMALL_DESCENDER
125 // we separate the letters with spaces
to avoid ligatures
;
126 // this is just for convenience
to simplify reading
127 TA_BLUE_STRING_TELUGU_TOP
129 TA_BLUE_STRING_TELUGU_BOTTOM
132 TA_BLUE_STRING_THAI_TOP
134 TA_BLUE_STRING_THAI_BOTTOM
136 TA_BLUE_STRING_THAI_ASCENDER
138 TA_BLUE_STRING_THAI_LARGE_ASCENDER
140 TA_BLUE_STRING_THAI_DESCENDER
142 TA_BLUE_STRING_THAI_LARGE_DESCENDER
144 TA_BLUE_STRING_THAI_DIGIT_TOP
147 // The blue zone stringsets
, as used
in the script styles
, cf. `tastyles.h
'.
149 // The TA_BLUE_PROPERTY_XXX flags are defined in `tablue.h'; here some
152 // A blue zone
in general is defined
by a reference
and an overshoot line.
153 // During the hinting process
, all coordinate values between those two lines
154 // are
set equal
to the reference value
, provided that the blue zone is
not
155 // wider than
0.75 pixels
(otherwise the blue zone gets ignored
). All
156 // entries must have `TA_BLUE_STRING_MAX
' as the final line.
158 // During the glyph analysis, edges are sorted from bottom to top, and then
159 // sequentially checked, edge by edge, against the blue zones in the order
166 // Characters in a blue string are automatically classified as having a flat
167 // (reference) or a round (overshoot) extremum. The blue zone is then set
168 // up by the mean values of all flat extrema and all round extrema,
169 // respectively. Only horizontal blue zones (i.e., adjusting vertical
170 // coordinate values) are supported.
172 // For the latin auto-hinter, the overshoot should be larger than the
173 // reference for top zones, and vice versa for bottom zones.
176 // Take the maximum flat and round coordinate values of the blue string
177 // characters for computing the blue zone's reference
and overshoot
180 // If
not set, take the minimum values.
183 // Ignore
round extrema
and define the blue zone with flat values only.
184 // Both top
and bottom of contours can match. This is useful for
185 // scripts like Devanagari where vowel signs attach
to the base
186 // character
and are implemented as components of composite glyphs.
188 // If
not set, both
round and flat extrema are taken into account.
189 // Additionally
, only the top
or the bottom of a contour can match
,
190 // depending on the LATIN_TOP flag.
192 // Neutral blue zones should always follow non
-neutral blue zones.
195 // Scale all glyphs vertically
from the corresponding script
to make the
196 // reference line of this blue zone align on the grid. The scaling
197 // takes place before all other blue zones get aligned
to the grid.
198 // Only one blue character string of a script style can have this flag.
201 // Apply an additional constraint for blue zone values
: Don
't
202 // necessarily use the extremum as-is but a segment of the topmost (or
203 // bottommost) contour that is longer than a heuristic threshold, and
204 // which is not too far away vertically from the real extremum. This
205 // ensures that small bumps in the outline are ignored (for example, the
206 // `vertical serifs' found
in many Hebrew glyph designs
).
208 // The segment must be at least EM
/25 font units long
, and the distance
209 // to the extremum must be smaller than EM
/4.
212 TA_BLUE_STRINGSET_ENUM TA_BLUE_STRINGSETS_ARRAY TA_BLUE_STRINGSET_MAX_LEN
:
214 TA_BLUE_STRINGSET_CYRL
215 { TA_BLUE_STRING_CYRILLIC_CAPITAL_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
216 { TA_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
, 0 }
217 { TA_BLUE_STRING_CYRILLIC_SMALL
, TA_BLUE_PROPERTY_LATIN_TOP |
218 TA_BLUE_PROPERTY_LATIN_X_HEIGHT
}
219 { TA_BLUE_STRING_CYRILLIC_SMALL
, 0 }
220 { TA_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
, 0 }
221 { TA_BLUE_STRING_MAX
, 0 }
223 TA_BLUE_STRINGSET_DEVA
224 { TA_BLUE_STRING_DEVANAGARI_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
225 { TA_BLUE_STRING_DEVANAGARI_HEAD
, TA_BLUE_PROPERTY_LATIN_TOP
}
226 { TA_BLUE_STRING_DEVANAGARI_BASE
, TA_BLUE_PROPERTY_LATIN_TOP |
227 TA_BLUE_PROPERTY_LATIN_NEUTRAL |
228 TA_BLUE_PROPERTY_LATIN_X_HEIGHT
}
229 { TA_BLUE_STRING_DEVANAGARI_BASE
, 0 }
230 { TA_BLUE_STRING_DEVANAGARI_BOTTOM
, 0 }
231 { TA_BLUE_STRING_MAX
, 0 }
233 TA_BLUE_STRINGSET_GREK
234 { TA_BLUE_STRING_GREEK_CAPITAL_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
235 { TA_BLUE_STRING_GREEK_CAPITAL_BOTTOM
, 0 }
236 { TA_BLUE_STRING_GREEK_SMALL_BETA_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
237 { TA_BLUE_STRING_GREEK_SMALL
, TA_BLUE_PROPERTY_LATIN_TOP |
238 TA_BLUE_PROPERTY_LATIN_X_HEIGHT
}
239 { TA_BLUE_STRING_GREEK_SMALL
, 0 }
240 { TA_BLUE_STRING_GREEK_SMALL_DESCENDER
, 0 }
241 { TA_BLUE_STRING_MAX
, 0 }
243 TA_BLUE_STRINGSET_HEBR
244 { TA_BLUE_STRING_HEBREW_TOP
, TA_BLUE_PROPERTY_LATIN_TOP |
245 TA_BLUE_PROPERTY_LATIN_LONG
}
246 { TA_BLUE_STRING_HEBREW_BOTTOM
, 0 }
247 { TA_BLUE_STRING_HEBREW_DESCENDER
, 0 }
248 { TA_BLUE_STRING_MAX
, 0 }
250 TA_BLUE_STRINGSET_LATN
251 { TA_BLUE_STRING_LATIN_CAPITAL_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
252 { TA_BLUE_STRING_LATIN_CAPITAL_BOTTOM
, 0 }
253 { TA_BLUE_STRING_LATIN_SMALL_F_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
254 { TA_BLUE_STRING_LATIN_SMALL
, TA_BLUE_PROPERTY_LATIN_TOP |
255 TA_BLUE_PROPERTY_LATIN_X_HEIGHT
}
256 { TA_BLUE_STRING_LATIN_SMALL
, 0 }
257 { TA_BLUE_STRING_LATIN_SMALL_DESCENDER
, 0 }
258 { TA_BLUE_STRING_MAX
, 0 }
260 TA_BLUE_STRINGSET_TELU
261 { TA_BLUE_STRING_TELUGU_TOP
, TA_BLUE_PROPERTY_LATIN_TOP
}
262 { TA_BLUE_STRING_TELUGU_BOTTOM
, 0 }
263 { TA_BLUE_STRING_MAX
, 0 }
265 TA_BLUE_STRINGSET_THAI
266 { TA_BLUE_STRING_THAI_TOP
, TA_BLUE_PROPERTY_LATIN_TOP |
267 TA_BLUE_PROPERTY_LATIN_X_HEIGHT
}
268 { TA_BLUE_STRING_THAI_BOTTOM
, 0 }
269 { TA_BLUE_STRING_THAI_ASCENDER
, TA_BLUE_PROPERTY_LATIN_TOP
}
270 { TA_BLUE_STRING_THAI_LARGE_ASCENDER
, TA_BLUE_PROPERTY_LATIN_TOP
}
271 { TA_BLUE_STRING_THAI_DESCENDER
, 0 }
272 { TA_BLUE_STRING_THAI_LARGE_DESCENDER
, 0 }
273 { TA_BLUE_STRING_THAI_DIGIT_TOP
, 0 }
274 { TA_BLUE_STRING_MAX
, 0 }