Home | History | Annotate | Download | only in autofit
      1 //  afblue.dat
      2 //
      3 //    Auto-fitter data for blue strings.
      4 //
      5 //  Copyright 2013, 2014 by
      6 //  David Turner, Robert Wilhelm, and Werner Lemberg.
      7 //
      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.
     13 
     14 
     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.
     18 //
     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).
     26 //
     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.
     30 //
     31 // There are two possible representations for array data.
     32 //
     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.
     42 //
     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.
     49 //
     50 // A section can contain either strings only or data blocks only.
     51 //
     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.
     56 //
     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.
     64 
     65 
     66 // The blue zone string data, to be used in the blue stringsets below.
     67 
     68 AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
     69 
     70   AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
     71     ""
     72   AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
     73     ""
     74   AF_BLUE_STRING_CYRILLIC_SMALL
     75     ""
     76   AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
     77     ""
     78 
     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
     82     "       "
     83   AF_BLUE_STRING_DEVANAGARI_TOP
     84     "       "
     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
     89     "       "
     90   AF_BLUE_STRING_DEVANAGARI_BOTTOM
     91     " "
     92 
     93   AF_BLUE_STRING_GREEK_CAPITAL_TOP
     94     ""
     95   AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM
     96     ""
     97   AF_BLUE_STRING_GREEK_SMALL_BETA_TOP
     98     ""
     99   AF_BLUE_STRING_GREEK_SMALL
    100     ""
    101   AF_BLUE_STRING_GREEK_SMALL_DESCENDER
    102     ""
    103 
    104   AF_BLUE_STRING_HEBREW_TOP
    105     ""
    106   AF_BLUE_STRING_HEBREW_BOTTOM
    107     ""
    108   AF_BLUE_STRING_HEBREW_DESCENDER
    109     ""
    110 
    111   AF_BLUE_STRING_LATIN_CAPITAL_TOP
    112     "THEZOCQS"
    113   AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
    114     "HEZLOCUS"
    115   AF_BLUE_STRING_LATIN_SMALL_F_TOP
    116     "fijkdbh"
    117   AF_BLUE_STRING_LATIN_SMALL
    118     "xzroesc"
    119   AF_BLUE_STRING_LATIN_SMALL_DESCENDER
    120     "pqgjy"
    121 
    122 #ifdef AF_CONFIG_OPTION_CJK
    123 
    124   AF_BLUE_STRING_CJK_TOP
    125     ""
    126     ""
    127     ""
    128     " |"
    129     ""
    130     ""
    131     ""
    132     ""
    133   AF_BLUE_STRING_CJK_BOTTOM
    134     ""
    135     ""
    136     ""
    137     " |"
    138     ""
    139     ""
    140     ""
    141     ""
    142 
    143 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
    144 
    145   AF_BLUE_STRING_CJK_LEFT
    146     ""
    147     ""
    148     ""
    149     " |"
    150     ""
    151     ""
    152     ""
    153     ""
    154   AF_BLUE_STRING_CJK_RIGHT
    155     ""
    156     ""
    157     ""
    158     " |"
    159     ""
    160     ""
    161     ""
    162     ""
    163 
    164 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
    165 
    166 #endif /* AF_CONFIG_OPTION_CJK                */
    167 
    168 
    169 // The blue zone stringsets, as used in the script styles, cf. `afstyles.h'.
    170 //
    171 // The AF_BLUE_PROPERTY_XXX flags are defined in `afblue.h'; here some
    172 // explanations.
    173 //
    174 // A blue zone in general is defined by a reference and an overshoot line.
    175 // During the hinting process, all coordinate values between those two lines
    176 // are set equal to the reference value, provided that the blue zone is not
    177 // wider than 0.75 pixels (otherwise the blue zone gets ignored).  All
    178 // entries must have `AF_BLUE_STRING_MAX' as the final line.
    179 //
    180 // During the glyph analysis, edges are sorted from bottom to top, and then
    181 // sequentially checked, edge by edge, against the blue zones in the order
    182 // given below.
    183 //
    184 //
    185 // latin auto-hinter
    186 // -----------------
    187 //
    188 // Characters in a blue string are automatically classified as having a flat
    189 // (reference) or a round (overshoot) extremum.  The blue zone is then set
    190 // up by the mean values of all flat extrema and all round extrema,
    191 // respectively.  Only horizontal blue zones (i.e., adjusting vertical
    192 // coordinate values) are supported.
    193 //
    194 // For the latin auto-hinter, the overshoot should be larger than the
    195 // reference for top zones, and vice versa for bottom zones.
    196 //
    197 //   LATIN_TOP
    198 //     Take the maximum flat and round coordinate values of the blue string
    199 //     characters for computing the blue zone's reference and overshoot
    200 //     values.
    201 //
    202 //     If not set, take the minimum values.
    203 //
    204 //   LATIN_NEUTRAL
    205 //     Ignore round extrema and define the blue zone with flat values only.
    206 //     Both top and bottom of contours can match.  This is useful for
    207 //     scripts like Devanagari where vowel signs attach to the base
    208 //     character and are implemented as components of composite glyphs.
    209 //
    210 //     If not set, both round and flat extrema are taken into account.
    211 //     Additionally, only the top or the bottom of a contour can match,
    212 //     depending on the LATIN_TOP flag.
    213 //
    214 //     Neutral blue zones should always follow non-neutral blue zones.
    215 //
    216 //   LATIN_X_HEIGHT
    217 //     Scale all glyphs vertically from the corresponding script to make the
    218 //     reference line of this blue zone align on the grid.  The scaling
    219 //     takes place before all other blue zones get aligned to the grid.
    220 //     Only one blue character string of a script style can have this flag.
    221 //
    222 //   LATIN_LONG
    223 //     Apply an additional constraint for blue zone values: Don't
    224 //     necessarily use the extremum as-is but a segment of the topmost (or
    225 //     bottommost) contour that is longer than a heuristic threshold, and
    226 //     which is not too far away vertically from the real extremum.  This
    227 //     ensures that small bumps in the outline are ignored (for example, the
    228 //     `vertical serifs' found in many Hebrew glyph designs).
    229 //
    230 //     The segment must be at least EM/25 font units long, and the distance
    231 //     to the extremum must be smaller than EM/4.
    232 //
    233 //
    234 // cjk auto-hinter
    235 // ---------------
    236 //
    237 // Characters in a blue string are *not* automatically classified.  Instead,
    238 // first come the characters used for the overshoot value, then the
    239 // character `|', then the characters used for the reference value.  The
    240 // blue zone is then set up by the mean values of all reference values and
    241 // all overshoot values, respectively.  Both horizontal and vertical blue
    242 // zones (i.e., adjusting vertical and horizontal coordinate values,
    243 // respectively) are supported.
    244 //
    245 // For the cjk auto-hinter, the overshoot should be smaller than the
    246 // reference for top zones, and vice versa for bottom zones.
    247 //
    248 //   CJK_TOP
    249 //     Take the maximum flat and round coordinate values of the blue string
    250 //     characters.  If not set, take the minimum values.
    251 //
    252 //   CJK_RIGHT
    253 //     A synonym for CJK_TOP.  If CJK_HORIZ is set, this flag indicates the
    254 //     right blue zone, taking horizontal maximum values.
    255 //
    256 //   CJK_HORIZ
    257 //     Define a blue zone for horizontal hinting (i.e., vertical blue
    258 //     zones).  If not set, this is a blue zone for vertical hinting.
    259 
    260 
    261 AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
    262 
    263   AF_BLUE_STRINGSET_CYRL
    264     { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    265     { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 }
    266     { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    267                                                AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    268     { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 }
    269     { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 }
    270     { AF_BLUE_STRING_MAX,                      0                                 }
    271 
    272   AF_BLUE_STRINGSET_DEVA
    273     { AF_BLUE_STRING_DEVANAGARI_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    274     { AF_BLUE_STRING_DEVANAGARI_HEAD,   AF_BLUE_PROPERTY_LATIN_TOP        }
    275     { AF_BLUE_STRING_DEVANAGARI_BASE,   AF_BLUE_PROPERTY_LATIN_TOP      |
    276                                         AF_BLUE_PROPERTY_LATIN_NEUTRAL  |
    277                                         AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    278     { AF_BLUE_STRING_DEVANAGARI_BASE,   0                                 }
    279     { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0                                 }
    280     { AF_BLUE_STRING_MAX,               0                                 }
    281 
    282   AF_BLUE_STRINGSET_GREK
    283     { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    284     { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  0                                 }
    285     { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP        }
    286     { AF_BLUE_STRING_GREEK_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    287                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    288     { AF_BLUE_STRING_GREEK_SMALL,           0                                 }
    289     { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                 }
    290     { AF_BLUE_STRING_MAX,                   0                                 }
    291 
    292   AF_BLUE_STRINGSET_HEBR
    293     { AF_BLUE_STRING_HEBREW_TOP,       AF_BLUE_PROPERTY_LATIN_TOP  |
    294                                        AF_BLUE_PROPERTY_LATIN_LONG   }
    295     { AF_BLUE_STRING_HEBREW_BOTTOM,    0                             }
    296     { AF_BLUE_STRING_HEBREW_DESCENDER, 0                             }
    297     { AF_BLUE_STRING_MAX,              0                             }
    298 
    299   AF_BLUE_STRINGSET_LATN
    300     { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    301     { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 }
    302     { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    303     { AF_BLUE_STRING_LATIN_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    304                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    305     { AF_BLUE_STRING_LATIN_SMALL,           0                                 }
    306     { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 }
    307     { AF_BLUE_STRING_MAX,                   0                                 }
    308 
    309 #ifdef AF_CONFIG_OPTION_CJK
    310 
    311   AF_BLUE_STRINGSET_HANI
    312     { AF_BLUE_STRING_CJK_TOP,    AF_BLUE_PROPERTY_CJK_TOP     }
    313     { AF_BLUE_STRING_CJK_BOTTOM, 0                            }
    314 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
    315     { AF_BLUE_STRING_CJK_LEFT,   AF_BLUE_PROPERTY_CJK_HORIZ   }
    316     { AF_BLUE_STRING_CJK_RIGHT,  AF_BLUE_PROPERTY_CJK_HORIZ |
    317                                  AF_BLUE_PROPERTY_CJK_RIGHT   }
    318 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
    319     { AF_BLUE_STRING_MAX,        0                            }
    320 
    321 #endif /* AF_CONFIG_OPTION_CJK                */
    322 
    323 
    324 // END
    325