*** empty log message ***
[m17n/libotf.git] / src / otf.h
index c84368e..31ff7b5 100644 (file)
--- a/src/otf.h
+++ b/src/otf.h
@@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA.  */
 /***
     Table of contents:
 
-    (1) Structures for OTF tables and OTF itself
+    (1) Structures for OTF Layout tables and OTF itself
     (1-1) Basic types
     (1-2) "head" table
     (1-3) "name" table
@@ -35,9 +35,10 @@ Boston, MA 02111-1307, USA.  */
     (1-5) Structures common to GDEF, GSUB, and GPOS
     (1-6) "GDEF" table
     (1-7) Structures for ScriptList, FeatureList, and LookupList
-    (1-8) "GSUB" table
-    (1-9) "GPOS" table
-    (1-9) Structure for OTF
+    (1-8) Structures common to GSUB and GPOS
+    (1-9) "GSUB" table
+    (1-10) "GPOS" table
+    (1-11) Structure for OTF
 
     (2) APIs for reading OTF
     (2-1) OTF_open()
@@ -60,7 +61,8 @@ Boston, MA 02111-1307, USA.  */
 
 */
 
-/*** (1) Structures for OTF tables and OTF itself */
+\f
+/*** (1) Structures for OTF Layout tables and OTF itself */
 
 /*** (1-1) Basic types */
 
@@ -464,215 +466,231 @@ typedef struct
   OTF_Lookup *Lookup;
 } OTF_LookupList;
 
-/*** (1-8) "GSUB" table */
+
+/*** (1-8) Structures common to GSUB and GPOS */
+
+/* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS).  */
 
 typedef struct
 {
-  int DeltaGlyphID;
-} OTF_GSUB_Single1;
+  unsigned SequenceIndex;
+  unsigned LookupListIndex;
+} OTF_LookupRecord;
 
 typedef struct
 {
+  OTF_Offset offset;
   unsigned GlyphCount;
-  OTF_GlyphID *Substitute;
-} OTF_GSUB_Single2;
-
-typedef struct OTF_Sequence OTF_Sequence;
+  unsigned LookupCount;
+  OTF_GlyphID *Input;          /* [<GlyphCount> - 1] */
+  OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
+} OTF_Rule;
 
 typedef struct
 {
-  unsigned SequenceCount;
-  OTF_Sequence *Sequence;
-} OTF_GSUB_Multiple1;
+  OTF_Offset offset;
+  unsigned RuleCount;
+  OTF_Rule *Rule;              /* [<RuleCount>] */
+} OTF_RuleSet;
 
-struct OTF_Sequence
+typedef struct
 {
   OTF_Offset offset;
   unsigned GlyphCount;
-  OTF_GlyphID *Substitute;
-};
-
-typedef struct OTF_AlternateSet OTF_AlternateSet;
+  unsigned LookupCount;
+  unsigned *Class;             /* [<GlyphCount> - 1] */
+  OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
+} OTF_ClassRule;
 
 typedef struct
 {
-  unsigned AlternateSetCount;
-  OTF_AlternateSet *AlternateSet;
-} OTF_GSUB_Alternate1;
-
-struct OTF_AlternateSet
-{
   OTF_Offset offset;
-  unsigned GlyphCount;
-  OTF_GlyphID *Alternate;
-};
-
-typedef struct OTF_LigatureSet OTF_LigatureSet;
-typedef struct OTF_Ligature OTF_Ligature;
+  unsigned ClassRuleCnt;
+  OTF_ClassRule *ClassRule;    /* [<ClassRuleCnt>] */
+} OTF_ClassSet;
 
 typedef struct
 {
-  unsigned LigSetCount;
-  OTF_LigatureSet *LigatureSet;
-} OTF_GSUB_Ligature1;
+  OTF_Offset offset;
+  unsigned BacktrackGlyphCount;
+  OTF_GlyphID *Backtrack;
+  unsigned InputGlyphCount;
+  OTF_GlyphID *Input;
+  unsigned LookaheadGlyphCount;
+  OTF_GlyphID *LookAhead;
+  unsigned LookupCount;
+  OTF_LookupRecord *LookupRecord;
+} OTF_ChainRule;
 
-struct OTF_LigatureSet
+typedef struct
 {
   OTF_Offset offset;
-  unsigned LigatureCount;
-  OTF_Ligature *Ligature;
-};
+  unsigned ChainRuleCount;
+  OTF_ChainRule *ChainRule;
+} OTF_ChainRuleSet;
 
-struct OTF_Ligature
+typedef struct
 {
   OTF_Offset offset;
-  OTF_GlyphID LigGlyph;
-  unsigned CompCount;
-  OTF_GlyphID *Component;
-};
+  unsigned BacktrackGlyphCount;
+  unsigned *Backtrack;
+  unsigned InputGlyphCount;
+  unsigned *Input;
+  unsigned LookaheadGlyphCount;
+  unsigned *LookAhead;
+  unsigned LookupCount;
+  OTF_LookupRecord *LookupRecord;
+} OTF_ChainClassRule;
 
 typedef struct
 {
-  unsigned SequenceIndex;
-  unsigned LookupListIndex;
-} OTF_LookupRecord;
+  OTF_Offset offset;
+  unsigned ChainClassRuleCnt;
+  OTF_ChainClassRule *ChainClassRule;
+} OTF_ChainClassSet;
 
-typedef struct OTF_RuleSet OTF_RuleSet;
+
+/* Common to OTF_GSUB/GPOS_Context1/2/3.  */
 
 typedef struct
 {
-  unsigned SubRuleSetCount;
-  OTF_RuleSet *SubRuleSet;     /* [<SubRuleSetCount>] */
-} OTF_GSUB_Context1;
-
-typedef struct OTF_Rule OTF_Rule;
+  unsigned RuleSetCount;
+  OTF_RuleSet *RuleSet;                /* [<RuleSetCount>] */
+} OTF_Context1;
 
-struct OTF_RuleSet
+typedef struct
 {
-  OTF_Offset offset;
-  unsigned RuleCount;
-  OTF_Rule *Rule;              /* [<RuleCount>] */
-};
+  OTF_ClassDef ClassDef;
+  unsigned ClassSetCnt;
+  OTF_ClassSet *ClassSet;      /* [<ClassSetCnt>] */
+} OTF_Context2;
 
-struct OTF_Rule
+typedef struct
 {
-  OTF_Offset offset;
   unsigned GlyphCount;
   unsigned LookupCount;
-  OTF_GlyphID *Input;          /* [<GlyphCount> - 1] */
+  OTF_Coverage *Coverage;      /* [<GlyphCount>] */
   OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
-};
+} OTF_Context3;
 
-typedef struct OTF_ClassSet OTF_ClassSet;
+
+/* Common to OTF_GSUB/GPOS_ChainContext1/2/3.  */
 
 typedef struct
 {
-  OTF_ClassDef ClassDef;
-  unsigned SubClassSetCnt;
-  OTF_ClassSet *SubClassSet;   /* [<ClassSetCnt>] */
-} OTF_GSUB_Context2;
+  unsigned ChainRuleSetCount;
+  OTF_ChainRuleSet *ChainRuleSet;
+} OTF_ChainContext1;
 
-typedef struct OTF_ClassRule OTF_ClassRule;
-
-struct OTF_ClassSet
+typedef struct
 {
-  OTF_Offset offset;
-  unsigned ClassRuleCnt;
-  OTF_ClassRule *ClassRule;    /* [<ClassRuleCnt>] */
-};
+  OTF_ClassDef BacktrackClassDef;
+  OTF_ClassDef InputClassDef;
+  OTF_ClassDef LookaheadClassDef;
+  unsigned ChainClassSetCnt;
+  OTF_ChainClassSet *ChainClassSet;
+} OTF_ChainContext2;
 
-struct OTF_ClassRule
+typedef struct
 {
-  OTF_Offset offset;
-  unsigned GlyphCount;
+  unsigned BacktrackGlyphCount;
+  OTF_Coverage *Backtrack;
+  unsigned InputGlyphCount;
+  OTF_Coverage *Input;
+  unsigned LookaheadGlyphCount;
+  OTF_Coverage *LookAhead;
   unsigned LookupCount;
-  unsigned *Class;             /* [<GlyphCount> - 1] */
-  OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
-};
+  OTF_LookupRecord *LookupRecord;
+} OTF_ChainContext3;
+
+/* Common to OTF_GSUB/GPOS.  */
 
 typedef struct
 {
-  unsigned GlyphCount;
-  unsigned SubstCount;
-  OTF_Coverage *Coverage;
-  OTF_LookupRecord *LookupRecord;
-} OTF_GSUB_Context3;
+  OTF_Fixed Version;
+  OTF_ScriptList ScriptList;
+  OTF_FeatureList FeatureList;
+  OTF_LookupList LookupList;
+} OTF_GSUB_GPOS;
 
-typedef struct OTF_ChainRuleSet OTF_ChainRuleSet;
+/*** (1-9) "GSUB" table */
 
 typedef struct
 {
-  unsigned ChainSubRuleSetCount;
-  OTF_ChainRuleSet *ChainSubRuleSet;
-} OTF_GSUB_ChainContext1;
+  int DeltaGlyphID;
+} OTF_GSUB_Single1;
+
+typedef struct
+{
+  unsigned GlyphCount;
+  OTF_GlyphID *Substitute;
+} OTF_GSUB_Single2;
 
-typedef struct OTF_ChainRule OTF_ChainRule;
+typedef struct OTF_Sequence OTF_Sequence;
+
+typedef struct
+{
+  unsigned SequenceCount;
+  OTF_Sequence *Sequence;
+} OTF_GSUB_Multiple1;
 
-struct OTF_ChainRuleSet
+struct OTF_Sequence
 {
   OTF_Offset offset;
-  unsigned ChainRuleCount;
-  OTF_ChainRule *ChainRule;
+  unsigned GlyphCount;
+  OTF_GlyphID *Substitute;
 };
 
-struct OTF_ChainRule
+typedef struct OTF_AlternateSet OTF_AlternateSet;
+
+typedef struct
+{
+  unsigned AlternateSetCount;
+  OTF_AlternateSet *AlternateSet;
+} OTF_GSUB_Alternate1;
+
+struct OTF_AlternateSet
 {
   OTF_Offset offset;
-  unsigned BacktrackGlyphCount;
-  OTF_GlyphID *Backtrack;
-  unsigned InputGlyphCount;
-  OTF_GlyphID *Input;
-  unsigned LookaheadGlyphCount;
-  OTF_GlyphID *LookAhead;
-  unsigned LookupCount;
-  OTF_LookupRecord *LookupRecord;
+  unsigned GlyphCount;
+  OTF_GlyphID *Alternate;
 };
 
-typedef struct OTF_ChainClassSet OTF_ChainClassSet;
+typedef struct OTF_LigatureSet OTF_LigatureSet;
+typedef struct OTF_Ligature OTF_Ligature;
 
 typedef struct
 {
-  OTF_ClassDef Backtrack;
-  OTF_ClassDef Input;
-  OTF_ClassDef LookAhead;
-  unsigned ChainSubClassSetCnt;
-  OTF_ChainClassSet *ChainSubClassSet;
-} OTF_GSUB_ChainContext2;
-
-typedef struct OTF_ChainClassRule OTF_ChainClassRule;
+  unsigned LigSetCount;
+  OTF_LigatureSet *LigatureSet;
+} OTF_GSUB_Ligature1;
 
-struct OTF_ChainClassSet
+struct OTF_LigatureSet
 {
   OTF_Offset offset;
-  unsigned ChainClassRuleCnt;
-  OTF_ChainClassRule *ChainClassRule;
+  unsigned LigatureCount;
+  OTF_Ligature *Ligature;
 };
 
-struct OTF_ChainClassRule
+struct OTF_Ligature
 {
   OTF_Offset offset;
-  unsigned BacktrackGlyphCount;
-  unsigned *Backtrack;
-  unsigned InputGlyphCount;
-  unsigned *Input;
-  unsigned LookaheadGlyphCount;
-  unsigned *LookAhead;
-  unsigned LookupCount;
-  OTF_LookupRecord *LookupRecord;
+  OTF_GlyphID LigGlyph;
+  unsigned CompCount;
+  OTF_GlyphID *Component;
 };
 
+typedef OTF_Context1 OTF_GSUB_Context1;
 
-typedef struct
-{
-  unsigned BacktrackGlyphCount;
-  OTF_Coverage *Backtrack;
-  unsigned InputGlyphCount;
-  OTF_Coverage *Input;
-  unsigned LookaheadGlyphCount;
-  OTF_Coverage *LookAhead;
-  unsigned SubstCount;
-  OTF_LookupRecord *LookupRecord;
-} OTF_GSUB_ChainContext3;
+typedef OTF_Context2 OTF_GSUB_Context2;
+
+typedef OTF_Context3 OTF_GSUB_Context3;
+
+typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
+
+typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
+
+typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
 
 typedef struct
 {
@@ -719,15 +737,9 @@ struct OTF_LookupSubTableGSUB
   } u;
 };
 
-typedef struct
-{
-  OTF_Fixed Version;
-  OTF_ScriptList ScriptList;
-  OTF_FeatureList FeatureList;
-  OTF_LookupList LookupList;
-} OTF_GSUB;
+typedef OTF_GSUB_GPOS OTF_GSUB;
 
-/*** (1-8) "GPOS" table */
+/*** (1-10) "GPOS" table */
 
 enum OTF_ValueFormat
   {
@@ -861,54 +873,17 @@ typedef struct
   OTF_AnchorArray Mark2Array;
 } OTF_GPOS_MarkMark1;
 
+typedef OTF_Context1 OTF_GPOS_Context1;
 
-typedef struct
-{
-  unsigned PosRuleSetCount;
-  OTF_RuleSet *PosRuleSet;
-} OTF_GPOS_Context1;
+typedef OTF_Context2 OTF_GPOS_Context2;
 
-typedef struct
-{
-  OTF_ClassDef ClassDef;
-  unsigned PosClassSetCnt;
-  OTF_ClassSet *PosClassSet;
-} OTF_GPOS_Context2;
+typedef OTF_Context3 OTF_GPOS_Context3;
 
-typedef struct
-{
-  unsigned GlyphCount;
-  unsigned PosCount;
-  OTF_Coverage *Coverage;      /* [<GlyphCount>] */
-  OTF_LookupRecord *LookupRecord;      /* [<PosCount>] */
-} OTF_GPOS_Context3;
+typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
 
-typedef struct
-{
-  unsigned ChainPosRuleSetCount;
-  OTF_ChainRuleSet *ChainPosRuleSet;
-} OTF_GPOS_ChainContext1;
+typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
 
-typedef struct
-{
-  OTF_ClassDef Backtrack;
-  OTF_ClassDef Input;
-  OTF_ClassDef LookAhead;
-  unsigned ChainPosClassSetCnt;
-  OTF_ChainClassSet *ChainPosClassSet;
-} OTF_GPOS_ChainContext2;
-
-typedef struct
-{
-  unsigned BacktrackGlyphCount;
-  OTF_Coverage *Backtrack;
-  unsigned InputGlyphCount;
-  OTF_Coverage *Input;
-  unsigned LookaheadGlyphCount;
-  OTF_Coverage *LookAhead;
-  unsigned PosCount;
-  OTF_LookupRecord *LookupRecord;
-} OTF_GPOS_ChainContext3;
+typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
 
 typedef struct
 {
@@ -948,15 +923,9 @@ struct OTF_LookupSubTableGPOS
   } u;
 };
 
-typedef struct
-{
-  OTF_Fixed Version;
-  OTF_ScriptList ScriptList;
-  OTF_FeatureList FeatureList;
-  OTF_LookupList LookupList;
-} OTF_GPOS;
+typedef OTF_GSUB_GPOS OTF_GPOS;
 
-/*** (1-9) Structure for OTF */
+/*** (1-11) Structure for OTF */
 
 typedef struct
 {
@@ -1281,9 +1250,9 @@ extern OTF_Tag OTF_tag (char *name);
 /***
     Convert OTF tag to name string.
 
-    The OTF_tag_name() function converts OTF tag $TAG to a 5-byte
-    name string (including the terminating NUL), and store it in
-    $NAME.  At least 5-byte space must be at $NAME.  */
+    The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
+    string (including the terminating NULL), and store it in $NAME.
+    At least 5-byte space must be at $NAME.  */
 
 extern void OTF_tag_name (OTF_Tag tag, char *name);