summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype/freetype-1.5/lib/extend/ftxkern.h
blob: 4f981ec873714523ec38182320d6282b0a1d7655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*******************************************************************
 *
 *  ftxkern.h                                                   1.0
 *
 *    High-Level API Kerning extension
 *
 *  Copyright 1996-2001 by
 *  David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 *  This file is part of the FreeType project, and may only be used
 *  modified and distributed under the terms of the FreeType project
 *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
 *  this file you indicate that you have read the license and
 *  understand and accept it fully.
 *
 *
 *  The kerning support is currently part of the engine extensions.
 *
 *  This file should _not_ depend on engine internal types.
 *
 ******************************************************************/

#ifndef FTXKERN_H
#define FTXKERN_H

#include "freetype.h"

#ifdef __cplusplus
extern "C" {
#endif

  /* The kerning support in FreeType is minimal.  This means that  */
  /* we do not try to interpret the kerning data in any way to     */
  /* `cook' it for a user application.  This API lets you access   */
  /* directly the kerning tables found in the TrueType file; it's  */
  /* up to the client application to apply its own processing on   */
  /* these.                                                        */

  /* The reason for this is that we generally do not encourage     */
  /* feature-bloat of the core engine.  Moreover, not all          */
  /* libraries or font servers really need kerning data, or all    */
  /* formats of this data.                                         */

  /************** kerning error codes *****************************/

  /* we choose the class 0x0A for our errors, this should not      */
  /* match with any error code class used in any other extension   */

#define TT_Err_Invalid_Kerning_Table_Format  0x0A00
#define TT_Err_Invalid_Kerning_Table         0x0A01


  /********** structures definitions ******************************/

  /* Remember that all types and function are accessible by client */
  /* applications in this section, and thus should have the `TT_'  */
  /* prefix.                                                       */

  /* format 0 kerning pair */

  struct  TT_Kern_0_Pair_
  {
    TT_UShort  left;   /* index of left  glyph in pair */
    TT_UShort  right;  /* index of right glyph in pair */
    TT_FWord   value;  /* kerning value                */
  };

  typedef struct TT_Kern_0_Pair_  TT_Kern_0_Pair;


  /* format 0 kerning subtable */

  struct  TT_Kern_0_
  {
    TT_UShort  nPairs;          /* number of kerning pairs */

    TT_UShort  searchRange;     /* these values are defined by the TT spec */
    TT_UShort  entrySelector;   /* for table searchs.                      */
    TT_UShort  rangeShift;

    TT_Kern_0_Pair*  pairs;     /* a table of nPairs `pairs' */
  };

  typedef struct TT_Kern_0_  TT_Kern_0;


  /* format 2 kerning glyph class */

  struct  TT_Kern_2_Class_
  {
    TT_UShort   firstGlyph;   /* first glyph in range                    */
    TT_UShort   nGlyphs;      /* number of glyphs in range               */
    TT_UShort*  classes;      /* a table giving for each ranged glyph    */
                              /* its class offset in the subtable pairs  */
                              /* two-dimensional array                   */
  };

  typedef struct TT_Kern_2_Class_  TT_Kern_2_Class;


  /* format 2 kerning subtable */

  struct TT_Kern_2_
  {
    TT_UShort        rowWidth;   /* length of one row in bytes         */
    TT_Kern_2_Class  leftClass;  /* left class table                   */
    TT_Kern_2_Class  rightClass; /* right class table                  */
    TT_FWord*        array;      /* 2-dimensional kerning values array */
  };

  typedef struct TT_Kern_2_  TT_Kern_2;


  /* kerning subtable */

  struct  TT_Kern_Subtable_
  {
    TT_Bool    loaded;   /* boolean; indicates whether the table is   */
                         /* loaded                                    */
    TT_UShort  version;  /* table version number                      */
    TT_Long    offset;   /* file offset of table                      */
    TT_UShort  length;   /* length of table, _excluding_ header       */
    TT_Byte    coverage; /* lower 8 bit of the coverage table entry   */
    TT_Byte    format;   /* the subtable format, as found in the      */
                         /* higher 8 bits of the coverage table entry */
    union
    {
      TT_Kern_0  kern0;
      TT_Kern_2  kern2;
    } t;
  };

  typedef struct TT_Kern_Subtable_  TT_Kern_Subtable;


  struct  TT_Kerning_
  {
    TT_UShort          version;  /* kern table version number. starts at 0 */
    TT_UShort          nTables;  /* number of tables                       */

    TT_Kern_Subtable*  tables;   /* the kerning sub-tables                 */
  };

  typedef struct TT_Kerning_  TT_Kerning;



  /***************** high-level API extension **************************/

  /* Initialize Kerning extension, must be called after                 */
  /* TT_Init_FreeType(). There is no need for a finalizer               */
  FT_EXPORT_DEF( TT_Error )
  TT_Init_Kerning_Extension( TT_Engine  engine );

  /* Note on the implemented mechanism:                                 */

  /* The kerning table directory is loaded with the face through the    */
  /* extension constructor.  However, the tables will only be loaded    */
  /* on demand, as they may represent a lot of data, unnecessary to     */
  /* most applications.                                                 */

  /* Queries a pointer to the kerning directory for the face object     */
  FT_EXPORT_DEF( TT_Error )
  TT_Get_Kerning_Directory( TT_Face      face,
                            TT_Kerning*  directory );

  /* Load the kerning table number `kern_index' in the kerning          */
  /* directory.  The table will stay in memory until the `face'         */
  /* face is destroyed.                                                 */
  FT_EXPORT_DEF( TT_Error )
  TT_Load_Kerning_Table( TT_Face    face,
                         TT_UShort  kern_index );

#ifdef __cplusplus
}
#endif

#endif /* FTXKERN_H */


/* END */