1/***************************************************************************/
2/*                                                                         */
3/*  afblue.h                                                               */
4/*                                                                         */
5/*    Auto-fitter data for blue strings (specification).                   */
6/*                                                                         */
7/*  Copyright 2013-2018 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 AFBLUE_H_
20#define AFBLUE_H_
21
22
23FT_BEGIN_HEADER
24
25
26  /* an auxiliary macro to decode a UTF-8 character -- since we only use */
27  /* hard-coded, self-converted data, no error checking is performed     */
28#define GET_UTF8_CHAR( ch, p )                      \
29          do                                        \
30          {                                         \
31            ch = (unsigned char)*p++;               \
32            if ( ch >= 0x80 )                       \
33            {                                       \
34              FT_UInt  len_;                        \
35                                                    \
36                                                    \
37              if ( ch < 0xE0 )                      \
38              {                                     \
39                len_ = 1;                           \
40                ch  &= 0x1F;                        \
41              }                                     \
42              else if ( ch < 0xF0 )                 \
43              {                                     \
44                len_ = 2;                           \
45                ch  &= 0x0F;                        \
46              }                                     \
47              else                                  \
48              {                                     \
49                len_ = 3;                           \
50                ch  &= 0x07;                        \
51              }                                     \
52                                                    \
53              for ( ; len_ > 0; len_-- )            \
54                ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
55            }                                       \
56          } while ( 0 )
57
58
59  /*************************************************************************/
60  /*************************************************************************/
61  /*****                                                               *****/
62  /*****                    B L U E   S T R I N G S                    *****/
63  /*****                                                               *****/
64  /*************************************************************************/
65  /*************************************************************************/
66
67  /* At the bottommost level, we define strings for finding blue zones. */
68
69
70#define AF_BLUE_STRING_MAX_LEN  @AF_BLUE_STRING_MAX_LEN@
71
72  /* The AF_Blue_String enumeration values are offsets into the */
73  /* `af_blue_strings' array.                                   */
74
75  typedef enum  AF_Blue_String_
76  {
77@AF_BLUE_STRING_ENUM@
78
79    AF_BLUE_STRING_MAX   /* do not remove */
80
81  } AF_Blue_String;
82
83
84  FT_LOCAL_ARRAY( char )
85  af_blue_strings[];
86
87
88  /*************************************************************************/
89  /*************************************************************************/
90  /*****                                                               *****/
91  /*****                 B L U E   S T R I N G S E T S                 *****/
92  /*****                                                               *****/
93  /*************************************************************************/
94  /*************************************************************************/
95
96  /* The next level is to group blue strings into style-specific sets. */
97
98
99  /* Properties are specific to a writing system.  We assume that a given  */
100  /* blue string can't be used in more than a single writing system, which */
101  /* is a safe bet.                                                        */
102#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1U << 0 )  /* must have value 1 */
103#define AF_BLUE_PROPERTY_LATIN_SUB_TOP   ( 1U << 1 )
104#define AF_BLUE_PROPERTY_LATIN_NEUTRAL   ( 1U << 2 )
105#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1U << 3 )
106#define AF_BLUE_PROPERTY_LATIN_LONG      ( 1U << 4 )
107
108#define AF_BLUE_PROPERTY_CJK_TOP    ( 1U << 0 )       /* must have value 1 */
109#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1U << 1 )       /* must have value 2 */
110#define AF_BLUE_PROPERTY_CJK_RIGHT  AF_BLUE_PROPERTY_CJK_TOP
111
112
113#define AF_BLUE_STRINGSET_MAX_LEN  @AF_BLUE_STRINGSET_MAX_LEN@
114
115  /* The AF_Blue_Stringset enumeration values are offsets into the */
116  /* `af_blue_stringsets' array.                                   */
117
118  typedef enum  AF_Blue_Stringset_
119  {
120@AF_BLUE_STRINGSET_ENUM@
121
122    AF_BLUE_STRINGSET_MAX   /* do not remove */
123
124  } AF_Blue_Stringset;
125
126
127  typedef struct  AF_Blue_StringRec_
128  {
129    AF_Blue_String  string;
130    FT_UShort       properties;
131
132  } AF_Blue_StringRec;
133
134
135  FT_LOCAL_ARRAY( AF_Blue_StringRec )
136  af_blue_stringsets[];
137
138/* */
139
140FT_END_HEADER
141
142
143#endif /* AFBLUE_H_ */
144
145
146/* END */
147