Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /***************************************************************************/ |
michael@0 | 2 | /* */ |
michael@0 | 3 | /* ftautoh.h */ |
michael@0 | 4 | /* */ |
michael@0 | 5 | /* FreeType API for controlling the auto-hinter (specification only). */ |
michael@0 | 6 | /* */ |
michael@0 | 7 | /* Copyright 2012, 2013 by */ |
michael@0 | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
michael@0 | 9 | /* */ |
michael@0 | 10 | /* This file is part of the FreeType project, and may only be used, */ |
michael@0 | 11 | /* modified, and distributed under the terms of the FreeType project */ |
michael@0 | 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
michael@0 | 13 | /* this file you indicate that you have read the license and */ |
michael@0 | 14 | /* understand and accept it fully. */ |
michael@0 | 15 | /* */ |
michael@0 | 16 | /***************************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | #ifndef __FTAUTOH_H__ |
michael@0 | 20 | #define __FTAUTOH_H__ |
michael@0 | 21 | |
michael@0 | 22 | #include <ft2build.h> |
michael@0 | 23 | #include FT_FREETYPE_H |
michael@0 | 24 | |
michael@0 | 25 | #ifdef FREETYPE_H |
michael@0 | 26 | #error "freetype.h of FreeType 1 has been loaded!" |
michael@0 | 27 | #error "Please fix the directory search order for header files" |
michael@0 | 28 | #error "so that freetype.h of FreeType 2 is found first." |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | |
michael@0 | 32 | FT_BEGIN_HEADER |
michael@0 | 33 | |
michael@0 | 34 | |
michael@0 | 35 | /************************************************************************** |
michael@0 | 36 | * |
michael@0 | 37 | * @section: |
michael@0 | 38 | * auto_hinter |
michael@0 | 39 | * |
michael@0 | 40 | * @title: |
michael@0 | 41 | * The auto-hinter |
michael@0 | 42 | * |
michael@0 | 43 | * @abstract: |
michael@0 | 44 | * Controlling the auto-hinting module. |
michael@0 | 45 | * |
michael@0 | 46 | * @description: |
michael@0 | 47 | * While FreeType's auto-hinter doesn't expose API functions by itself, |
michael@0 | 48 | * it is possible to control its behaviour with @FT_Property_Set and |
michael@0 | 49 | * @FT_Property_Get. The following lists the available properties |
michael@0 | 50 | * together with the necessary macros and structures. |
michael@0 | 51 | * |
michael@0 | 52 | * Note that the auto-hinter's module name is `autofitter' for |
michael@0 | 53 | * historical reasons. |
michael@0 | 54 | * |
michael@0 | 55 | */ |
michael@0 | 56 | |
michael@0 | 57 | |
michael@0 | 58 | /************************************************************************** |
michael@0 | 59 | * |
michael@0 | 60 | * @property: |
michael@0 | 61 | * glyph-to-script-map |
michael@0 | 62 | * |
michael@0 | 63 | * @description: |
michael@0 | 64 | * *Experimental* *only* |
michael@0 | 65 | * |
michael@0 | 66 | * The auto-hinter provides various script modules to hint glyphs. |
michael@0 | 67 | * Examples of supported scripts are Latin or CJK. Before a glyph is |
michael@0 | 68 | * auto-hinted, the Unicode character map of the font gets examined, and |
michael@0 | 69 | * the script is then determined based on Unicode character ranges, see |
michael@0 | 70 | * below. |
michael@0 | 71 | * |
michael@0 | 72 | * OpenType fonts, however, often provide much more glyphs than |
michael@0 | 73 | * character codes (small caps, superscripts, ligatures, swashes, etc.), |
michael@0 | 74 | * to be controlled by so-called `features'. Handling OpenType features |
michael@0 | 75 | * can be quite complicated and thus needs a separate library on top of |
michael@0 | 76 | * FreeType. |
michael@0 | 77 | * |
michael@0 | 78 | * The mapping between glyph indices and scripts (in the auto-hinter |
michael@0 | 79 | * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an |
michael@0 | 80 | * array with `num_glyphs' elements, as found in the font's @FT_Face |
michael@0 | 81 | * structure. The `glyph-to-script-map' property returns a pointer to |
michael@0 | 82 | * this array, which can be modified as needed. Note that the |
michael@0 | 83 | * modification should happen before the first glyph gets processed by |
michael@0 | 84 | * the auto-hinter so that the global analysis of the font shapes |
michael@0 | 85 | * actually uses the modified mapping. |
michael@0 | 86 | * |
michael@0 | 87 | * The following example code demonstrates how to access it (omitting |
michael@0 | 88 | * the error handling). |
michael@0 | 89 | * |
michael@0 | 90 | * { |
michael@0 | 91 | * FT_Library library; |
michael@0 | 92 | * FT_Face face; |
michael@0 | 93 | * FT_Prop_GlyphToScriptMap prop; |
michael@0 | 94 | * |
michael@0 | 95 | * |
michael@0 | 96 | * FT_Init_FreeType( &library ); |
michael@0 | 97 | * FT_New_Face( library, "foo.ttf", 0, &face ); |
michael@0 | 98 | * |
michael@0 | 99 | * prop.face = face; |
michael@0 | 100 | * |
michael@0 | 101 | * FT_Property_Get( library, "autofitter", |
michael@0 | 102 | * "glyph-to-script-map", &prop ); |
michael@0 | 103 | * |
michael@0 | 104 | * // adjust `prop.map' as needed right here |
michael@0 | 105 | * |
michael@0 | 106 | * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); |
michael@0 | 107 | * } |
michael@0 | 108 | * |
michael@0 | 109 | */ |
michael@0 | 110 | |
michael@0 | 111 | |
michael@0 | 112 | /************************************************************************** |
michael@0 | 113 | * |
michael@0 | 114 | * @enum: |
michael@0 | 115 | * FT_AUTOHINTER_SCRIPT_XXX |
michael@0 | 116 | * |
michael@0 | 117 | * @description: |
michael@0 | 118 | * *Experimental* *only* |
michael@0 | 119 | * |
michael@0 | 120 | * A list of constants used for the @glyph-to-script-map property to |
michael@0 | 121 | * specify the script submodule the auto-hinter should use for hinting a |
michael@0 | 122 | * particular glyph. |
michael@0 | 123 | * |
michael@0 | 124 | * @values: |
michael@0 | 125 | * FT_AUTOHINTER_SCRIPT_NONE :: |
michael@0 | 126 | * Don't auto-hint this glyph. |
michael@0 | 127 | * |
michael@0 | 128 | * FT_AUTOHINTER_SCRIPT_LATIN :: |
michael@0 | 129 | * Apply the latin auto-hinter. For the auto-hinter, `latin' is a |
michael@0 | 130 | * very broad term, including Cyrillic and Greek also since characters |
michael@0 | 131 | * from those scripts share the same design constraints. |
michael@0 | 132 | * |
michael@0 | 133 | * By default, characters from the following Unicode ranges are |
michael@0 | 134 | * assigned to this submodule. |
michael@0 | 135 | * |
michael@0 | 136 | * { |
michael@0 | 137 | * U+0020 - U+007F // Basic Latin (no control characters) |
michael@0 | 138 | * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) |
michael@0 | 139 | * U+0100 - U+017F // Latin Extended-A |
michael@0 | 140 | * U+0180 - U+024F // Latin Extended-B |
michael@0 | 141 | * U+0250 - U+02AF // IPA Extensions |
michael@0 | 142 | * U+02B0 - U+02FF // Spacing Modifier Letters |
michael@0 | 143 | * U+0300 - U+036F // Combining Diacritical Marks |
michael@0 | 144 | * U+0370 - U+03FF // Greek and Coptic |
michael@0 | 145 | * U+0400 - U+04FF // Cyrillic |
michael@0 | 146 | * U+0500 - U+052F // Cyrillic Supplement |
michael@0 | 147 | * U+1D00 - U+1D7F // Phonetic Extensions |
michael@0 | 148 | * U+1D80 - U+1DBF // Phonetic Extensions Supplement |
michael@0 | 149 | * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement |
michael@0 | 150 | * U+1E00 - U+1EFF // Latin Extended Additional |
michael@0 | 151 | * U+1F00 - U+1FFF // Greek Extended |
michael@0 | 152 | * U+2000 - U+206F // General Punctuation |
michael@0 | 153 | * U+2070 - U+209F // Superscripts and Subscripts |
michael@0 | 154 | * U+20A0 - U+20CF // Currency Symbols |
michael@0 | 155 | * U+2150 - U+218F // Number Forms |
michael@0 | 156 | * U+2460 - U+24FF // Enclosed Alphanumerics |
michael@0 | 157 | * U+2C60 - U+2C7F // Latin Extended-C |
michael@0 | 158 | * U+2DE0 - U+2DFF // Cyrillic Extended-A |
michael@0 | 159 | * U+2E00 - U+2E7F // Supplemental Punctuation |
michael@0 | 160 | * U+A640 - U+A69F // Cyrillic Extended-B |
michael@0 | 161 | * U+A720 - U+A7FF // Latin Extended-D |
michael@0 | 162 | * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) |
michael@0 | 163 | * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols |
michael@0 | 164 | * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement |
michael@0 | 165 | * } |
michael@0 | 166 | * |
michael@0 | 167 | * FT_AUTOHINTER_SCRIPT_CJK :: |
michael@0 | 168 | * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old |
michael@0 | 169 | * Vietnamese, and some other scripts. |
michael@0 | 170 | * |
michael@0 | 171 | * By default, characters from the following Unicode ranges are |
michael@0 | 172 | * assigned to this submodule. |
michael@0 | 173 | * |
michael@0 | 174 | * { |
michael@0 | 175 | * U+1100 - U+11FF // Hangul Jamo |
michael@0 | 176 | * U+2E80 - U+2EFF // CJK Radicals Supplement |
michael@0 | 177 | * U+2F00 - U+2FDF // Kangxi Radicals |
michael@0 | 178 | * U+2FF0 - U+2FFF // Ideographic Description Characters |
michael@0 | 179 | * U+3000 - U+303F // CJK Symbols and Punctuation |
michael@0 | 180 | * U+3040 - U+309F // Hiragana |
michael@0 | 181 | * U+30A0 - U+30FF // Katakana |
michael@0 | 182 | * U+3100 - U+312F // Bopomofo |
michael@0 | 183 | * U+3130 - U+318F // Hangul Compatibility Jamo |
michael@0 | 184 | * U+3190 - U+319F // Kanbun |
michael@0 | 185 | * U+31A0 - U+31BF // Bopomofo Extended |
michael@0 | 186 | * U+31C0 - U+31EF // CJK Strokes |
michael@0 | 187 | * U+31F0 - U+31FF // Katakana Phonetic Extensions |
michael@0 | 188 | * U+3200 - U+32FF // Enclosed CJK Letters and Months |
michael@0 | 189 | * U+3300 - U+33FF // CJK Compatibility |
michael@0 | 190 | * U+3400 - U+4DBF // CJK Unified Ideographs Extension A |
michael@0 | 191 | * U+4DC0 - U+4DFF // Yijing Hexagram Symbols |
michael@0 | 192 | * U+4E00 - U+9FFF // CJK Unified Ideographs |
michael@0 | 193 | * U+A960 - U+A97F // Hangul Jamo Extended-A |
michael@0 | 194 | * U+AC00 - U+D7AF // Hangul Syllables |
michael@0 | 195 | * U+D7B0 - U+D7FF // Hangul Jamo Extended-B |
michael@0 | 196 | * U+F900 - U+FAFF // CJK Compatibility Ideographs |
michael@0 | 197 | * U+FE10 - U+FE1F // Vertical forms |
michael@0 | 198 | * U+FE30 - U+FE4F // CJK Compatibility Forms |
michael@0 | 199 | * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms |
michael@0 | 200 | * U+1B000 - U+1B0FF // Kana Supplement |
michael@0 | 201 | * U+1D300 - U+1D35F // Tai Xuan Hing Symbols |
michael@0 | 202 | * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement |
michael@0 | 203 | * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B |
michael@0 | 204 | * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C |
michael@0 | 205 | * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D |
michael@0 | 206 | * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement |
michael@0 | 207 | * } |
michael@0 | 208 | * |
michael@0 | 209 | * FT_AUTOHINTER_SCRIPT_INDIC :: |
michael@0 | 210 | * Apply the indic auto-hinter, covering all major scripts from the |
michael@0 | 211 | * Indian sub-continent and some other related scripts like Thai, Lao, |
michael@0 | 212 | * or Tibetan. |
michael@0 | 213 | * |
michael@0 | 214 | * By default, characters from the following Unicode ranges are |
michael@0 | 215 | * assigned to this submodule. |
michael@0 | 216 | * |
michael@0 | 217 | * { |
michael@0 | 218 | * U+0900 - U+0DFF // Indic Range |
michael@0 | 219 | * U+0F00 - U+0FFF // Tibetan |
michael@0 | 220 | * U+1900 - U+194F // Limbu |
michael@0 | 221 | * U+1B80 - U+1BBF // Sundanese |
michael@0 | 222 | * U+1C80 - U+1CDF // Meetei Mayak |
michael@0 | 223 | * U+A800 - U+A82F // Syloti Nagri |
michael@0 | 224 | * U+11800 - U+118DF // Sharada |
michael@0 | 225 | * } |
michael@0 | 226 | * |
michael@0 | 227 | * Note that currently Indic support is rudimentary only, missing blue |
michael@0 | 228 | * zone support. |
michael@0 | 229 | * |
michael@0 | 230 | */ |
michael@0 | 231 | #define FT_AUTOHINTER_SCRIPT_NONE 0 |
michael@0 | 232 | #define FT_AUTOHINTER_SCRIPT_LATIN 1 |
michael@0 | 233 | #define FT_AUTOHINTER_SCRIPT_CJK 2 |
michael@0 | 234 | #define FT_AUTOHINTER_SCRIPT_INDIC 3 |
michael@0 | 235 | |
michael@0 | 236 | |
michael@0 | 237 | /************************************************************************** |
michael@0 | 238 | * |
michael@0 | 239 | * @struct: |
michael@0 | 240 | * FT_Prop_GlyphToScriptMap |
michael@0 | 241 | * |
michael@0 | 242 | * @description: |
michael@0 | 243 | * *Experimental* *only* |
michael@0 | 244 | * |
michael@0 | 245 | * The data exchange structure for the @glyph-to-script-map property. |
michael@0 | 246 | * |
michael@0 | 247 | */ |
michael@0 | 248 | typedef struct FT_Prop_GlyphToScriptMap_ |
michael@0 | 249 | { |
michael@0 | 250 | FT_Face face; |
michael@0 | 251 | FT_Byte* map; |
michael@0 | 252 | |
michael@0 | 253 | } FT_Prop_GlyphToScriptMap; |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | /************************************************************************** |
michael@0 | 257 | * |
michael@0 | 258 | * @property: |
michael@0 | 259 | * fallback-script |
michael@0 | 260 | * |
michael@0 | 261 | * @description: |
michael@0 | 262 | * *Experimental* *only* |
michael@0 | 263 | * |
michael@0 | 264 | * If no auto-hinter script module can be assigned to a glyph, a |
michael@0 | 265 | * fallback script gets assigned to it (see also the |
michael@0 | 266 | * @glyph-to-script-map property). By default, this is |
michael@0 | 267 | * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, |
michael@0 | 268 | * this fallback value can be changed. |
michael@0 | 269 | * |
michael@0 | 270 | * { |
michael@0 | 271 | * FT_Library library; |
michael@0 | 272 | * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; |
michael@0 | 273 | * |
michael@0 | 274 | * |
michael@0 | 275 | * FT_Init_FreeType( &library ); |
michael@0 | 276 | * |
michael@0 | 277 | * FT_Property_Set( library, "autofitter", |
michael@0 | 278 | * "fallback-script", &fallback_script ); |
michael@0 | 279 | * } |
michael@0 | 280 | * |
michael@0 | 281 | * @note: |
michael@0 | 282 | * This property can be used with @FT_Property_Get also. |
michael@0 | 283 | * |
michael@0 | 284 | * It's important to use the right timing for changing this value: The |
michael@0 | 285 | * creation of the glyph-to-script map that eventually uses the |
michael@0 | 286 | * fallback script value gets triggered either by setting or reading a |
michael@0 | 287 | * face-specific property like @glyph-to-script-map, or by auto-hinting |
michael@0 | 288 | * any glyph from that face. In particular, if you have already created |
michael@0 | 289 | * an @FT_Face structure but not loaded any glyph (using the |
michael@0 | 290 | * auto-hinter), a change of the fallback script will affect this face. |
michael@0 | 291 | * |
michael@0 | 292 | */ |
michael@0 | 293 | |
michael@0 | 294 | |
michael@0 | 295 | /************************************************************************** |
michael@0 | 296 | * |
michael@0 | 297 | * @property: |
michael@0 | 298 | * default-script |
michael@0 | 299 | * |
michael@0 | 300 | * @description: |
michael@0 | 301 | * *Experimental* *only* |
michael@0 | 302 | * |
michael@0 | 303 | * If Freetype gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make |
michael@0 | 304 | * the HarfBuzz library access OpenType features for getting better |
michael@0 | 305 | * glyph coverages, this property sets the (auto-fitter) script to be |
michael@0 | 306 | * used for the default (OpenType) script data of a font's GSUB table. |
michael@0 | 307 | * Features for the default script are intended for all scripts not |
michael@0 | 308 | * explicitly handled in GSUB; an example is a `dlig' feature, |
michael@0 | 309 | * containing the combination of the characters `T', `E', and `L' to |
michael@0 | 310 | * form a `TEL' ligature. |
michael@0 | 311 | * |
michael@0 | 312 | * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the |
michael@0 | 313 | * `default-script' property, this default value can be changed. |
michael@0 | 314 | * |
michael@0 | 315 | * { |
michael@0 | 316 | * FT_Library library; |
michael@0 | 317 | * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; |
michael@0 | 318 | * |
michael@0 | 319 | * |
michael@0 | 320 | * FT_Init_FreeType( &library ); |
michael@0 | 321 | * |
michael@0 | 322 | * FT_Property_Set( library, "autofitter", |
michael@0 | 323 | * "default-script", &default_script ); |
michael@0 | 324 | * } |
michael@0 | 325 | * |
michael@0 | 326 | * @note: |
michael@0 | 327 | * This property can be used with @FT_Property_Get also. |
michael@0 | 328 | * |
michael@0 | 329 | * It's important to use the right timing for changing this value: The |
michael@0 | 330 | * creation of the glyph-to-script map that eventually uses the |
michael@0 | 331 | * default script value gets triggered either by setting or reading a |
michael@0 | 332 | * face-specific property like @glyph-to-script-map, or by auto-hinting |
michael@0 | 333 | * any glyph from that face. In particular, if you have already created |
michael@0 | 334 | * an @FT_Face structure but not loaded any glyph (using the |
michael@0 | 335 | * auto-hinter), a change of the default script will affect this face. |
michael@0 | 336 | * |
michael@0 | 337 | */ |
michael@0 | 338 | |
michael@0 | 339 | |
michael@0 | 340 | /************************************************************************** |
michael@0 | 341 | * |
michael@0 | 342 | * @property: |
michael@0 | 343 | * increase-x-height |
michael@0 | 344 | * |
michael@0 | 345 | * @description: |
michael@0 | 346 | * For ppem values in the range 6~<= ppem <= `increase-x-height', round |
michael@0 | 347 | * up the font's x~height much more often than normally. If the value |
michael@0 | 348 | * is set to~0, which is the default, this feature is switched off. Use |
michael@0 | 349 | * this property to improve the legibility of small font sizes if |
michael@0 | 350 | * necessary. |
michael@0 | 351 | * |
michael@0 | 352 | * { |
michael@0 | 353 | * FT_Library library; |
michael@0 | 354 | * FT_Face face; |
michael@0 | 355 | * FT_Prop_IncreaseXHeight prop; |
michael@0 | 356 | * |
michael@0 | 357 | * |
michael@0 | 358 | * FT_Init_FreeType( &library ); |
michael@0 | 359 | * FT_New_Face( library, "foo.ttf", 0, &face ); |
michael@0 | 360 | * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); |
michael@0 | 361 | * |
michael@0 | 362 | * prop.face = face; |
michael@0 | 363 | * prop.limit = 14; |
michael@0 | 364 | * |
michael@0 | 365 | * FT_Property_Set( library, "autofitter", |
michael@0 | 366 | * "increase-x-height", &prop ); |
michael@0 | 367 | * } |
michael@0 | 368 | * |
michael@0 | 369 | * @note: |
michael@0 | 370 | * This property can be used with @FT_Property_Get also. |
michael@0 | 371 | * |
michael@0 | 372 | * Set this value right after calling @FT_Set_Char_Size, but before |
michael@0 | 373 | * loading any glyph (using the auto-hinter). |
michael@0 | 374 | * |
michael@0 | 375 | */ |
michael@0 | 376 | |
michael@0 | 377 | |
michael@0 | 378 | /************************************************************************** |
michael@0 | 379 | * |
michael@0 | 380 | * @struct: |
michael@0 | 381 | * FT_Prop_IncreaseXHeight |
michael@0 | 382 | * |
michael@0 | 383 | * @description: |
michael@0 | 384 | * The data exchange structure for the @increase-x-height property. |
michael@0 | 385 | * |
michael@0 | 386 | */ |
michael@0 | 387 | typedef struct FT_Prop_IncreaseXHeight_ |
michael@0 | 388 | { |
michael@0 | 389 | FT_Face face; |
michael@0 | 390 | FT_UInt limit; |
michael@0 | 391 | |
michael@0 | 392 | } FT_Prop_IncreaseXHeight; |
michael@0 | 393 | |
michael@0 | 394 | |
michael@0 | 395 | /* */ |
michael@0 | 396 | |
michael@0 | 397 | FT_END_HEADER |
michael@0 | 398 | |
michael@0 | 399 | #endif /* __FTAUTOH_H__ */ |
michael@0 | 400 | |
michael@0 | 401 | |
michael@0 | 402 | /* END */ |