1 /***************************************************************************/
2 /*                                                                         */
3 /*  afcjk.h                                                                */
4 /*                                                                         */
5 /*    Auto-fitter hinting routines for CJK writing system (specification). */
6 /*                                                                         */
7 /*  Copyright 2006, 2007, 2011-2013 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 __AFCJK_H__
20 #define __AFCJK_H__
21 
22 #include "afhints.h"
23 #include "aflatin.h"
24 
25 
26 FT_BEGIN_HEADER
27 
28 
29   /* the CJK-specific writing system */
30 
31   AF_DECLARE_WRITING_SYSTEM_CLASS( af_cjk_writing_system_class )
32 
33 
34   /*************************************************************************/
35   /*************************************************************************/
36   /*****                                                               *****/
37   /*****              C J K   G L O B A L   M E T R I C S              *****/
38   /*****                                                               *****/
39   /*************************************************************************/
40   /*************************************************************************/
41 
42 
43   /*
44    *  CJK glyphs tend to fill the square.  So we have both vertical and
45    *  horizontal blue zones.  But some glyphs have flat bounding strokes that
46    *  leave some space between neighbour glyphs.
47    */
48 
49 #define AF_CJK_IS_TOP_BLUE( b ) \
50           ( (b)->properties & AF_BLUE_PROPERTY_CJK_TOP )
51 #define AF_CJK_IS_HORIZ_BLUE( b ) \
52           ( (b)->properties & AF_BLUE_PROPERTY_CJK_HORIZ )
53 #define AF_CJK_IS_FILLED_BLUE( b ) \
54           ( (b)->properties & AF_BLUE_PROPERTY_CJK_FILL )
55 #define AF_CJK_IS_RIGHT_BLUE  AF_CJK_IS_TOP_BLUE
56 
57 #define AF_CJK_MAX_WIDTHS  16
58 
59 
60   enum
61   {
62     AF_CJK_BLUE_ACTIVE     = 1 << 0,  /* set if zone height is <= 3/4px */
63     AF_CJK_BLUE_TOP        = 1 << 1,  /* result of AF_CJK_IS_TOP_BLUE   */
64     AF_CJK_BLUE_ADJUSTMENT = 1 << 2,  /* used for scale adjustment      */
65                                       /* optimization                   */
66     AF_CJK_BLUE_FLAG_MAX
67   };
68 
69 
70   typedef struct  AF_CJKBlueRec_
71   {
72     AF_WidthRec  ref;
73     AF_WidthRec  shoot; /* undershoot */
74     FT_UInt      flags;
75 
76   } AF_CJKBlueRec, *AF_CJKBlue;
77 
78 
79   typedef struct  AF_CJKAxisRec_
80   {
81     FT_Fixed       scale;
82     FT_Pos         delta;
83 
84     FT_UInt        width_count;                   /* number of used widths */
85     AF_WidthRec    widths[AF_CJK_MAX_WIDTHS];     /* widths array          */
86     FT_Pos         edge_distance_threshold;     /* used for creating edges */
87     FT_Pos         standard_width;           /* the default stem thickness */
88     FT_Bool        extra_light;           /* is standard width very light? */
89 
90     /* used for horizontal metrics too for CJK */
91     FT_Bool        control_overshoot;
92     FT_UInt        blue_count;
93     AF_CJKBlueRec  blues[AF_BLUE_STRINGSET_MAX];
94 
95     FT_Fixed       org_scale;
96     FT_Pos         org_delta;
97 
98   } AF_CJKAxisRec, *AF_CJKAxis;
99 
100 
101   typedef struct  AF_CJKMetricsRec_
102   {
103     AF_StyleMetricsRec  root;
104     FT_UInt             units_per_em;
105     AF_CJKAxisRec       axis[AF_DIMENSION_MAX];
106 
107   } AF_CJKMetricsRec, *AF_CJKMetrics;
108 
109 
110 #ifdef AF_CONFIG_OPTION_CJK
111   FT_LOCAL( FT_Error )
112   af_cjk_metrics_init( AF_CJKMetrics  metrics,
113                        FT_Face        face );
114 
115   FT_LOCAL( void )
116   af_cjk_metrics_scale( AF_CJKMetrics  metrics,
117                         AF_Scaler      scaler );
118 
119   FT_LOCAL( FT_Error )
120   af_cjk_hints_init( AF_GlyphHints  hints,
121                      AF_CJKMetrics  metrics );
122 
123   FT_LOCAL( FT_Error )
124   af_cjk_hints_apply( AF_GlyphHints  hints,
125                       FT_Outline*    outline,
126                       AF_CJKMetrics  metrics );
127 
128   /* shared; called from afindic.c */
129   FT_LOCAL( void )
130   af_cjk_metrics_check_digits( AF_CJKMetrics  metrics,
131                                FT_Face        face );
132 
133   FT_LOCAL( void )
134   af_cjk_metrics_init_widths( AF_CJKMetrics  metrics,
135                               FT_Face        face );
136 #endif /* AF_CONFIG_OPTION_CJK */
137 
138 
139 /* */
140 
141 FT_END_HEADER
142 
143 #endif /* __AFCJK_H__ */
144 
145 
146 /* END */
147