1727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/***************************************************************************/
2727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
3727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  cf2blues.h                                                             */
4727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
5727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*    Adobe's code for handling Blue Zones (specification).                */
6727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
7727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  Copyright 2009-2013 Adobe Systems Incorporated.                        */
8727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
9727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  This software, and all works of authorship, whether in source or       */
10727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  object code form as indicated by the copyright notice(s) included      */
11727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  herein (collectively, the "Work") is made available, and may only be   */
12727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  used, modified, and distributed under the FreeType Project License,    */
13727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  LICENSE.TXT.  Additionally, subject to the terms and conditions of the */
14727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  FreeType Project License, each contributor to the Work hereby grants   */
15727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  to any individual or legal entity exercising permissions granted by    */
16727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  the FreeType Project License and this section (hereafter, "You" or     */
17727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  "Your") a perpetual, worldwide, non-exclusive, no-charge,              */
18727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  royalty-free, irrevocable (except as stated in this section) patent    */
19727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  license to make, have made, use, offer to sell, sell, import, and      */
20727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  otherwise transfer the Work, where such license applies only to those  */
21727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  patent claims licensable by such contributor that are necessarily      */
22727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  infringed by their contribution(s) alone or by combination of their    */
23727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  contribution(s) with the Work to which such contribution(s) was        */
24727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  submitted.  If You institute patent litigation against any entity      */
25727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  (including a cross-claim or counterclaim in a lawsuit) alleging that   */
26727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  the Work or a contribution incorporated within the Work constitutes    */
27727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  direct or contributory patent infringement, then any patent licenses   */
28727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  granted to You under this License for that Work shall terminate as of  */
29727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  the date such litigation is filed.                                     */
30727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
31727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  By using, modifying, or distributing the Work you indicate that you    */
32727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  have read and understood the terms and conditions of the               */
33727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  FreeType Project License as well as those provided in this section,    */
34727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*  and you accept them fully.                                             */
35727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/*                                                                         */
36727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/***************************************************************************/
37727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
38727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
39727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /*
40727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * A `CF2_Blues' object stores the blue zones (horizontal alignment
41727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * zones) of a font.  These are specified in the CFF private dictionary
42727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * by `BlueValues', `OtherBlues', `FamilyBlues', and `FamilyOtherBlues'.
43727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Each zone is defined by a top and bottom edge in character space.
44727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Further, each zone is either a top zone or a bottom zone, as recorded
45727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * by `bottomZone'.
46727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
47727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * The maximum number of `BlueValues' and `FamilyBlues' is 7 each.
48727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * However, these are combined to produce a total of 7 zones.
49727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Similarly, the maximum number of `OtherBlues' and `FamilyOtherBlues'
50727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * is 5 and these are combined to produce an additional 5 zones.
51727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
52727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Blue zones are used to `capture' hints and force them to a common
53727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * alignment point.  This alignment is recorded in device space in
54727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `dsFlatEdge'.  Except for this value, a `CF2_Blues' object could be
55727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * constructed independently of scaling.  Construction may occur once
56727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * the matrix is known.  Other features implemented in the Capture
57727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * method are overshoot suppression, overshoot enforcement, and Blue
58727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Boost.
59727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
60727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Capture is determined by `BlueValues' and `OtherBlues', but the
61727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * alignment point may be adjusted to the scaled flat edge of
62727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `FamilyBlues' or `FamilyOtherBlues'.  No alignment is done to the
63727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * curved edge of a zone.
64727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
65727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   */
66727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
67727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
68727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease#ifndef __CF2BLUES_H__
69727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease#define __CF2BLUES_H__
70727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
71727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
72727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease#include "cf2glue.h"
73727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
74727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
75727dee178a392d20eb050d0c446f2fcc29058fa1Victoria LeaseFT_BEGIN_HEADER
76727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
77727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
78727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /*
79727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `CF2_Hint' is shared by `cf2hints.h' and
80727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `cf2blues.h', but `cf2blues.h' depends on
81727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `cf2hints.h', so define it here.  Note: The typedef is in
82727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * `cf2glue.h'.
83727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
84727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   */
85727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  enum
86727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
87727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_GhostBottom = 0x1,  /* a single bottom edge           */
88727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_GhostTop    = 0x2,  /* a single top edge              */
89727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_PairBottom  = 0x4,  /* the bottom edge of a stem hint */
90727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_PairTop     = 0x8,  /* the top edge of a stem hint    */
91727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Locked      = 0x10, /* this edge has been aligned     */
92727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                            /* by a blue zone                 */
93727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Synthetic   = 0x20  /* this edge was synthesized      */
94727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  };
95727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
96727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
97727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /*
98727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Default value for OS/2 typoAscender/Descender when their difference
99727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * is not equal to `unitsPerEm'.  The default is based on -250 and 1100
100727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * in `CF2_Blues', assuming 1000 units per em here.
101727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   *
102727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   */
103727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  enum
104727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
105727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_ICF_Top    = cf2_intToFixed(  880 ),
106727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_ICF_Bottom = cf2_intToFixed( -120 )
107727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  };
108727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
109727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
110727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /*
111727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * Constant used for hint adjustment and for synthetic em box hint
112727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   * placement.
113727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease   */
114727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease#define CF2_MIN_COUNTER  cf2_floatToFixed( 0.5 )
115727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
116727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
117727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /* shared typedef is in cf2glue.h */
118727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  struct  CF2_HintRec_
119727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
120727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_UInt  flags;  /* attributes of the edge            */
121727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    size_t    index;  /* index in original stem hint array */
122727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                      /* (if not synthetic)                */
123727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  csCoord;
124727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  dsCoord;
125727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  scale;
126727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  };
127727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
128727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
129727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  typedef struct  CF2_BlueRec_
130727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
131727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  csBottomEdge;
132727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  csTopEdge;
133727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  csFlatEdge; /* may be from either local or Family zones */
134727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  dsFlatEdge; /* top edge of bottom zone or bottom edge   */
135727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                           /* of top zone (rounded)                    */
136727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    FT_Bool  bottomZone;
137727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
138727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  } CF2_BlueRec;
139727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
140727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
141727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  /* max total blue zones is 12 */
142727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  enum
143727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
144727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_MAX_BLUES      = 7,
145727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_MAX_OTHERBLUES = 5
146727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  };
147727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
148727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
149727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  typedef struct  CF2_BluesRec_
150727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  {
151727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  scale;
152727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_UInt   count;
153727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    FT_Bool    suppressOvershoot;
154727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    FT_Bool    doEmBoxHints;
155727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
156727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  blueScale;
157727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  blueShift;
158727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  blueFuzz;
159727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
160727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_Fixed  boost;
161727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
162727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_HintRec  emBoxTopEdge;
163727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_HintRec  emBoxBottomEdge;
164727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
165727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease    CF2_BlueRec  zone[CF2_MAX_BLUES + CF2_MAX_OTHERBLUES];
166727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
167727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  } CF2_BluesRec, *CF2_Blues;
168727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
169727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
170727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  FT_LOCAL( void )
171727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  cf2_blues_init( CF2_Blues  blues,
172727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                  CF2_Font   font );
173727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  FT_LOCAL( FT_Bool )
174727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease  cf2_blues_capture( const CF2_Blues  blues,
175727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                     CF2_Hint         bottomHintEdge,
176727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease                     CF2_Hint         topHintEdge );
177727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
178727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
179727dee178a392d20eb050d0c446f2fcc29058fa1Victoria LeaseFT_END_HEADER
180727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
181727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
182727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease#endif /* __CF2BLUES_H__ */
183727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
184727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease
185727dee178a392d20eb050d0c446f2fcc29058fa1Victoria Lease/* END */
186