modules/freetype2/include/ftautoh.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/freetype2/include/ftautoh.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,402 @@
     1.4 +/***************************************************************************/
     1.5 +/*                                                                         */
     1.6 +/*  ftautoh.h                                                              */
     1.7 +/*                                                                         */
     1.8 +/*    FreeType API for controlling the auto-hinter (specification only).   */
     1.9 +/*                                                                         */
    1.10 +/*  Copyright 2012, 2013 by                                                */
    1.11 +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
    1.12 +/*                                                                         */
    1.13 +/*  This file is part of the FreeType project, and may only be used,       */
    1.14 +/*  modified, and distributed under the terms of the FreeType project      */
    1.15 +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    1.16 +/*  this file you indicate that you have read the license and              */
    1.17 +/*  understand and accept it fully.                                        */
    1.18 +/*                                                                         */
    1.19 +/***************************************************************************/
    1.20 +
    1.21 +
    1.22 +#ifndef __FTAUTOH_H__
    1.23 +#define __FTAUTOH_H__
    1.24 +
    1.25 +#include <ft2build.h>
    1.26 +#include FT_FREETYPE_H
    1.27 +
    1.28 +#ifdef FREETYPE_H
    1.29 +#error "freetype.h of FreeType 1 has been loaded!"
    1.30 +#error "Please fix the directory search order for header files"
    1.31 +#error "so that freetype.h of FreeType 2 is found first."
    1.32 +#endif
    1.33 +
    1.34 +
    1.35 +FT_BEGIN_HEADER
    1.36 +
    1.37 +
    1.38 +  /**************************************************************************
    1.39 +   *
    1.40 +   * @section:
    1.41 +   *   auto_hinter
    1.42 +   *
    1.43 +   * @title:
    1.44 +   *   The auto-hinter
    1.45 +   *
    1.46 +   * @abstract:
    1.47 +   *   Controlling the auto-hinting module.
    1.48 +   *
    1.49 +   * @description:
    1.50 +   *   While FreeType's auto-hinter doesn't expose API functions by itself,
    1.51 +   *   it is possible to control its behaviour with @FT_Property_Set and
    1.52 +   *   @FT_Property_Get.  The following lists the available properties
    1.53 +   *   together with the necessary macros and structures.
    1.54 +   *
    1.55 +   *   Note that the auto-hinter's module name is `autofitter' for
    1.56 +   *   historical reasons.
    1.57 +   *
    1.58 +   */
    1.59 +
    1.60 +
    1.61 +  /**************************************************************************
    1.62 +   *
    1.63 +   * @property:
    1.64 +   *   glyph-to-script-map
    1.65 +   *
    1.66 +   * @description:
    1.67 +   *   *Experimental* *only*
    1.68 +   *
    1.69 +   *   The auto-hinter provides various script modules to hint glyphs.
    1.70 +   *   Examples of supported scripts are Latin or CJK.  Before a glyph is
    1.71 +   *   auto-hinted, the Unicode character map of the font gets examined, and
    1.72 +   *   the script is then determined based on Unicode character ranges, see
    1.73 +   *   below.
    1.74 +   *
    1.75 +   *   OpenType fonts, however, often provide much more glyphs than
    1.76 +   *   character codes (small caps, superscripts, ligatures, swashes, etc.),
    1.77 +   *   to be controlled by so-called `features'.  Handling OpenType features
    1.78 +   *   can be quite complicated and thus needs a separate library on top of
    1.79 +   *   FreeType.
    1.80 +   *
    1.81 +   *   The mapping between glyph indices and scripts (in the auto-hinter
    1.82 +   *   sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an
    1.83 +   *   array with `num_glyphs' elements, as found in the font's @FT_Face
    1.84 +   *   structure.  The `glyph-to-script-map' property returns a pointer to
    1.85 +   *   this array, which can be modified as needed.  Note that the
    1.86 +   *   modification should happen before the first glyph gets processed by
    1.87 +   *   the auto-hinter so that the global analysis of the font shapes
    1.88 +   *   actually uses the modified mapping.
    1.89 +   *
    1.90 +   *   The following example code demonstrates how to access it (omitting
    1.91 +   *   the error handling).
    1.92 +   *
    1.93 +   *   {
    1.94 +   *     FT_Library                library;
    1.95 +   *     FT_Face                   face;
    1.96 +   *     FT_Prop_GlyphToScriptMap  prop;
    1.97 +   *
    1.98 +   *
    1.99 +   *     FT_Init_FreeType( &library );
   1.100 +   *     FT_New_Face( library, "foo.ttf", 0, &face );
   1.101 +   *
   1.102 +   *     prop.face = face;
   1.103 +   *
   1.104 +   *     FT_Property_Get( library, "autofitter",
   1.105 +   *                               "glyph-to-script-map", &prop );
   1.106 +   *
   1.107 +   *     // adjust `prop.map' as needed right here
   1.108 +   *
   1.109 +   *     FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
   1.110 +   *   }
   1.111 +   *
   1.112 +   */
   1.113 +
   1.114 +
   1.115 +  /**************************************************************************
   1.116 +   *
   1.117 +   * @enum:
   1.118 +   *   FT_AUTOHINTER_SCRIPT_XXX
   1.119 +   *
   1.120 +   * @description:
   1.121 +   *   *Experimental* *only*
   1.122 +   *
   1.123 +   *   A list of constants used for the @glyph-to-script-map property to
   1.124 +   *   specify the script submodule the auto-hinter should use for hinting a
   1.125 +   *   particular glyph.
   1.126 +   *
   1.127 +   * @values:
   1.128 +   *   FT_AUTOHINTER_SCRIPT_NONE ::
   1.129 +   *     Don't auto-hint this glyph.
   1.130 +   *
   1.131 +   *   FT_AUTOHINTER_SCRIPT_LATIN ::
   1.132 +   *     Apply the latin auto-hinter.  For the auto-hinter, `latin' is a
   1.133 +   *     very broad term, including Cyrillic and Greek also since characters
   1.134 +   *     from those scripts share the same design constraints.
   1.135 +   *
   1.136 +   *     By default, characters from the following Unicode ranges are
   1.137 +   *     assigned to this submodule.
   1.138 +   *
   1.139 +   *     {
   1.140 +   *       U+0020 - U+007F  // Basic Latin (no control characters)
   1.141 +   *       U+00A0 - U+00FF  // Latin-1 Supplement (no control characters)
   1.142 +   *       U+0100 - U+017F  // Latin Extended-A
   1.143 +   *       U+0180 - U+024F  // Latin Extended-B
   1.144 +   *       U+0250 - U+02AF  // IPA Extensions
   1.145 +   *       U+02B0 - U+02FF  // Spacing Modifier Letters
   1.146 +   *       U+0300 - U+036F  // Combining Diacritical Marks
   1.147 +   *       U+0370 - U+03FF  // Greek and Coptic
   1.148 +   *       U+0400 - U+04FF  // Cyrillic
   1.149 +   *       U+0500 - U+052F  // Cyrillic Supplement
   1.150 +   *       U+1D00 - U+1D7F  // Phonetic Extensions
   1.151 +   *       U+1D80 - U+1DBF  // Phonetic Extensions Supplement
   1.152 +   *       U+1DC0 - U+1DFF  // Combining Diacritical Marks Supplement
   1.153 +   *       U+1E00 - U+1EFF  // Latin Extended Additional
   1.154 +   *       U+1F00 - U+1FFF  // Greek Extended
   1.155 +   *       U+2000 - U+206F  // General Punctuation
   1.156 +   *       U+2070 - U+209F  // Superscripts and Subscripts
   1.157 +   *       U+20A0 - U+20CF  // Currency Symbols
   1.158 +   *       U+2150 - U+218F  // Number Forms
   1.159 +   *       U+2460 - U+24FF  // Enclosed Alphanumerics
   1.160 +   *       U+2C60 - U+2C7F  // Latin Extended-C
   1.161 +   *       U+2DE0 - U+2DFF  // Cyrillic Extended-A
   1.162 +   *       U+2E00 - U+2E7F  // Supplemental Punctuation
   1.163 +   *       U+A640 - U+A69F  // Cyrillic Extended-B
   1.164 +   *       U+A720 - U+A7FF  // Latin Extended-D
   1.165 +   *       U+FB00 - U+FB06  // Alphab. Present. Forms (Latin Ligatures)
   1.166 +   *      U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
   1.167 +   *      U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
   1.168 +   *     }
   1.169 +   *
   1.170 +   *   FT_AUTOHINTER_SCRIPT_CJK ::
   1.171 +   *     Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
   1.172 +   *     Vietnamese, and some other scripts.
   1.173 +   *
   1.174 +   *     By default, characters from the following Unicode ranges are
   1.175 +   *     assigned to this submodule.
   1.176 +   *
   1.177 +   *     {
   1.178 +   *       U+1100 - U+11FF  // Hangul Jamo
   1.179 +   *       U+2E80 - U+2EFF  // CJK Radicals Supplement
   1.180 +   *       U+2F00 - U+2FDF  // Kangxi Radicals
   1.181 +   *       U+2FF0 - U+2FFF  // Ideographic Description Characters
   1.182 +   *       U+3000 - U+303F  // CJK Symbols and Punctuation
   1.183 +   *       U+3040 - U+309F  // Hiragana
   1.184 +   *       U+30A0 - U+30FF  // Katakana
   1.185 +   *       U+3100 - U+312F  // Bopomofo
   1.186 +   *       U+3130 - U+318F  // Hangul Compatibility Jamo
   1.187 +   *       U+3190 - U+319F  // Kanbun
   1.188 +   *       U+31A0 - U+31BF  // Bopomofo Extended
   1.189 +   *       U+31C0 - U+31EF  // CJK Strokes
   1.190 +   *       U+31F0 - U+31FF  // Katakana Phonetic Extensions
   1.191 +   *       U+3200 - U+32FF  // Enclosed CJK Letters and Months
   1.192 +   *       U+3300 - U+33FF  // CJK Compatibility
   1.193 +   *       U+3400 - U+4DBF  // CJK Unified Ideographs Extension A
   1.194 +   *       U+4DC0 - U+4DFF  // Yijing Hexagram Symbols
   1.195 +   *       U+4E00 - U+9FFF  // CJK Unified Ideographs
   1.196 +   *       U+A960 - U+A97F  // Hangul Jamo Extended-A
   1.197 +   *       U+AC00 - U+D7AF  // Hangul Syllables
   1.198 +   *       U+D7B0 - U+D7FF  // Hangul Jamo Extended-B
   1.199 +   *       U+F900 - U+FAFF  // CJK Compatibility Ideographs
   1.200 +   *       U+FE10 - U+FE1F  // Vertical forms
   1.201 +   *       U+FE30 - U+FE4F  // CJK Compatibility Forms
   1.202 +   *       U+FF00 - U+FFEF  // Halfwidth and Fullwidth Forms
   1.203 +   *      U+1B000 - U+1B0FF // Kana Supplement
   1.204 +   *      U+1D300 - U+1D35F // Tai Xuan Hing Symbols
   1.205 +   *      U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
   1.206 +   *      U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
   1.207 +   *      U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
   1.208 +   *      U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
   1.209 +   *      U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
   1.210 +   *     }
   1.211 +   *
   1.212 +   *   FT_AUTOHINTER_SCRIPT_INDIC ::
   1.213 +   *     Apply the indic auto-hinter, covering all major scripts from the
   1.214 +   *     Indian sub-continent and some other related scripts like Thai, Lao,
   1.215 +   *     or Tibetan.
   1.216 +   *
   1.217 +   *     By default, characters from the following Unicode ranges are
   1.218 +   *     assigned to this submodule.
   1.219 +   *
   1.220 +   *     {
   1.221 +   *       U+0900 - U+0DFF  // Indic Range
   1.222 +   *       U+0F00 - U+0FFF  // Tibetan
   1.223 +   *       U+1900 - U+194F  // Limbu
   1.224 +   *       U+1B80 - U+1BBF  // Sundanese
   1.225 +   *       U+1C80 - U+1CDF  // Meetei Mayak
   1.226 +   *       U+A800 - U+A82F  // Syloti Nagri
   1.227 +   *      U+11800 - U+118DF // Sharada
   1.228 +   *     }
   1.229 +   *
   1.230 +   *     Note that currently Indic support is rudimentary only, missing blue
   1.231 +   *     zone support.
   1.232 +   *
   1.233 +   */
   1.234 +#define FT_AUTOHINTER_SCRIPT_NONE   0
   1.235 +#define FT_AUTOHINTER_SCRIPT_LATIN  1
   1.236 +#define FT_AUTOHINTER_SCRIPT_CJK    2
   1.237 +#define FT_AUTOHINTER_SCRIPT_INDIC  3
   1.238 +
   1.239 +
   1.240 +  /**************************************************************************
   1.241 +   *
   1.242 +   * @struct:
   1.243 +   *   FT_Prop_GlyphToScriptMap
   1.244 +   *
   1.245 +   * @description:
   1.246 +   *   *Experimental* *only*
   1.247 +   *
   1.248 +   *   The data exchange structure for the @glyph-to-script-map property.
   1.249 +   *
   1.250 +   */
   1.251 +   typedef struct  FT_Prop_GlyphToScriptMap_
   1.252 +   {
   1.253 +     FT_Face   face;
   1.254 +     FT_Byte*  map;
   1.255 +
   1.256 +   } FT_Prop_GlyphToScriptMap;
   1.257 +
   1.258 +
   1.259 +  /**************************************************************************
   1.260 +   *
   1.261 +   * @property:
   1.262 +   *   fallback-script
   1.263 +   *
   1.264 +   * @description:
   1.265 +   *   *Experimental* *only*
   1.266 +   *
   1.267 +   *   If no auto-hinter script module can be assigned to a glyph, a
   1.268 +   *   fallback script gets assigned to it (see also the
   1.269 +   *   @glyph-to-script-map property).  By default, this is
   1.270 +   *   @FT_AUTOHINTER_SCRIPT_CJK.  Using the `fallback-script' property,
   1.271 +   *   this fallback value can be changed.
   1.272 +   *
   1.273 +   *   {
   1.274 +   *     FT_Library  library;
   1.275 +   *     FT_UInt     fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
   1.276 +   *
   1.277 +   *
   1.278 +   *     FT_Init_FreeType( &library );
   1.279 +   *
   1.280 +   *     FT_Property_Set( library, "autofitter",
   1.281 +   *                               "fallback-script", &fallback_script );
   1.282 +   *   }
   1.283 +   *
   1.284 +   * @note:
   1.285 +   *   This property can be used with @FT_Property_Get also.
   1.286 +   *
   1.287 +   *   It's important to use the right timing for changing this value: The
   1.288 +   *   creation of the glyph-to-script map that eventually uses the
   1.289 +   *   fallback script value gets triggered either by setting or reading a
   1.290 +   *   face-specific property like @glyph-to-script-map, or by auto-hinting
   1.291 +   *   any glyph from that face.  In particular, if you have already created
   1.292 +   *   an @FT_Face structure but not loaded any glyph (using the
   1.293 +   *   auto-hinter), a change of the fallback script will affect this face.
   1.294 +   *
   1.295 +   */
   1.296 +
   1.297 +
   1.298 +  /**************************************************************************
   1.299 +   *
   1.300 +   * @property:
   1.301 +   *   default-script
   1.302 +   *
   1.303 +   * @description:
   1.304 +   *   *Experimental* *only*
   1.305 +   *
   1.306 +   *   If Freetype gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
   1.307 +   *   the HarfBuzz library access OpenType features for getting better
   1.308 +   *   glyph coverages, this property sets the (auto-fitter) script to be
   1.309 +   *   used for the default (OpenType) script data of a font's GSUB table.
   1.310 +   *   Features for the default script are intended for all scripts not
   1.311 +   *   explicitly handled in GSUB; an example is a `dlig' feature,
   1.312 +   *   containing the combination of the characters `T', `E', and `L' to
   1.313 +   *   form a `TEL' ligature.
   1.314 +   *
   1.315 +   *   By default, this is @FT_AUTOHINTER_SCRIPT_LATIN.  Using the
   1.316 +   *   `default-script' property, this default value can be changed.
   1.317 +   *
   1.318 +   *   {
   1.319 +   *     FT_Library  library;
   1.320 +   *     FT_UInt     default_script = FT_AUTOHINTER_SCRIPT_NONE;
   1.321 +   *
   1.322 +   *
   1.323 +   *     FT_Init_FreeType( &library );
   1.324 +   *
   1.325 +   *     FT_Property_Set( library, "autofitter",
   1.326 +   *                               "default-script", &default_script );
   1.327 +   *   }
   1.328 +   *
   1.329 +   * @note:
   1.330 +   *   This property can be used with @FT_Property_Get also.
   1.331 +   *
   1.332 +   *   It's important to use the right timing for changing this value: The
   1.333 +   *   creation of the glyph-to-script map that eventually uses the
   1.334 +   *   default script value gets triggered either by setting or reading a
   1.335 +   *   face-specific property like @glyph-to-script-map, or by auto-hinting
   1.336 +   *   any glyph from that face.  In particular, if you have already created
   1.337 +   *   an @FT_Face structure but not loaded any glyph (using the
   1.338 +   *   auto-hinter), a change of the default script will affect this face.
   1.339 +   *
   1.340 +   */
   1.341 +
   1.342 +
   1.343 +  /**************************************************************************
   1.344 +   *
   1.345 +   * @property:
   1.346 +   *   increase-x-height
   1.347 +   *
   1.348 +   * @description:
   1.349 +   *   For ppem values in the range 6~<= ppem <= `increase-x-height', round
   1.350 +   *   up the font's x~height much more often than normally.  If the value
   1.351 +   *   is set to~0, which is the default, this feature is switched off.  Use
   1.352 +   *   this property to improve the legibility of small font sizes if
   1.353 +   *   necessary.
   1.354 +   *
   1.355 +   *   {
   1.356 +   *     FT_Library               library;
   1.357 +   *     FT_Face                  face;
   1.358 +   *     FT_Prop_IncreaseXHeight  prop;
   1.359 +   *
   1.360 +   *
   1.361 +   *     FT_Init_FreeType( &library );
   1.362 +   *     FT_New_Face( library, "foo.ttf", 0, &face );
   1.363 +   *     FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
   1.364 +   *
   1.365 +   *     prop.face  = face;
   1.366 +   *     prop.limit = 14;
   1.367 +   *
   1.368 +   *     FT_Property_Set( library, "autofitter",
   1.369 +   *                               "increase-x-height", &prop );
   1.370 +   *   }
   1.371 +   *
   1.372 +   * @note:
   1.373 +   *   This property can be used with @FT_Property_Get also.
   1.374 +   *
   1.375 +   *   Set this value right after calling @FT_Set_Char_Size, but before
   1.376 +   *   loading any glyph (using the auto-hinter).
   1.377 +   *
   1.378 +   */
   1.379 +
   1.380 +
   1.381 +  /**************************************************************************
   1.382 +   *
   1.383 +   * @struct:
   1.384 +   *   FT_Prop_IncreaseXHeight
   1.385 +   *
   1.386 +   * @description:
   1.387 +   *   The data exchange structure for the @increase-x-height property.
   1.388 +   *
   1.389 +   */
   1.390 +   typedef struct  FT_Prop_IncreaseXHeight_
   1.391 +   {
   1.392 +     FT_Face  face;
   1.393 +     FT_UInt  limit;
   1.394 +
   1.395 +   } FT_Prop_IncreaseXHeight;
   1.396 +
   1.397 +
   1.398 + /* */
   1.399 +
   1.400 +FT_END_HEADER
   1.401 +
   1.402 +#endif /* __FTAUTOH_H__ */
   1.403 +
   1.404 +
   1.405 +/* END */

mercurial