• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  *
3  * ftdriver.h
4  *
5  *   FreeType API for controlling driver modules (specification only).
6  *
7  * Copyright (C) 2017-2020 by
8  * David Turner, Robert Wilhelm, and Werner Lemberg.
9  *
10  * This file is part of the FreeType project, and may only be used,
11  * modified, and distributed under the terms of the FreeType project
12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
13  * this file you indicate that you have read the license and
14  * understand and accept it fully.
15  *
16  */
17 
18 
19 #ifndef FTDRIVER_H_
20 #define FTDRIVER_H_
21 
22 #include <freetype/freetype.h>
23 #include <freetype/ftparams.h>
24 
25 #ifdef FREETYPE_H
26 #error "freetype.h of FreeType 1 has been loaded!"
27 #error "Please fix the directory search order for header files"
28 #error "so that freetype.h of FreeType 2 is found first."
29 #endif
30 
31 
32 FT_BEGIN_HEADER
33 
34 
35   /**************************************************************************
36    *
37    * @section:
38    *   auto_hinter
39    *
40    * @title:
41    *   The auto-hinter
42    *
43    * @abstract:
44    *   Controlling the auto-hinting module.
45    *
46    * @description:
47    *   While FreeType's auto-hinter doesn't expose API functions by itself,
48    *   it is possible to control its behaviour with @FT_Property_Set and
49    *   @FT_Property_Get.  The following lists the available properties
50    *   together with the necessary macros and structures.
51    *
52    *   Note that the auto-hinter's module name is 'autofitter' for historical
53    *   reasons.
54    *
55    *   Available properties are @increase-x-height, @no-stem-darkening
56    *   (experimental), @darkening-parameters (experimental), @warping
57    *   (experimental), @glyph-to-script-map (experimental), @fallback-script
58    *   (experimental), and @default-script (experimental), as documented in
59    *   the @properties section.
60    *
61    */
62 
63 
64   /**************************************************************************
65    *
66    * @section:
67    *   cff_driver
68    *
69    * @title:
70    *   The CFF driver
71    *
72    * @abstract:
73    *   Controlling the CFF driver module.
74    *
75    * @description:
76    *   While FreeType's CFF driver doesn't expose API functions by itself, it
77    *   is possible to control its behaviour with @FT_Property_Set and
78    *   @FT_Property_Get.
79    *
80    *   The CFF driver's module name is 'cff'.
81    *
82    *   Available properties are @hinting-engine, @no-stem-darkening,
83    *   @darkening-parameters, and @random-seed, as documented in the
84    *   @properties section.
85    *
86    *
87    *   **Hinting and antialiasing principles of the new engine**
88    *
89    *   The rasterizer is positioning horizontal features (e.g., ascender
90    *   height & x-height, or crossbars) on the pixel grid and minimizing the
91    *   amount of antialiasing applied to them, while placing vertical
92    *   features (vertical stems) on the pixel grid without hinting, thus
93    *   representing the stem position and weight accurately.  Sometimes the
94    *   vertical stems may be only partially black.  In this context,
95    *   'antialiasing' means that stems are not positioned exactly on pixel
96    *   borders, causing a fuzzy appearance.
97    *
98    *   There are two principles behind this approach.
99    *
100    *   1) No hinting in the horizontal direction: Unlike 'superhinted'
101    *   TrueType, which changes glyph widths to accommodate regular
102    *   inter-glyph spacing, Adobe's approach is 'faithful to the design' in
103    *   representing both the glyph width and the inter-glyph spacing designed
104    *   for the font.  This makes the screen display as close as it can be to
105    *   the result one would get with infinite resolution, while preserving
106    *   what is considered the key characteristics of each glyph.  Note that
107    *   the distances between unhinted and grid-fitted positions at small
108    *   sizes are comparable to kerning values and thus would be noticeable
109    *   (and distracting) while reading if hinting were applied.
110    *
111    *   One of the reasons to not hint horizontally is antialiasing for LCD
112    *   screens: The pixel geometry of modern displays supplies three vertical
113    *   subpixels as the eye moves horizontally across each visible pixel.  On
114    *   devices where we can be certain this characteristic is present a
115    *   rasterizer can take advantage of the subpixels to add increments of
116    *   weight.  In Western writing systems this turns out to be the more
117    *   critical direction anyway; the weights and spacing of vertical stems
118    *   (see above) are central to Armenian, Cyrillic, Greek, and Latin type
119    *   designs.  Even when the rasterizer uses greyscale antialiasing instead
120    *   of color (a necessary compromise when one doesn't know the screen
121    *   characteristics), the unhinted vertical features preserve the design's
122    *   weight and spacing much better than aliased type would.
123    *
124    *   2) Alignment in the vertical direction: Weights and spacing along the
125    *   y~axis are less critical; what is much more important is the visual
126    *   alignment of related features (like cap-height and x-height).  The
127    *   sense of alignment for these is enhanced by the sharpness of grid-fit
128    *   edges, while the cruder vertical resolution (full pixels instead of
129    *   1/3 pixels) is less of a problem.
130    *
131    *   On the technical side, horizontal alignment zones for ascender,
132    *   x-height, and other important height values (traditionally called
133    *   'blue zones') as defined in the font are positioned independently,
134    *   each being rounded to the nearest pixel edge, taking care of overshoot
135    *   suppression at small sizes, stem darkening, and scaling.
136    *
137    *   Hstems (this is, hint values defined in the font to help align
138    *   horizontal features) that fall within a blue zone are said to be
139    *   'captured' and are aligned to that zone.  Uncaptured stems are moved
140    *   in one of four ways, top edge up or down, bottom edge up or down.
141    *   Unless there are conflicting hstems, the smallest movement is taken to
142    *   minimize distortion.
143    *
144    */
145 
146 
147   /**************************************************************************
148    *
149    * @section:
150    *   pcf_driver
151    *
152    * @title:
153    *   The PCF driver
154    *
155    * @abstract:
156    *   Controlling the PCF driver module.
157    *
158    * @description:
159    *   While FreeType's PCF driver doesn't expose API functions by itself, it
160    *   is possible to control its behaviour with @FT_Property_Set and
161    *   @FT_Property_Get.  Right now, there is a single property
162    *   @no-long-family-names available if FreeType is compiled with
163    *   PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
164    *
165    *   The PCF driver's module name is 'pcf'.
166    *
167    */
168 
169 
170   /**************************************************************************
171    *
172    * @section:
173    *   t1_cid_driver
174    *
175    * @title:
176    *   The Type 1 and CID drivers
177    *
178    * @abstract:
179    *   Controlling the Type~1 and CID driver modules.
180    *
181    * @description:
182    *   It is possible to control the behaviour of FreeType's Type~1 and
183    *   Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get.
184    *
185    *   Behind the scenes, both drivers use the Adobe CFF engine for hinting;
186    *   however, the used properties must be specified separately.
187    *
188    *   The Type~1 driver's module name is 'type1'; the CID driver's module
189    *   name is 't1cid'.
190    *
191    *   Available properties are @hinting-engine, @no-stem-darkening,
192    *   @darkening-parameters, and @random-seed, as documented in the
193    *   @properties section.
194    *
195    *   Please see the @cff_driver section for more details on the new hinting
196    *   engine.
197    *
198    */
199 
200 
201   /**************************************************************************
202    *
203    * @section:
204    *   tt_driver
205    *
206    * @title:
207    *   The TrueType driver
208    *
209    * @abstract:
210    *   Controlling the TrueType driver module.
211    *
212    * @description:
213    *   While FreeType's TrueType driver doesn't expose API functions by
214    *   itself, it is possible to control its behaviour with @FT_Property_Set
215    *   and @FT_Property_Get.  The following lists the available properties
216    *   together with the necessary macros and structures.
217    *
218    *   The TrueType driver's module name is 'truetype'.
219    *
220    *   A single property @interpreter-version is available, as documented in
221    *   the @properties section.
222    *
223    *   We start with a list of definitions, kindly provided by Greg
224    *   Hitchcock.
225    *
226    *   _Bi-Level Rendering_
227    *
228    *   Monochromatic rendering, exclusively used in the early days of
229    *   TrueType by both Apple and Microsoft.  Microsoft's GDI interface
230    *   supported hinting of the right-side bearing point, such that the
231    *   advance width could be non-linear.  Most often this was done to
232    *   achieve some level of glyph symmetry.  To enable reasonable
233    *   performance (e.g., not having to run hinting on all glyphs just to get
234    *   the widths) there was a bit in the head table indicating if the side
235    *   bearing was hinted, and additional tables, 'hdmx' and 'LTSH', to cache
236    *   hinting widths across multiple sizes and device aspect ratios.
237    *
238    *   _Font Smoothing_
239    *
240    *   Microsoft's GDI implementation of anti-aliasing.  Not traditional
241    *   anti-aliasing as the outlines were hinted before the sampling.  The
242    *   widths matched the bi-level rendering.
243    *
244    *   _ClearType Rendering_
245    *
246    *   Technique that uses physical subpixels to improve rendering on LCD
247    *   (and other) displays.  Because of the higher resolution, many methods
248    *   of improving symmetry in glyphs through hinting the right-side bearing
249    *   were no longer necessary.  This lead to what GDI calls 'natural
250    *   widths' ClearType, see
251    *   http://rastertragedy.com/RTRCh4.htm#Sec21.  Since hinting
252    *   has extra resolution, most non-linearity went away, but it is still
253    *   possible for hints to change the advance widths in this mode.
254    *
255    *   _ClearType Compatible Widths_
256    *
257    *   One of the earliest challenges with ClearType was allowing the
258    *   implementation in GDI to be selected without requiring all UI and
259    *   documents to reflow.  To address this, a compatible method of
260    *   rendering ClearType was added where the font hints are executed once
261    *   to determine the width in bi-level rendering, and then re-run in
262    *   ClearType, with the difference in widths being absorbed in the font
263    *   hints for ClearType (mostly in the white space of hints); see
264    *   http://rastertragedy.com/RTRCh4.htm#Sec20.  Somewhat by
265    *   definition, compatible width ClearType allows for non-linear widths,
266    *   but only when the bi-level version has non-linear widths.
267    *
268    *   _ClearType Subpixel Positioning_
269    *
270    *   One of the nice benefits of ClearType is the ability to more crisply
271    *   display fractional widths; unfortunately, the GDI model of integer
272    *   bitmaps did not support this.  However, the WPF and Direct Write
273    *   frameworks do support fractional widths.  DWrite calls this 'natural
274    *   mode', not to be confused with GDI's 'natural widths'.  Subpixel
275    *   positioning, in the current implementation of Direct Write,
276    *   unfortunately does not support hinted advance widths, see
277    *   http://rastertragedy.com/RTRCh4.htm#Sec22.  Note that the
278    *   TrueType interpreter fully allows the advance width to be adjusted in
279    *   this mode, just the DWrite client will ignore those changes.
280    *
281    *   _ClearType Backward Compatibility_
282    *
283    *   This is a set of exceptions made in the TrueType interpreter to
284    *   minimize hinting techniques that were problematic with the extra
285    *   resolution of ClearType; see
286    *   http://rastertragedy.com/RTRCh4.htm#Sec1 and
287    *   https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx.
288    *   This technique is not to be confused with ClearType compatible widths.
289    *   ClearType backward compatibility has no direct impact on changing
290    *   advance widths, but there might be an indirect impact on disabling
291    *   some deltas.  This could be worked around in backward compatibility
292    *   mode.
293    *
294    *   _Native ClearType Mode_
295    *
296    *   (Not to be confused with 'natural widths'.)  This mode removes all the
297    *   exceptions in the TrueType interpreter when running with ClearType.
298    *   Any issues on widths would still apply, though.
299    *
300    */
301 
302 
303   /**************************************************************************
304    *
305    * @section:
306    *   properties
307    *
308    * @title:
309    *   Driver properties
310    *
311    * @abstract:
312    *   Controlling driver modules.
313    *
314    * @description:
315    *   Driver modules can be controlled by setting and unsetting properties,
316    *   using the functions @FT_Property_Set and @FT_Property_Get.  This
317    *   section documents the available properties, together with auxiliary
318    *   macros and structures.
319    *
320    */
321 
322 
323   /**************************************************************************
324    *
325    * @enum:
326    *   FT_HINTING_XXX
327    *
328    * @description:
329    *   A list of constants used for the @hinting-engine property to select
330    *   the hinting engine for CFF, Type~1, and CID fonts.
331    *
332    * @values:
333    *   FT_HINTING_FREETYPE ::
334    *     Use the old FreeType hinting engine.
335    *
336    *   FT_HINTING_ADOBE ::
337    *     Use the hinting engine contributed by Adobe.
338    *
339    * @since:
340    *   2.9
341    *
342    */
343 #define FT_HINTING_FREETYPE  0
344 #define FT_HINTING_ADOBE     1
345 
346   /* these constants (introduced in 2.4.12) are deprecated */
347 #define FT_CFF_HINTING_FREETYPE  FT_HINTING_FREETYPE
348 #define FT_CFF_HINTING_ADOBE     FT_HINTING_ADOBE
349 
350 
351   /**************************************************************************
352    *
353    * @property:
354    *   hinting-engine
355    *
356    * @description:
357    *   Thanks to Adobe, which contributed a new hinting (and parsing) engine,
358    *   an application can select between 'freetype' and 'adobe' if compiled
359    *   with `CFF_CONFIG_OPTION_OLD_ENGINE`.  If this configuration macro
360    *   isn't defined, 'hinting-engine' does nothing.
361    *
362    *   The same holds for the Type~1 and CID modules if compiled with
363    *   `T1_CONFIG_OPTION_OLD_ENGINE`.
364    *
365    *   For the 'cff' module, the default engine is 'freetype' if
366    *   `CFF_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe' otherwise.
367    *
368    *   For both the 'type1' and 't1cid' modules, the default engine is
369    *   'freetype' if `T1_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe'
370    *   otherwise.
371    *
372    * @note:
373    *   This property can be used with @FT_Property_Get also.
374    *
375    *   This property can be set via the `FREETYPE_PROPERTIES` environment
376    *   variable (using values 'adobe' or 'freetype').
377    *
378    * @example:
379    *   The following example code demonstrates how to select Adobe's hinting
380    *   engine for the 'cff' module (omitting the error handling).
381    *
382    *   ```
383    *     FT_Library  library;
384    *     FT_UInt     hinting_engine = FT_HINTING_ADOBE;
385    *
386    *
387    *     FT_Init_FreeType( &library );
388    *
389    *     FT_Property_Set( library, "cff",
390    *                               "hinting-engine", &hinting_engine );
391    *   ```
392    *
393    * @since:
394    *   2.4.12 (for 'cff' module)
395    *
396    *   2.9 (for 'type1' and 't1cid' modules)
397    *
398    */
399 
400 
401   /**************************************************************************
402    *
403    * @property:
404    *   no-stem-darkening
405    *
406    * @description:
407    *   All glyphs that pass through the auto-hinter will be emboldened unless
408    *   this property is set to TRUE.  The same is true for the CFF, Type~1,
409    *   and CID font modules if the 'Adobe' engine is selected (which is the
410    *   default).
411    *
412    *   Stem darkening emboldens glyphs at smaller sizes to make them more
413    *   readable on common low-DPI screens when using linear alpha blending
414    *   and gamma correction, see @FT_Render_Glyph.  When not using linear
415    *   alpha blending and gamma correction, glyphs will appear heavy and
416    *   fuzzy!
417    *
418    *   Gamma correction essentially lightens fonts since shades of grey are
419    *   shifted to higher pixel values (=~higher brightness) to match the
420    *   original intention to the reality of our screens.  The side-effect is
421    *   that glyphs 'thin out'.  Mac OS~X and Adobe's proprietary font
422    *   rendering library implement a counter-measure: stem darkening at
423    *   smaller sizes where shades of gray dominate.  By emboldening a glyph
424    *   slightly in relation to its pixel size, individual pixels get higher
425    *   coverage of filled-in outlines and are therefore 'blacker'.  This
426    *   counteracts the 'thinning out' of glyphs, making text remain readable
427    *   at smaller sizes.
428    *
429    *   For the auto-hinter, stem-darkening is experimental currently and thus
430    *   switched off by default (this is, `no-stem-darkening` is set to TRUE
431    *   by default).  Total consistency with the CFF driver is not achieved
432    *   right now because the emboldening method differs and glyphs must be
433    *   scaled down on the Y-axis to keep outline points inside their
434    *   precomputed blue zones.  The smaller the size (especially 9ppem and
435    *   down), the higher the loss of emboldening versus the CFF driver.
436    *
437    *   Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set.
438    *
439    * @note:
440    *   This property can be used with @FT_Property_Get also.
441    *
442    *   This property can be set via the `FREETYPE_PROPERTIES` environment
443    *   variable (using values 1 and 0 for 'on' and 'off', respectively).  It
444    *   can also be set per face using @FT_Face_Properties with
445    *   @FT_PARAM_TAG_STEM_DARKENING.
446    *
447    * @example:
448    *   ```
449    *     FT_Library  library;
450    *     FT_Bool     no_stem_darkening = TRUE;
451    *
452    *
453    *     FT_Init_FreeType( &library );
454    *
455    *     FT_Property_Set( library, "cff",
456    *                               "no-stem-darkening", &no_stem_darkening );
457    *   ```
458    *
459    * @since:
460    *   2.4.12 (for 'cff' module)
461    *
462    *   2.6.2 (for 'autofitter' module)
463    *
464    *   2.9 (for 'type1' and 't1cid' modules)
465    *
466    */
467 
468 
469   /**************************************************************************
470    *
471    * @property:
472    *   darkening-parameters
473    *
474    * @description:
475    *   By default, the Adobe hinting engine, as used by the CFF, Type~1, and
476    *   CID font drivers, darkens stems as follows (if the `no-stem-darkening`
477    *   property isn't set):
478    *
479    *   ```
480    *     stem width <= 0.5px:   darkening amount = 0.4px
481    *     stem width  = 1px:     darkening amount = 0.275px
482    *     stem width  = 1.667px: darkening amount = 0.275px
483    *     stem width >= 2.333px: darkening amount = 0px
484    *   ```
485    *
486    *   and piecewise linear in-between.  At configuration time, these four
487    *   control points can be set with the macro
488    *   `CFF_CONFIG_OPTION_DARKENING_PARAMETERS`; the CFF, Type~1, and CID
489    *   drivers share these values.  At runtime, the control points can be
490    *   changed using the `darkening-parameters` property (see the example
491    *   below that demonstrates this for the Type~1 driver).
492    *
493    *   The x~values give the stem width, and the y~values the darkening
494    *   amount.  The unit is 1000th of pixels.  All coordinate values must be
495    *   positive; the x~values must be monotonically increasing; the y~values
496    *   must be monotonically decreasing and smaller than or equal to 500
497    *   (corresponding to half a pixel); the slope of each linear piece must
498    *   be shallower than -1 (e.g., -.4).
499    *
500    *   The auto-hinter provides this property, too, as an experimental
501    *   feature.  See @no-stem-darkening for more.
502    *
503    * @note:
504    *   This property can be used with @FT_Property_Get also.
505    *
506    *   This property can be set via the `FREETYPE_PROPERTIES` environment
507    *   variable, using eight comma-separated integers without spaces.  Here
508    *   the above example, using `\` to break the line for readability.
509    *
510    *   ```
511    *     FREETYPE_PROPERTIES=\
512    *     type1:darkening-parameters=500,300,1000,200,1500,100,2000,0
513    *   ```
514    *
515    * @example:
516    *   ```
517    *     FT_Library  library;
518    *     FT_Int      darken_params[8] = {  500, 300,   // x1, y1
519    *                                      1000, 200,   // x2, y2
520    *                                      1500, 100,   // x3, y3
521    *                                      2000,   0 }; // x4, y4
522    *
523    *
524    *     FT_Init_FreeType( &library );
525    *
526    *     FT_Property_Set( library, "type1",
527    *                               "darkening-parameters", darken_params );
528    *   ```
529    *
530    * @since:
531    *   2.5.1 (for 'cff' module)
532    *
533    *   2.6.2 (for 'autofitter' module)
534    *
535    *   2.9 (for 'type1' and 't1cid' modules)
536    *
537    */
538 
539 
540   /**************************************************************************
541    *
542    * @property:
543    *   random-seed
544    *
545    * @description:
546    *   By default, the seed value for the CFF 'random' operator and the
547    *   similar '0 28 callothersubr pop' command for the Type~1 and CID
548    *   drivers is set to a random value.  However, mainly for debugging
549    *   purposes, it is often necessary to use a known value as a seed so that
550    *   the pseudo-random number sequences generated by 'random' are
551    *   repeatable.
552    *
553    *   The `random-seed` property does that.  Its argument is a signed 32bit
554    *   integer; if the value is zero or negative, the seed given by the
555    *   `intitialRandomSeed` private DICT operator in a CFF file gets used (or
556    *   a default value if there is no such operator).  If the value is
557    *   positive, use it instead of `initialRandomSeed`, which is consequently
558    *   ignored.
559    *
560    * @note:
561    *   This property can be set via the `FREETYPE_PROPERTIES` environment
562    *   variable.  It can also be set per face using @FT_Face_Properties with
563    *   @FT_PARAM_TAG_RANDOM_SEED.
564    *
565    * @since:
566    *   2.8 (for 'cff' module)
567    *
568    *   2.9 (for 'type1' and 't1cid' modules)
569    *
570    */
571 
572 
573   /**************************************************************************
574    *
575    * @property:
576    *   no-long-family-names
577    *
578    * @description:
579    *   If `PCF_CONFIG_OPTION_LONG_FAMILY_NAMES` is active while compiling
580    *   FreeType, the PCF driver constructs long family names.
581    *
582    *   There are many PCF fonts just called 'Fixed' which look completely
583    *   different, and which have nothing to do with each other.  When
584    *   selecting 'Fixed' in KDE or Gnome one gets results that appear rather
585    *   random, the style changes often if one changes the size and one cannot
586    *   select some fonts at all.  The improve this situation, the PCF module
587    *   prepends the foundry name (plus a space) to the family name.  It also
588    *   checks whether there are 'wide' characters; all put together, family
589    *   names like 'Sony Fixed' or 'Misc Fixed Wide' are constructed.
590    *
591    *   If `no-long-family-names` is set, this feature gets switched off.
592    *
593    * @note:
594    *   This property can be used with @FT_Property_Get also.
595    *
596    *   This property can be set via the `FREETYPE_PROPERTIES` environment
597    *   variable (using values 1 and 0 for 'on' and 'off', respectively).
598    *
599    * @example:
600    *   ```
601    *     FT_Library  library;
602    *     FT_Bool     no_long_family_names = TRUE;
603    *
604    *
605    *     FT_Init_FreeType( &library );
606    *
607    *     FT_Property_Set( library, "pcf",
608    *                               "no-long-family-names",
609    *                               &no_long_family_names );
610    *   ```
611    *
612    * @since:
613    *   2.8
614    */
615 
616 
617   /**************************************************************************
618    *
619    * @enum:
620    *   TT_INTERPRETER_VERSION_XXX
621    *
622    * @description:
623    *   A list of constants used for the @interpreter-version property to
624    *   select the hinting engine for Truetype fonts.
625    *
626    *   The numeric value in the constant names represents the version number
627    *   as returned by the 'GETINFO' bytecode instruction.
628    *
629    * @values:
630    *   TT_INTERPRETER_VERSION_35 ::
631    *     Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in
632    *     Windows~98; only grayscale and B/W rasterizing is supported.
633    *
634    *   TT_INTERPRETER_VERSION_38 ::
635    *     Version~38 corresponds to MS rasterizer v.1.9; it is roughly
636    *     equivalent to the hinting provided by DirectWrite ClearType (as can
637    *     be found, for example, in the Internet Explorer~9 running on
638    *     Windows~7).  It is used in FreeType to select the 'Infinality'
639    *     subpixel hinting code.  The code may be removed in a future version.
640    *
641    *   TT_INTERPRETER_VERSION_40 ::
642    *     Version~40 corresponds to MS rasterizer v.2.1; it is roughly
643    *     equivalent to the hinting provided by DirectWrite ClearType (as can
644    *     be found, for example, in Microsoft's Edge Browser on Windows~10).
645    *     It is used in FreeType to select the 'minimal' subpixel hinting
646    *     code, a stripped-down and higher performance version of the
647    *     'Infinality' code.
648    *
649    * @note:
650    *   This property controls the behaviour of the bytecode interpreter and
651    *   thus how outlines get hinted.  It does **not** control how glyph get
652    *   rasterized!  In particular, it does not control subpixel color
653    *   filtering.
654    *
655    *   If FreeType has not been compiled with the configuration option
656    *   `TT_CONFIG_OPTION_SUBPIXEL_HINTING`, selecting version~38 or~40 causes
657    *   an `FT_Err_Unimplemented_Feature` error.
658    *
659    *   Depending on the graphics framework, Microsoft uses different bytecode
660    *   and rendering engines.  As a consequence, the version numbers returned
661    *   by a call to the 'GETINFO' bytecode instruction are more convoluted
662    *   than desired.
663    *
664    *   Here are two tables that try to shed some light on the possible values
665    *   for the MS rasterizer engine, together with the additional features
666    *   introduced by it.
667    *
668    *   ```
669    *     GETINFO framework               version feature
670    *     -------------------------------------------------------------------
671    *         3   GDI (Win 3.1),            v1.0  16-bit, first version
672    *             TrueImage
673    *        33   GDI (Win NT 3.1),         v1.5  32-bit
674    *             HP Laserjet
675    *        34   GDI (Win 95)              v1.6  font smoothing,
676    *                                             new SCANTYPE opcode
677    *        35   GDI (Win 98/2000)         v1.7  (UN)SCALED_COMPONENT_OFFSET
678    *                                               bits in composite glyphs
679    *        36   MGDI (Win CE 2)           v1.6+ classic ClearType
680    *        37   GDI (XP and later),       v1.8  ClearType
681    *             GDI+ old (before Vista)
682    *        38   GDI+ old (Vista, Win 7),  v1.9  subpixel ClearType,
683    *             WPF                             Y-direction ClearType,
684    *                                             additional error checking
685    *        39   DWrite (before Win 8)     v2.0  subpixel ClearType flags
686    *                                               in GETINFO opcode,
687    *                                             bug fixes
688    *        40   GDI+ (after Win 7),       v2.1  Y-direction ClearType flag
689    *             DWrite (Win 8)                    in GETINFO opcode,
690    *                                             Gray ClearType
691    *   ```
692    *
693    *   The 'version' field gives a rough orientation only, since some
694    *   applications provided certain features much earlier (as an example,
695    *   Microsoft Reader used subpixel and Y-direction ClearType already in
696    *   Windows 2000).  Similarly, updates to a given framework might include
697    *   improved hinting support.
698    *
699    *   ```
700    *      version   sampling          rendering        comment
701    *               x        y       x           y
702    *     --------------------------------------------------------------
703    *       v1.0   normal  normal  B/W           B/W    bi-level
704    *       v1.6   high    high    gray          gray   grayscale
705    *       v1.8   high    normal  color-filter  B/W    (GDI) ClearType
706    *       v1.9   high    high    color-filter  gray   Color ClearType
707    *       v2.1   high    normal  gray          B/W    Gray ClearType
708    *       v2.1   high    high    gray          gray   Gray ClearType
709    *   ```
710    *
711    *   Color and Gray ClearType are the two available variants of
712    *   'Y-direction ClearType', meaning grayscale rasterization along the
713    *   Y-direction; the name used in the TrueType specification for this
714    *   feature is 'symmetric smoothing'.  'Classic ClearType' is the original
715    *   algorithm used before introducing a modified version in Win~XP.
716    *   Another name for v1.6's grayscale rendering is 'font smoothing', and
717    *   'Color ClearType' is sometimes also called 'DWrite ClearType'.  To
718    *   differentiate between today's Color ClearType and the earlier
719    *   ClearType variant with B/W rendering along the vertical axis, the
720    *   latter is sometimes called 'GDI ClearType'.
721    *
722    *   'Normal' and 'high' sampling describe the (virtual) resolution to
723    *   access the rasterized outline after the hinting process.  'Normal'
724    *   means 1 sample per grid line (i.e., B/W).  In the current Microsoft
725    *   implementation, 'high' means an extra virtual resolution of 16x16 (or
726    *   16x1) grid lines per pixel for bytecode instructions like 'MIRP'.
727    *   After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid
728    *   lines for color filtering if Color ClearType is activated.
729    *
730    *   Note that 'Gray ClearType' is essentially the same as v1.6's grayscale
731    *   rendering.  However, the GETINFO instruction handles it differently:
732    *   v1.6 returns bit~12 (hinting for grayscale), while v2.1 returns
733    *   bits~13 (hinting for ClearType), 18 (symmetrical smoothing), and~19
734    *   (Gray ClearType).  Also, this mode respects bits 2 and~3 for the
735    *   version~1 gasp table exclusively (like Color ClearType), while v1.6
736    *   only respects the values of version~0 (bits 0 and~1).
737    *
738    *   Keep in mind that the features of the above interpreter versions might
739    *   not map exactly to FreeType features or behavior because it is a
740    *   fundamentally different library with different internals.
741    *
742    */
743 #define TT_INTERPRETER_VERSION_35  35
744 #define TT_INTERPRETER_VERSION_38  38
745 #define TT_INTERPRETER_VERSION_40  40
746 
747 
748   /**************************************************************************
749    *
750    * @property:
751    *   interpreter-version
752    *
753    * @description:
754    *   Currently, three versions are available, two representing the bytecode
755    *   interpreter with subpixel hinting support (old 'Infinality' code and
756    *   new stripped-down and higher performance 'minimal' code) and one
757    *   without, respectively.  The default is subpixel support if
758    *   `TT_CONFIG_OPTION_SUBPIXEL_HINTING` is defined, and no subpixel
759    *   support otherwise (since it isn't available then).
760    *
761    *   If subpixel hinting is on, many TrueType bytecode instructions behave
762    *   differently compared to B/W or grayscale rendering (except if 'native
763    *   ClearType' is selected by the font).  Microsoft's main idea is to
764    *   render at a much increased horizontal resolution, then sampling down
765    *   the created output to subpixel precision.  However, many older fonts
766    *   are not suited to this and must be specially taken care of by applying
767    *   (hardcoded) tweaks in Microsoft's interpreter.
768    *
769    *   Details on subpixel hinting and some of the necessary tweaks can be
770    *   found in Greg Hitchcock's whitepaper at
771    *   'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
772    *   Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2,
773    *   or 6x5 supersampling) like discussed in the paper.  Depending on the
774    *   chosen interpreter, it simply ignores instructions on vertical stems
775    *   to arrive at very similar results.
776    *
777    * @note:
778    *   This property can be used with @FT_Property_Get also.
779    *
780    *   This property can be set via the `FREETYPE_PROPERTIES` environment
781    *   variable (using values '35', '38', or '40').
782    *
783    * @example:
784    *   The following example code demonstrates how to deactivate subpixel
785    *   hinting (omitting the error handling).
786    *
787    *   ```
788    *     FT_Library  library;
789    *     FT_Face     face;
790    *     FT_UInt     interpreter_version = TT_INTERPRETER_VERSION_35;
791    *
792    *
793    *     FT_Init_FreeType( &library );
794    *
795    *     FT_Property_Set( library, "truetype",
796    *                               "interpreter-version",
797    *                               &interpreter_version );
798    *   ```
799    *
800    * @since:
801    *   2.5
802    */
803 
804 
805   /**************************************************************************
806    *
807    * @property:
808    *   glyph-to-script-map
809    *
810    * @description:
811    *   **Experimental only**
812    *
813    *   The auto-hinter provides various script modules to hint glyphs.
814    *   Examples of supported scripts are Latin or CJK.  Before a glyph is
815    *   auto-hinted, the Unicode character map of the font gets examined, and
816    *   the script is then determined based on Unicode character ranges, see
817    *   below.
818    *
819    *   OpenType fonts, however, often provide much more glyphs than character
820    *   codes (small caps, superscripts, ligatures, swashes, etc.), to be
821    *   controlled by so-called 'features'.  Handling OpenType features can be
822    *   quite complicated and thus needs a separate library on top of
823    *   FreeType.
824    *
825    *   The mapping between glyph indices and scripts (in the auto-hinter
826    *   sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array
827    *   with `num_glyphs` elements, as found in the font's @FT_Face structure.
828    *   The `glyph-to-script-map` property returns a pointer to this array,
829    *   which can be modified as needed.  Note that the modification should
830    *   happen before the first glyph gets processed by the auto-hinter so
831    *   that the global analysis of the font shapes actually uses the modified
832    *   mapping.
833    *
834    * @example:
835    *   The following example code demonstrates how to access it (omitting the
836    *   error handling).
837    *
838    *   ```
839    *     FT_Library                library;
840    *     FT_Face                   face;
841    *     FT_Prop_GlyphToScriptMap  prop;
842    *
843    *
844    *     FT_Init_FreeType( &library );
845    *     FT_New_Face( library, "foo.ttf", 0, &face );
846    *
847    *     prop.face = face;
848    *
849    *     FT_Property_Get( library, "autofitter",
850    *                               "glyph-to-script-map", &prop );
851    *
852    *     // adjust `prop.map' as needed right here
853    *
854    *     FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
855    *   ```
856    *
857    * @since:
858    *   2.4.11
859    *
860    */
861 
862 
863   /**************************************************************************
864    *
865    * @enum:
866    *   FT_AUTOHINTER_SCRIPT_XXX
867    *
868    * @description:
869    *   **Experimental only**
870    *
871    *   A list of constants used for the @glyph-to-script-map property to
872    *   specify the script submodule the auto-hinter should use for hinting a
873    *   particular glyph.
874    *
875    * @values:
876    *   FT_AUTOHINTER_SCRIPT_NONE ::
877    *     Don't auto-hint this glyph.
878    *
879    *   FT_AUTOHINTER_SCRIPT_LATIN ::
880    *     Apply the latin auto-hinter.  For the auto-hinter, 'latin' is a very
881    *     broad term, including Cyrillic and Greek also since characters from
882    *     those scripts share the same design constraints.
883    *
884    *     By default, characters from the following Unicode ranges are
885    *     assigned to this submodule.
886    *
887    *     ```
888    *       U+0020 - U+007F  // Basic Latin (no control characters)
889    *       U+00A0 - U+00FF  // Latin-1 Supplement (no control characters)
890    *       U+0100 - U+017F  // Latin Extended-A
891    *       U+0180 - U+024F  // Latin Extended-B
892    *       U+0250 - U+02AF  // IPA Extensions
893    *       U+02B0 - U+02FF  // Spacing Modifier Letters
894    *       U+0300 - U+036F  // Combining Diacritical Marks
895    *       U+0370 - U+03FF  // Greek and Coptic
896    *       U+0400 - U+04FF  // Cyrillic
897    *       U+0500 - U+052F  // Cyrillic Supplement
898    *       U+1D00 - U+1D7F  // Phonetic Extensions
899    *       U+1D80 - U+1DBF  // Phonetic Extensions Supplement
900    *       U+1DC0 - U+1DFF  // Combining Diacritical Marks Supplement
901    *       U+1E00 - U+1EFF  // Latin Extended Additional
902    *       U+1F00 - U+1FFF  // Greek Extended
903    *       U+2000 - U+206F  // General Punctuation
904    *       U+2070 - U+209F  // Superscripts and Subscripts
905    *       U+20A0 - U+20CF  // Currency Symbols
906    *       U+2150 - U+218F  // Number Forms
907    *       U+2460 - U+24FF  // Enclosed Alphanumerics
908    *       U+2C60 - U+2C7F  // Latin Extended-C
909    *       U+2DE0 - U+2DFF  // Cyrillic Extended-A
910    *       U+2E00 - U+2E7F  // Supplemental Punctuation
911    *       U+A640 - U+A69F  // Cyrillic Extended-B
912    *       U+A720 - U+A7FF  // Latin Extended-D
913    *       U+FB00 - U+FB06  // Alphab. Present. Forms (Latin Ligatures)
914    *      U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
915    *      U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
916    *     ```
917    *
918    *   FT_AUTOHINTER_SCRIPT_CJK ::
919    *     Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
920    *     Vietnamese, and some other scripts.
921    *
922    *     By default, characters from the following Unicode ranges are
923    *     assigned to this submodule.
924    *
925    *     ```
926    *       U+1100 - U+11FF  // Hangul Jamo
927    *       U+2E80 - U+2EFF  // CJK Radicals Supplement
928    *       U+2F00 - U+2FDF  // Kangxi Radicals
929    *       U+2FF0 - U+2FFF  // Ideographic Description Characters
930    *       U+3000 - U+303F  // CJK Symbols and Punctuation
931    *       U+3040 - U+309F  // Hiragana
932    *       U+30A0 - U+30FF  // Katakana
933    *       U+3100 - U+312F  // Bopomofo
934    *       U+3130 - U+318F  // Hangul Compatibility Jamo
935    *       U+3190 - U+319F  // Kanbun
936    *       U+31A0 - U+31BF  // Bopomofo Extended
937    *       U+31C0 - U+31EF  // CJK Strokes
938    *       U+31F0 - U+31FF  // Katakana Phonetic Extensions
939    *       U+3200 - U+32FF  // Enclosed CJK Letters and Months
940    *       U+3300 - U+33FF  // CJK Compatibility
941    *       U+3400 - U+4DBF  // CJK Unified Ideographs Extension A
942    *       U+4DC0 - U+4DFF  // Yijing Hexagram Symbols
943    *       U+4E00 - U+9FFF  // CJK Unified Ideographs
944    *       U+A960 - U+A97F  // Hangul Jamo Extended-A
945    *       U+AC00 - U+D7AF  // Hangul Syllables
946    *       U+D7B0 - U+D7FF  // Hangul Jamo Extended-B
947    *       U+F900 - U+FAFF  // CJK Compatibility Ideographs
948    *       U+FE10 - U+FE1F  // Vertical forms
949    *       U+FE30 - U+FE4F  // CJK Compatibility Forms
950    *       U+FF00 - U+FFEF  // Halfwidth and Fullwidth Forms
951    *      U+1B000 - U+1B0FF // Kana Supplement
952    *      U+1D300 - U+1D35F // Tai Xuan Hing Symbols
953    *      U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
954    *      U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
955    *      U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
956    *      U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
957    *      U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
958    *     ```
959    *
960    *   FT_AUTOHINTER_SCRIPT_INDIC ::
961    *     Apply the indic auto-hinter, covering all major scripts from the
962    *     Indian sub-continent and some other related scripts like Thai, Lao,
963    *     or Tibetan.
964    *
965    *     By default, characters from the following Unicode ranges are
966    *     assigned to this submodule.
967    *
968    *     ```
969    *       U+0900 - U+0DFF  // Indic Range
970    *       U+0F00 - U+0FFF  // Tibetan
971    *       U+1900 - U+194F  // Limbu
972    *       U+1B80 - U+1BBF  // Sundanese
973    *       U+A800 - U+A82F  // Syloti Nagri
974    *       U+ABC0 - U+ABFF  // Meetei Mayek
975    *      U+11800 - U+118DF // Sharada
976    *     ```
977    *
978    *     Note that currently Indic support is rudimentary only, missing blue
979    *     zone support.
980    *
981    * @since:
982    *   2.4.11
983    *
984    */
985 #define FT_AUTOHINTER_SCRIPT_NONE   0
986 #define FT_AUTOHINTER_SCRIPT_LATIN  1
987 #define FT_AUTOHINTER_SCRIPT_CJK    2
988 #define FT_AUTOHINTER_SCRIPT_INDIC  3
989 
990 
991   /**************************************************************************
992    *
993    * @struct:
994    *   FT_Prop_GlyphToScriptMap
995    *
996    * @description:
997    *   **Experimental only**
998    *
999    *   The data exchange structure for the @glyph-to-script-map property.
1000    *
1001    * @since:
1002    *   2.4.11
1003    *
1004    */
1005   typedef struct  FT_Prop_GlyphToScriptMap_
1006   {
1007     FT_Face     face;
1008     FT_UShort*  map;
1009 
1010   } FT_Prop_GlyphToScriptMap;
1011 
1012 
1013   /**************************************************************************
1014    *
1015    * @property:
1016    *   fallback-script
1017    *
1018    * @description:
1019    *   **Experimental only**
1020    *
1021    *   If no auto-hinter script module can be assigned to a glyph, a fallback
1022    *   script gets assigned to it (see also the @glyph-to-script-map
1023    *   property).  By default, this is @FT_AUTOHINTER_SCRIPT_CJK.  Using the
1024    *   `fallback-script` property, this fallback value can be changed.
1025    *
1026    * @note:
1027    *   This property can be used with @FT_Property_Get also.
1028    *
1029    *   It's important to use the right timing for changing this value: The
1030    *   creation of the glyph-to-script map that eventually uses the fallback
1031    *   script value gets triggered either by setting or reading a
1032    *   face-specific property like @glyph-to-script-map, or by auto-hinting
1033    *   any glyph from that face.  In particular, if you have already created
1034    *   an @FT_Face structure but not loaded any glyph (using the
1035    *   auto-hinter), a change of the fallback script will affect this face.
1036    *
1037    * @example:
1038    *   ```
1039    *     FT_Library  library;
1040    *     FT_UInt     fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
1041    *
1042    *
1043    *     FT_Init_FreeType( &library );
1044    *
1045    *     FT_Property_Set( library, "autofitter",
1046    *                               "fallback-script", &fallback_script );
1047    *   ```
1048    *
1049    * @since:
1050    *   2.4.11
1051    *
1052    */
1053 
1054 
1055   /**************************************************************************
1056    *
1057    * @property:
1058    *   default-script
1059    *
1060    * @description:
1061    *   **Experimental only**
1062    *
1063    *   If FreeType gets compiled with `FT_CONFIG_OPTION_USE_HARFBUZZ` to make
1064    *   the HarfBuzz library access OpenType features for getting better glyph
1065    *   coverages, this property sets the (auto-fitter) script to be used for
1066    *   the default (OpenType) script data of a font's GSUB table.  Features
1067    *   for the default script are intended for all scripts not explicitly
1068    *   handled in GSUB; an example is a 'dlig' feature, containing the
1069    *   combination of the characters 'T', 'E', and 'L' to form a 'TEL'
1070    *   ligature.
1071    *
1072    *   By default, this is @FT_AUTOHINTER_SCRIPT_LATIN.  Using the
1073    *   `default-script` property, this default value can be changed.
1074    *
1075    * @note:
1076    *   This property can be used with @FT_Property_Get also.
1077    *
1078    *   It's important to use the right timing for changing this value: The
1079    *   creation of the glyph-to-script map that eventually uses the default
1080    *   script value gets triggered either by setting or reading a
1081    *   face-specific property like @glyph-to-script-map, or by auto-hinting
1082    *   any glyph from that face.  In particular, if you have already created
1083    *   an @FT_Face structure but not loaded any glyph (using the
1084    *   auto-hinter), a change of the default script will affect this face.
1085    *
1086    * @example:
1087    *   ```
1088    *     FT_Library  library;
1089    *     FT_UInt     default_script = FT_AUTOHINTER_SCRIPT_NONE;
1090    *
1091    *
1092    *     FT_Init_FreeType( &library );
1093    *
1094    *     FT_Property_Set( library, "autofitter",
1095    *                               "default-script", &default_script );
1096    *   ```
1097    *
1098    * @since:
1099    *   2.5.3
1100    *
1101    */
1102 
1103 
1104   /**************************************************************************
1105    *
1106    * @property:
1107    *   increase-x-height
1108    *
1109    * @description:
1110    *   For ppem values in the range 6~<= ppem <= `increase-x-height`, round
1111    *   up the font's x~height much more often than normally.  If the value is
1112    *   set to~0, which is the default, this feature is switched off.  Use
1113    *   this property to improve the legibility of small font sizes if
1114    *   necessary.
1115    *
1116    * @note:
1117    *   This property can be used with @FT_Property_Get also.
1118    *
1119    *   Set this value right after calling @FT_Set_Char_Size, but before
1120    *   loading any glyph (using the auto-hinter).
1121    *
1122    * @example:
1123    *   ```
1124    *     FT_Library               library;
1125    *     FT_Face                  face;
1126    *     FT_Prop_IncreaseXHeight  prop;
1127    *
1128    *
1129    *     FT_Init_FreeType( &library );
1130    *     FT_New_Face( library, "foo.ttf", 0, &face );
1131    *     FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
1132    *
1133    *     prop.face  = face;
1134    *     prop.limit = 14;
1135    *
1136    *     FT_Property_Set( library, "autofitter",
1137    *                               "increase-x-height", &prop );
1138    *   ```
1139    *
1140    * @since:
1141    *   2.4.11
1142    *
1143    */
1144 
1145 
1146   /**************************************************************************
1147    *
1148    * @struct:
1149    *   FT_Prop_IncreaseXHeight
1150    *
1151    * @description:
1152    *   The data exchange structure for the @increase-x-height property.
1153    *
1154    */
1155   typedef struct  FT_Prop_IncreaseXHeight_
1156   {
1157     FT_Face  face;
1158     FT_UInt  limit;
1159 
1160   } FT_Prop_IncreaseXHeight;
1161 
1162 
1163   /**************************************************************************
1164    *
1165    * @property:
1166    *   warping
1167    *
1168    * @description:
1169    *   **Experimental only**
1170    *
1171    *   If FreeType gets compiled with option `AF_CONFIG_OPTION_USE_WARPER` to
1172    *   activate the warp hinting code in the auto-hinter, this property
1173    *   switches warping on and off.
1174    *
1175    *   Warping only works in 'normal' auto-hinting mode replacing it.  The
1176    *   idea of the code is to slightly scale and shift a glyph along the
1177    *   non-hinted dimension (which is usually the horizontal axis) so that as
1178    *   much of its segments are aligned (more or less) to the grid.  To find
1179    *   out a glyph's optimal scaling and shifting value, various parameter
1180    *   combinations are tried and scored.
1181    *
1182    *   By default, warping is off.
1183    *
1184    * @note:
1185    *   This property can be used with @FT_Property_Get also.
1186    *
1187    *   This property can be set via the `FREETYPE_PROPERTIES` environment
1188    *   variable (using values 1 and 0 for 'on' and 'off', respectively).
1189    *
1190    *   The warping code can also change advance widths.  Have a look at the
1191    *   `lsb_delta` and `rsb_delta` fields in the @FT_GlyphSlotRec structure
1192    *   for details on improving inter-glyph distances while rendering.
1193    *
1194    *   Since warping is a global property of the auto-hinter it is best to
1195    *   change its value before rendering any face.  Otherwise, you should
1196    *   reload all faces that get auto-hinted in 'normal' hinting mode.
1197    *
1198    * @example:
1199    *   This example shows how to switch on warping (omitting the error
1200    *   handling).
1201    *
1202    *   ```
1203    *     FT_Library  library;
1204    *     FT_Bool     warping = 1;
1205    *
1206    *
1207    *     FT_Init_FreeType( &library );
1208    *
1209    *     FT_Property_Set( library, "autofitter", "warping", &warping );
1210    *   ```
1211    *
1212    * @since:
1213    *   2.6
1214    *
1215    */
1216 
1217 
1218  /* */
1219 
1220 
1221 FT_END_HEADER
1222 
1223 
1224 #endif /* FTDRIVER_H_ */
1225 
1226 
1227 /* END */
1228