modules/freetype2/include/ftcffdrv.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/freetype2/include/ftcffdrv.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,254 @@
     1.4 +/***************************************************************************/
     1.5 +/*                                                                         */
     1.6 +/*  ftcffdrv.h                                                             */
     1.7 +/*                                                                         */
     1.8 +/*    FreeType API for controlling the CFF driver (specification only).    */
     1.9 +/*                                                                         */
    1.10 +/*  Copyright 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 __FTCFFDRV_H__
    1.23 +#define __FTCFFDRV_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 +   *   cff_driver
    1.42 +   *
    1.43 +   * @title:
    1.44 +   *   The CFF driver
    1.45 +   *
    1.46 +   * @abstract:
    1.47 +   *   Controlling the CFF driver module.
    1.48 +   *
    1.49 +   * @description:
    1.50 +   *   While FreeType's CFF driver 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 list below gives the available properties
    1.53 +   *   together with the necessary macros and structures.
    1.54 +   *
    1.55 +   *   The CFF driver's module name is `cff'.
    1.56 +   *
    1.57 +   *   *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine*
    1.58 +   *
    1.59 +   *   The rasterizer is positioning horizontal features (e.g., ascender
    1.60 +   *   height & x-height, or crossbars) on the pixel grid and minimizing the
    1.61 +   *   amount of antialiasing applied to them, while placing vertical
    1.62 +   *   features (vertical stems) on the pixel grid without hinting, thus
    1.63 +   *   representing the stem position and weight accurately.  Sometimes the
    1.64 +   *   vertical stems may be only partially black.  In this context,
    1.65 +   *   `antialiasing' means that stems are not positioned exactly on pixel
    1.66 +   *   borders, causing a fuzzy appearance.
    1.67 +   *
    1.68 +   *   There are two principles behind this approach.
    1.69 +   *
    1.70 +   *   1) No hinting in the horizontal direction: Unlike `superhinted'
    1.71 +   *   TrueType, which changes glyph widths to accommodate regular
    1.72 +   *   inter-glyph spacing, Adobe's approach is `faithful to the design' in
    1.73 +   *   representing both the glyph width and the inter-glyph spacing
    1.74 +   *   designed for the font.  This makes the screen display as close as it
    1.75 +   *   can be to the result one would get with infinite resolution, while
    1.76 +   *   preserving what is considered the key characteristics of each glyph.
    1.77 +   *   Note that the distances between unhinted and grid-fitted positions at
    1.78 +   *   small sizes are comparable to kerning values and thus would be
    1.79 +   *   noticeable (and distracting) while reading if hinting were applied.
    1.80 +   *
    1.81 +   *   One of the reasons to not hint horizontally is antialiasing for LCD
    1.82 +   *   screens: The pixel geometry of modern displays supplies three
    1.83 +   *   vertical sub-pixels as the eye moves horizontally across each visible
    1.84 +   *   pixel.  On devices where we can be certain this characteristic is
    1.85 +   *   present a rasterizer can take advantage of the sub-pixels to add
    1.86 +   *   increments of weight.  In Western writing systems this turns out to
    1.87 +   *   be the more critical direction anyway; the weights and spacing of
    1.88 +   *   vertical stems (see above) are central to Armenian, Cyrillic, Greek,
    1.89 +   *   and Latin type designs.  Even when the rasterizer uses greyscale
    1.90 +   *   antialiasing instead of color (a necessary compromise when one
    1.91 +   *   doesn't know the screen characteristics), the unhinted vertical
    1.92 +   *   features preserve the design's weight and spacing much better than
    1.93 +   *   aliased type would.
    1.94 +   *
    1.95 +   *   2) Aligment in the vertical direction: Weights and spacing along the
    1.96 +   *   y~axis are less critical; what is much more important is the visual
    1.97 +   *   alignment of related features (like cap-height and x-height).  The
    1.98 +   *   sense of alignment for these is enhanced by the sharpness of grid-fit
    1.99 +   *   edges, while the cruder vertical resolution (full pixels instead of
   1.100 +   *   1/3 pixels) is less of a problem.
   1.101 +   *
   1.102 +   *   On the technical side, horizontal alignment zones for ascender,
   1.103 +   *   x-height, and other important height values (traditionally called
   1.104 +   *   `blue zones') as defined in the font are positioned independently,
   1.105 +   *   each being rounded to the nearest pixel edge, taking care of
   1.106 +   *   overshoot suppression at small sizes, stem darkening, and scaling.
   1.107 +   *
   1.108 +   *   Hstems (this is, hint values defined in the font to help align
   1.109 +   *   horizontal features) that fall within a blue zone are said to be
   1.110 +   *   `captured' and are aligned to that zone.  Uncaptured stems are moved
   1.111 +   *   in one of four ways, top edge up or down, bottom edge up or down.
   1.112 +   *   Unless there are conflicting hstems, the smallest movement is taken
   1.113 +   *   to minimize distortion.
   1.114 +   */
   1.115 +
   1.116 +
   1.117 +  /**************************************************************************
   1.118 +   *
   1.119 +   * @property:
   1.120 +   *   hinting-engine
   1.121 +   *
   1.122 +   * @description:
   1.123 +   *   Thanks to Adobe, which contributed a new hinting (and parsing)
   1.124 +   *   engine, an application can select between `freetype' and `adobe' if
   1.125 +   *   compiled with CFF_CONFIG_OPTION_OLD_ENGINE.  If this configuration
   1.126 +   *   macro isn't defined, `hinting-engine' does nothing.
   1.127 +   *
   1.128 +   *   The default engine is `freetype' if CFF_CONFIG_OPTION_OLD_ENGINE is
   1.129 +   *   defined, and `adobe' otherwise.
   1.130 +   *
   1.131 +   *   The following example code demonstrates how to select Adobe's hinting
   1.132 +   *   engine (omitting the error handling).
   1.133 +   *
   1.134 +   *   {
   1.135 +   *     FT_Library  library;
   1.136 +   *     FT_UInt     hinting_engine = FT_CFF_HINTING_ADOBE;
   1.137 +   *
   1.138 +   *
   1.139 +   *     FT_Init_FreeType( &library );
   1.140 +   *
   1.141 +   *     FT_Property_Set( library, "cff",
   1.142 +   *                               "hinting-engine", &hinting_engine );
   1.143 +   *   }
   1.144 +   *
   1.145 +   * @note:
   1.146 +   *   This property can be used with @FT_Property_Get also.
   1.147 +   *
   1.148 +   */
   1.149 +
   1.150 +
   1.151 +  /**************************************************************************
   1.152 +   *
   1.153 +   * @enum:
   1.154 +   *   FT_CFF_HINTING_XXX
   1.155 +   *
   1.156 +   * @description:
   1.157 +   *   A list of constants used for the @hinting-engine property to select
   1.158 +   *   the hinting engine for CFF fonts.
   1.159 +   *
   1.160 +   * @values:
   1.161 +   *   FT_CFF_HINTING_FREETYPE ::
   1.162 +   *     Use the old FreeType hinting engine.
   1.163 +   *
   1.164 +   *   FT_CFF_HINTING_ADOBE ::
   1.165 +   *     Use the hinting engine contributed by Adobe.
   1.166 +   *
   1.167 +   */
   1.168 +#define FT_CFF_HINTING_FREETYPE  0
   1.169 +#define FT_CFF_HINTING_ADOBE     1
   1.170 +
   1.171 +
   1.172 +  /**************************************************************************
   1.173 +   *
   1.174 +   * @property:
   1.175 +   *   no-stem-darkening
   1.176 +   *
   1.177 +   * @description:
   1.178 +   *   By default, the Adobe CFF engine darkens stems at smaller sizes,
   1.179 +   *   regardless of hinting, to enhance contrast.  This feature requires
   1.180 +   *   a rendering system with proper gamma correction.  Setting this
   1.181 +   *   property, stem darkening gets switched off.
   1.182 +   *
   1.183 +   *   Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set.
   1.184 +   *
   1.185 +   *   {
   1.186 +   *     FT_Library  library;
   1.187 +   *     FT_Bool     no_stem_darkening = TRUE;
   1.188 +   *
   1.189 +   *
   1.190 +   *     FT_Init_FreeType( &library );
   1.191 +   *
   1.192 +   *     FT_Property_Set( library, "cff",
   1.193 +   *                               "no-stem-darkening", &no_stem_darkening );
   1.194 +   *   }
   1.195 +   *
   1.196 +   * @note:
   1.197 +   *   This property can be used with @FT_Property_Get also.
   1.198 +   *
   1.199 +   */
   1.200 +
   1.201 +
   1.202 +  /**************************************************************************
   1.203 +   *
   1.204 +   * @property:
   1.205 +   *   darkening-parameters
   1.206 +   *
   1.207 +   * @description:
   1.208 +   *   By default, the Adobe CFF engine darkens stems as follows (if the
   1.209 +   *   `no-stem-darkening' property isn't set):
   1.210 +   *
   1.211 +   *   {
   1.212 +   *     stem width <= 0.5px:   darkening amount = 0.4px
   1.213 +   *     stem width  = 1px:     darkening amount = 0.275px
   1.214 +   *     stem width  = 1.667px: darkening amount = 0.275px
   1.215 +   *     stem width >= 2.333px: darkening amount = 0px
   1.216 +   *   }
   1.217 +   *
   1.218 +   *   and piecewise linear in-between.  Using the `darkening-parameters'
   1.219 +   *   property, these four control points can be changed, as the following
   1.220 +   *   example demonstrates.
   1.221 +   *
   1.222 +   *   {
   1.223 +   *     FT_Library  library;
   1.224 +   *     FT_Int      darken_params[8] = {  500, 300,   // x1, y1
   1.225 +   *                                      1000, 200,   // x2, y2
   1.226 +   *                                      1500, 100,   // x3, y3
   1.227 +   *                                      2000,   0 }; // x4, y4
   1.228 +   *
   1.229 +   *
   1.230 +   *     FT_Init_FreeType( &library );
   1.231 +   *
   1.232 +   *     FT_Property_Set( library, "cff",
   1.233 +   *                               "darkening-parameters", darken_params );
   1.234 +   *   }
   1.235 +   *
   1.236 +   *   The x~values give the stem width, and the y~values the darkening
   1.237 +   *   amount.  The unit is 1000th of pixels.  All coordinate values must be
   1.238 +   *   positive; the x~values must be monotonically increasing; the
   1.239 +   *   y~values must be monotonically decreasing and smaller than or
   1.240 +   *   equal to 500 (corresponding to half a pixel); the slope of each
   1.241 +   *   linear piece must be shallower than -1 (e.g., -.4).
   1.242 +   *
   1.243 +   * @note:
   1.244 +   *   This property can be used with @FT_Property_Get also.
   1.245 +   *
   1.246 +   */
   1.247 +
   1.248 +
   1.249 + /* */
   1.250 +
   1.251 +FT_END_HEADER
   1.252 +
   1.253 +
   1.254 +#endif /* __FTCFFDRV_H__ */
   1.255 +
   1.256 +
   1.257 +/* END */

mercurial