1
/*******************************************************************
5
* High-Level API Kerning extension
7
* Copyright 1996-1999 by
8
* David Turner, Robert Wilhelm, and Werner Lemberg.
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.
17
* The kerning support is currently part of the engine extensions.
19
* This file should _not_ depend on engine internal types.
21
******************************************************************/
32
/* The kerning support in FreeType is minimal. This means that */
33
/* we do not try to interpret the kerning data in any way to */
34
/* `cook' it for a user application. This API lets you access */
35
/* directly the kerning tables found in the TrueType file; it's */
36
/* up to the client application to apply its own processing on */
39
/* The reason for this is that we generally do not encourage */
40
/* feature-bloat of the core engine. Moreover, not all */
41
/* libraries or font servers really need kerning data, or all */
42
/* formats of this data. */
44
/************** kerning error codes *****************************/
46
/* we choose the class 0x0A for our errors, this should not */
47
/* match with any error code class used in any other extension */
49
#define TT_Err_Invalid_Kerning_Table_Format 0x0A00
50
#define TT_Err_Invalid_Kerning_Table 0x0A01
53
/********** structures definitions ******************************/
55
/* Remember that all types and function are accessible by client */
56
/* applications in this section, and thus should have the `TT_' */
59
/* format 0 kerning pair */
61
struct TT_Kern_0_Pair_
63
TT_UShort left; /* index of left glyph in pair */
64
TT_UShort right; /* index of right glyph in pair */
65
TT_FWord value; /* kerning value */
68
typedef struct TT_Kern_0_Pair_ TT_Kern_0_Pair;
71
/* format 0 kerning subtable */
75
TT_UShort nPairs; /* number of kerning pairs */
77
TT_UShort searchRange; /* these values are defined by the TT spec */
78
TT_UShort entrySelector; /* for table searchs. */
81
TT_Kern_0_Pair* pairs; /* a table of nPairs `pairs' */
84
typedef struct TT_Kern_0_ TT_Kern_0;
87
/* format 2 kerning glyph class */
89
struct TT_Kern_2_Class_
91
TT_UShort firstGlyph; /* first glyph in range */
92
TT_UShort nGlyphs; /* number of glyphs in range */
93
TT_UShort* classes; /* a table giving for each ranged glyph */
94
/* its class offset in the subtable pairs */
95
/* two-dimensional array */
98
typedef struct TT_Kern_2_Class_ TT_Kern_2_Class;
101
/* format 2 kerning subtable */
105
TT_UShort rowWidth; /* length of one row in bytes */
106
TT_Kern_2_Class leftClass; /* left class table */
107
TT_Kern_2_Class rightClass; /* right class table */
108
TT_FWord* array; /* 2-dimensional kerning values array */
111
typedef struct TT_Kern_2_ TT_Kern_2;
114
/* kerning subtable */
116
struct TT_Kern_Subtable_
118
TT_Bool loaded; /* boolean; indicates whether the table is */
120
TT_UShort version; /* table version number */
121
TT_Long offset; /* file offset of table */
122
TT_UShort length; /* length of table, _excluding_ header */
123
TT_Byte coverage; /* lower 8 bit of the coverage table entry */
124
TT_Byte format; /* the subtable format, as found in the */
125
/* higher 8 bits of the coverage table entry */
133
typedef struct TT_Kern_Subtable_ TT_Kern_Subtable;
138
TT_UShort version; /* kern table version number. starts at 0 */
139
TT_UShort nTables; /* number of tables */
141
TT_Kern_Subtable* tables; /* the kerning sub-tables */
144
typedef struct TT_Kerning_ TT_Kerning;
148
/***************** high-level API extension **************************/
150
/* Initialize Kerning extension, must be called after */
151
/* TT_Init_FreeType(). There is no need for a finalizer */
153
TT_Error TT_Init_Kerning_Extension( TT_Engine engine );
155
/* Note on the implemented mechanism: */
157
/* The kerning table directory is loaded with the face through the */
158
/* extension constructor. However, the tables will only be loaded */
159
/* on demand, as they may represent a lot of data, unnecessary to */
160
/* most applications. */
162
/* Queries a pointer to the kerning directory for the face object */
164
TT_Error TT_Get_Kerning_Directory( TT_Face face,
165
TT_Kerning* directory );
167
/* Load the kerning table number `kern_index' in the kerning */
168
/* directory. The table will stay in memory until the `face' */
169
/* face is destroyed. */
171
TT_Error TT_Load_Kerning_Table( TT_Face face,
172
TT_UShort kern_index );
178
#endif /* FTXKERN_H */