Imported Upstream version 0.9.3
[platform/upstream/harfbuzz.git] / src / hb-old / harfbuzz-gdef.h
1 /*
2  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3  * Copyright (C) 2006  Behdad Esfahbod
4  *
5  * This is part of HarfBuzz, an OpenType Layout engine library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  */
25
26 #ifndef HARFBUZZ_GDEF_H
27 #define HARFBUZZ_GDEF_H
28
29 #include "harfbuzz-open.h"
30 #include "harfbuzz-stream.h"
31
32 HB_BEGIN_HEADER
33
34 #ifdef HB_USE_PACKED_STRUCTS
35 #pragma pack(push, 1)
36 #endif
37
38 /* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding
39  * flag in the LookupFlag field.     */
40 #define HB_GDEF_BASE_GLYPH  0x0002
41 #define HB_GDEF_LIGATURE    0x0004
42 #define HB_GDEF_MARK        0x0008
43 #define HB_GDEF_COMPONENT   0x0010
44
45
46 typedef struct HB_AttachPoint_  HB_AttachPoint;
47
48
49 struct  HB_AttachList_
50 {
51   HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */
52   HB_Coverage       Coverage;         /* Coverage table              */
53   HB_UShort         GlyphCount;       /* number of glyphs with
54                                          attachments                 */
55   HB_Bool           loaded;
56 };
57
58 typedef struct HB_AttachList_  HB_AttachList;
59
60 typedef struct HB_LigGlyph_  HB_LigGlyph;
61
62 struct  HB_LigCaretList_
63 {
64   HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */
65   HB_Coverage    Coverage;            /* Coverage table            */
66   HB_UShort      LigGlyphCount;       /* number of ligature glyphs */
67   HB_Bool        loaded;
68 };
69
70 typedef struct HB_LigCaretList_  HB_LigCaretList;
71
72
73
74 /* The `NewGlyphClasses' field is not defined in the TTO specification.
75    We use it for fonts with a constructed `GlyphClassDef' structure
76    (i.e., which don't have a GDEF table) to collect glyph classes
77    assigned during the lookup process.  The number of arrays in this
78    pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
79    array then contains the glyph class values of the glyphs not covered
80    by the ClassRangeRecords structures with index n-1 and n.  We store
81    glyph class values for four glyphs in a single array element.
82
83    `LastGlyph' is identical to the number of glyphs minus one in the
84    font; we need it only if `NewGlyphClasses' is not NULL (to have an
85    upper bound for the last array).
86
87    Note that we first store the file offset to the `MarkAttachClassDef'
88    field (which has been introduced in OpenType 1.2) -- since the
89    `Version' field value hasn't been increased to indicate that we have
90    one more field for some obscure reason, we must parse the GSUB table
91    to find out whether class values refer to this table.  Only then we
92    can finally load the MarkAttachClassDef structure if necessary.      */
93
94 struct  HB_GDEFHeader_
95 {
96   HB_UShort**          NewGlyphClasses;
97   HB_UInt             offset;
98   HB_UInt             MarkAttachClassDef_offset;
99
100   HB_16Dot16             Version;
101
102   HB_ClassDefinition   GlyphClassDef;
103   HB_AttachList        AttachList;
104   HB_LigCaretList      LigCaretList;
105   HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */
106
107   HB_UShort            LastGlyph;
108 };
109
110 typedef struct HB_GDEFHeader_   HB_GDEFHeader;
111 typedef struct HB_GDEFHeader_*  HB_GDEF;
112
113
114 HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );
115       
116
117 HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,
118                               HB_GDEFHeader** gdef );
119
120
121 HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
122
123
124 HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
125                                       HB_UShort        glyphID,
126                                       HB_UShort*       property );
127
128 HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
129                                          HB_UShort        num_glyphs,
130                                          HB_UShort        glyph_count,
131                                          HB_UShort*       glyph_array,
132                                          HB_UShort*       class_array );
133
134 #ifdef HB_USE_PACKED_STRUCTS
135 #pragma pack(pop)
136 #endif
137
138 HB_END_HEADER
139
140 #endif /* HARFBUZZ_GDEF_H */