11512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod/*
21512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Copyright (C) 1998-2004  David Turner and Werner Lemberg
31512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Copyright (C) 2006  Behdad Esfahbod
41512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
51512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * This is part of HarfBuzz, an OpenType Layout engine library.
61512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
71512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Permission is hereby granted, without written agreement and without
81512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
91512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * software and its documentation for any purpose, provided that the
101512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
111512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * all copies of this software.
121512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
131512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
141512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
151512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
161512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
171512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * DAMAGE.
181512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
191512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
201512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
211512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
221512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
231512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
241512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod */
251512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
261512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef HARFBUZZ_GDEF_H
271512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HARFBUZZ_GDEF_H
281512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
291512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#include "harfbuzz-open.h"
301512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#include "harfbuzz-stream.h"
311512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
321512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_BEGIN_HEADER
331512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
341512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifdef HB_USE_PACKED_STRUCTS
351512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#pragma pack(push, 1)
361512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
371512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
381512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding
391512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * flag in the LookupFlag field.     */
401512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_GDEF_BASE_GLYPH  0x0002
411512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_GDEF_LIGATURE    0x0004
421512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_GDEF_MARK        0x0008
431512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_GDEF_COMPONENT   0x0010
441512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
451512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
461512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_AttachPoint_  HB_AttachPoint;
471512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
481512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
491512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodstruct  HB_AttachList_
501512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod{
511512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */
521512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_Coverage       Coverage;         /* Coverage table              */
531512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UShort         GlyphCount;       /* number of glyphs with
541512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod					 attachments                 */
551512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_Bool           loaded;
561512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod};
571512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
581512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_AttachList_  HB_AttachList;
591512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
601512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_LigGlyph_  HB_LigGlyph;
611512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
621512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodstruct  HB_LigCaretList_
631512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod{
641512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */
651512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_Coverage    Coverage;            /* Coverage table            */
661512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */
671512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_Bool        loaded;
681512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod};
691512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
701512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_LigCaretList_  HB_LigCaretList;
711512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
721512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
731512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
741512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod/* The `NewGlyphClasses' field is not defined in the TTO specification.
751512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   We use it for fonts with a constructed `GlyphClassDef' structure
761512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   (i.e., which don't have a GDEF table) to collect glyph classes
771512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   assigned during the lookup process.  The number of arrays in this
781512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
791512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   array then contains the glyph class values of the glyphs not covered
801512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   by the ClassRangeRecords structures with index n-1 and n.  We store
811512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   glyph class values for four glyphs in a single array element.
821512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
831512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   `LastGlyph' is identical to the number of glyphs minus one in the
841512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   font; we need it only if `NewGlyphClasses' is not NULL (to have an
851512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   upper bound for the last array).
861512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
871512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   Note that we first store the file offset to the `MarkAttachClassDef'
881512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   field (which has been introduced in OpenType 1.2) -- since the
891512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   `Version' field value hasn't been increased to indicate that we have
901512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   one more field for some obscure reason, we must parse the GSUB table
911512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   to find out whether class values refer to this table.  Only then we
921512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod   can finally load the MarkAttachClassDef structure if necessary.      */
931512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
941512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodstruct  HB_GDEFHeader_
951512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod{
961512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UShort**          NewGlyphClasses;
971512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UInt             offset;
981512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UInt             MarkAttachClassDef_offset;
991512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1001512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_16Dot16             Version;
1011512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1021512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_ClassDefinition   GlyphClassDef;
1031512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_AttachList        AttachList;
1041512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_LigCaretList      LigCaretList;
1051512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */
1061512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1071512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  HB_UShort            LastGlyph;
1081512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod};
1091512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1101512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_GDEFHeader_   HB_GDEFHeader;
1111512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbodtypedef struct HB_GDEFHeader_*  HB_GDEF;
1121512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1131512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1141512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );
1151512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1161512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1171512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_Error  HB_Load_GDEF_Table( HB_Stream       stream,
1181512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod			      HB_GDEFHeader** gdef );
1191512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1201512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1211512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
1221512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1231512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1241512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
1251512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod				      HB_UShort        glyphID,
1261512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod				      HB_UShort*       property );
1271512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1281512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
1291512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod					 HB_UShort        num_glyphs,
1301512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod					 HB_UShort        glyph_count,
1311512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod					 HB_UShort*       glyph_array,
1321512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod					 HB_UShort*       class_array );
1331512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1341512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifdef HB_USE_PACKED_STRUCTS
1351512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#pragma pack(pop)
1361512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
1371512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1381512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_END_HEADER
1391512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1401512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif /* HARFBUZZ_GDEF_H */
141