Eneboo - Documentación para desarrolladores
src/qt/src/3rdparty/opentype/ftxgsub.h
Ir a la documentación de este archivo.
00001 /*******************************************************************
00002  *
00003  *  ftxgsub.h
00004  *
00005  *    TrueType Open GSUB table support
00006  *
00007  *  Copyright 1996-2000 by
00008  *  David Turner, Robert Wilhelm, and Werner Lemberg.
00009  *
00010  *  This file is part of the FreeType project, and may only be used
00011  *  modified and distributed under the terms of the FreeType project
00012  *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
00013  *  this file you indicate that you have read the license and
00014  *  understand and accept it fully.
00015  *
00016  ******************************************************************/
00017 
00018 #ifndef FTXOPEN_H
00019 #error "Don't include this file! Use ftxopen.h instead."
00020 #endif
00021 
00022 #ifndef FTXGSUB_H
00023 #define FTXGSUB_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #define TTO_Err_Invalid_GSUB_SubTable_Format  0x1010
00030 #define TTO_Err_Invalid_GSUB_SubTable         0x1011
00031 
00032 
00033 /* Lookup types for glyph substitution */
00034 
00035 #define GSUB_LOOKUP_SINGLE     1
00036 #define GSUB_LOOKUP_MULTIPLE   2
00037 #define GSUB_LOOKUP_ALTERNATE  3
00038 #define GSUB_LOOKUP_LIGATURE   4
00039 #define GSUB_LOOKUP_CONTEXT    5
00040 #define GSUB_LOOKUP_CHAIN      6
00041 #define GSUB_LOOKUP_EXTENSION  7
00042 
00043 
00044 /* Use this if a feature applies to all glyphs */
00045 
00046 #define ALL_GLYPHS  0xFFFF
00047 
00048 
00049   /* A pointer to a function which selects the alternate glyph.  `pos' is
00050      the position of the glyph with index `glyphID', `num_alternates'
00051      gives the number of alternates in the `alternates' array.  `data'
00052      points to the user-defined structure specified during a call to
00053      TT_GSUB_Register_Alternate_Function().  The function must return an
00054      index into the `alternates' array.                                   */
00055 
00056   typedef FT_UShort  (*TTO_AltFunction)(FT_ULong    pos,
00057                                         FT_UShort   glyphID,
00058                                         FT_UShort   num_alternates,
00059                                         FT_UShort*  alternates,
00060                                         void*       data );
00061 
00062 
00063   struct  TTO_GSUBHeader_
00064   {
00065     FT_Memory        memory;
00066     
00067     FT_ULong         offset;
00068 
00069     FT_Fixed         Version;
00070 
00071     TTO_ScriptList   ScriptList;
00072     TTO_FeatureList  FeatureList;
00073     TTO_LookupList   LookupList;
00074 
00075     TTO_GDEFHeader*  gdef;
00076 
00077     /* the next two fields are used for an alternate substitution callback
00078        function to select the proper alternate glyph.                      */
00079 
00080     TTO_AltFunction  altfunc;
00081     void*            data;
00082   };
00083 
00084   typedef struct TTO_GSUBHeader_   TTO_GSUBHeader;
00085   typedef struct TTO_GSUBHeader_*  TTO_GSUB;
00086 
00087 
00088   /* LookupType 1 */
00089 
00090   struct  TTO_SingleSubstFormat1_
00091   {
00092     FT_Short  DeltaGlyphID;             /* constant added to get
00093                                            substitution glyph index */
00094   };
00095 
00096   typedef struct TTO_SingleSubstFormat1_  TTO_SingleSubstFormat1;
00097 
00098 
00099   struct  TTO_SingleSubstFormat2_
00100   {
00101     FT_UShort   GlyphCount;             /* number of glyph IDs in
00102                                            Substitute array              */
00103     FT_UShort*  Substitute;             /* array of substitute glyph IDs */
00104   };
00105 
00106   typedef struct TTO_SingleSubstFormat2_  TTO_SingleSubstFormat2;
00107 
00108 
00109   struct  TTO_SingleSubst_
00110   {
00111     FT_UShort     SubstFormat;          /* 1 or 2         */
00112     TTO_Coverage  Coverage;             /* Coverage table */
00113 
00114     union
00115     {
00116       TTO_SingleSubstFormat1  ssf1;
00117       TTO_SingleSubstFormat2  ssf2;
00118     } ssf;
00119   };
00120 
00121   typedef struct TTO_SingleSubst_  TTO_SingleSubst;
00122 
00123 
00124   /* LookupType 2 */
00125 
00126   struct  TTO_Sequence_
00127   {
00128     FT_UShort   GlyphCount;             /* number of glyph IDs in the
00129                                            Substitute array           */
00130     FT_UShort*  Substitute;             /* string of glyph IDs to
00131                                            substitute                 */
00132   };
00133 
00134   typedef struct TTO_Sequence_  TTO_Sequence;
00135 
00136 
00137   struct  TTO_MultipleSubst_
00138   {
00139     FT_UShort      SubstFormat;         /* always 1                  */
00140     TTO_Coverage   Coverage;            /* Coverage table            */
00141     FT_UShort      SequenceCount;       /* number of Sequence tables */
00142     TTO_Sequence*  Sequence;            /* array of Sequence tables  */
00143   };
00144 
00145   typedef struct TTO_MultipleSubst_  TTO_MultipleSubst;
00146 
00147 
00148   /* LookupType 3 */
00149 
00150   struct  TTO_AlternateSet_
00151   {
00152     FT_UShort   GlyphCount;             /* number of glyph IDs in the
00153                                            Alternate array              */
00154     FT_UShort*  Alternate;              /* array of alternate glyph IDs */
00155   };
00156 
00157   typedef struct TTO_AlternateSet_  TTO_AlternateSet;
00158 
00159 
00160   struct  TTO_AlternateSubst_
00161   {
00162     FT_UShort          SubstFormat;     /* always 1                      */
00163     TTO_Coverage       Coverage;        /* Coverage table                */
00164     FT_UShort          AlternateSetCount;
00165                                         /* number of AlternateSet tables */
00166     TTO_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */
00167   };
00168 
00169   typedef struct TTO_AlternateSubst_  TTO_AlternateSubst;
00170 
00171 
00172   /* LookupType 4 */
00173 
00174   struct  TTO_Ligature_
00175   {
00176     FT_UShort   LigGlyph;               /* glyphID of ligature
00177                                            to substitute                    */
00178     FT_UShort   ComponentCount;         /* number of components in ligature */
00179     FT_UShort*  Component;              /* array of component glyph IDs     */
00180   };
00181 
00182   typedef struct TTO_Ligature_  TTO_Ligature;
00183 
00184 
00185   struct  TTO_LigatureSet_
00186   {
00187     FT_UShort      LigatureCount;       /* number of Ligature tables */
00188     TTO_Ligature*  Ligature;            /* array of Ligature tables  */
00189   };
00190 
00191   typedef struct TTO_LigatureSet_  TTO_LigatureSet;
00192 
00193 
00194   struct  TTO_LigatureSubst_
00195   {
00196     FT_UShort         SubstFormat;      /* always 1                     */
00197     TTO_Coverage      Coverage;         /* Coverage table               */
00198     FT_UShort         LigatureSetCount; /* number of LigatureSet tables */
00199     TTO_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */
00200   };
00201 
00202   typedef struct TTO_LigatureSubst_  TTO_LigatureSubst;
00203 
00204 
00205   /* needed by both lookup type 5 and 6 */
00206 
00207   struct  TTO_SubstLookupRecord_
00208   {
00209     FT_UShort  SequenceIndex;           /* index into current
00210                                            glyph sequence               */
00211     FT_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
00212   };
00213 
00214   typedef struct TTO_SubstLookupRecord_  TTO_SubstLookupRecord;
00215 
00216 
00217   /* LookupType 5 */
00218 
00219   struct  TTO_SubRule_
00220   {
00221     FT_UShort               GlyphCount; /* total number of input glyphs */
00222     FT_UShort               SubstCount; /* number of SubstLookupRecord
00223                                            tables                       */
00224     FT_UShort*              Input;      /* array of input glyph IDs     */
00225     TTO_SubstLookupRecord*  SubstLookupRecord;
00226                                         /* array of SubstLookupRecord
00227                                            tables                       */
00228   };
00229 
00230   typedef struct TTO_SubRule_  TTO_SubRule;
00231 
00232 
00233   struct  TTO_SubRuleSet_
00234   {
00235     FT_UShort     SubRuleCount;         /* number of SubRule tables */
00236     TTO_SubRule*  SubRule;              /* array of SubRule tables  */
00237   };
00238 
00239   typedef struct TTO_SubRuleSet_  TTO_SubRuleSet;
00240 
00241 
00242   struct  TTO_ContextSubstFormat1_
00243   {
00244     TTO_Coverage     Coverage;          /* Coverage table              */
00245     FT_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */
00246     TTO_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */
00247   };
00248 
00249   typedef struct TTO_ContextSubstFormat1_  TTO_ContextSubstFormat1;
00250 
00251 
00252   struct  TTO_SubClassRule_
00253   {
00254     FT_UShort               GlyphCount; /* total number of context classes */
00255     FT_UShort               SubstCount; /* number of SubstLookupRecord
00256                                            tables                          */
00257     FT_UShort*              Class;      /* array of classes                */
00258     TTO_SubstLookupRecord*  SubstLookupRecord;
00259                                         /* array of SubstLookupRecord
00260                                            tables                          */
00261   };
00262 
00263   typedef struct TTO_SubClassRule_  TTO_SubClassRule;
00264 
00265 
00266   struct  TTO_SubClassSet_
00267   {
00268     FT_UShort          SubClassRuleCount;
00269                                         /* number of SubClassRule tables */
00270     TTO_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */
00271   };
00272 
00273   typedef struct TTO_SubClassSet_  TTO_SubClassSet;
00274 
00275 
00276   /* The `MaxContextLength' field is not defined in the TTO specification
00277      but simplifies the implementation of this format.  It holds the
00278      maximal context length used in the context rules.                    */
00279 
00280   struct  TTO_ContextSubstFormat2_
00281   {
00282     FT_UShort            MaxContextLength;
00283                                         /* maximal context length       */
00284     TTO_Coverage         Coverage;      /* Coverage table               */
00285     TTO_ClassDefinition  ClassDef;      /* ClassDef table               */
00286     FT_UShort            SubClassSetCount;
00287                                         /* number of SubClassSet tables */
00288     TTO_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */
00289   };
00290 
00291   typedef struct TTO_ContextSubstFormat2_  TTO_ContextSubstFormat2;
00292 
00293 
00294   struct  TTO_ContextSubstFormat3_
00295   {
00296     FT_UShort               GlyphCount; /* number of input glyphs        */
00297     FT_UShort               SubstCount; /* number of SubstLookupRecords  */
00298     TTO_Coverage*           Coverage;   /* array of Coverage tables      */
00299     TTO_SubstLookupRecord*  SubstLookupRecord;
00300                                         /* array of substitution lookups */
00301   };
00302 
00303   typedef struct TTO_ContextSubstFormat3_  TTO_ContextSubstFormat3;
00304 
00305 
00306   struct  TTO_ContextSubst_
00307   {
00308     FT_UShort  SubstFormat;             /* 1, 2, or 3 */
00309 
00310     union
00311     {
00312       TTO_ContextSubstFormat1  csf1;
00313       TTO_ContextSubstFormat2  csf2;
00314       TTO_ContextSubstFormat3  csf3;
00315     } csf;
00316   };
00317 
00318   typedef struct TTO_ContextSubst_  TTO_ContextSubst;
00319 
00320 
00321   /* LookupType 6 */
00322 
00323   struct  TTO_ChainSubRule_
00324   {
00325     FT_UShort               BacktrackGlyphCount;
00326                                         /* total number of backtrack glyphs */
00327     FT_UShort*              Backtrack;  /* array of backtrack glyph IDs     */
00328     FT_UShort               InputGlyphCount;
00329                                         /* total number of input glyphs     */
00330     FT_UShort*              Input;      /* array of input glyph IDs         */
00331     FT_UShort               LookaheadGlyphCount;
00332                                         /* total number of lookahead glyphs */
00333     FT_UShort*              Lookahead;  /* array of lookahead glyph IDs     */
00334     FT_UShort               SubstCount; /* number of SubstLookupRecords     */
00335     TTO_SubstLookupRecord*  SubstLookupRecord;
00336                                         /* array of SubstLookupRecords      */
00337   };
00338 
00339   typedef struct TTO_ChainSubRule_  TTO_ChainSubRule;
00340 
00341 
00342   struct  TTO_ChainSubRuleSet_
00343   {
00344     FT_UShort          ChainSubRuleCount;
00345                                         /* number of ChainSubRule tables */
00346     TTO_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */
00347   };
00348 
00349   typedef struct TTO_ChainSubRuleSet_  TTO_ChainSubRuleSet;
00350 
00351 
00352   struct  TTO_ChainContextSubstFormat1_
00353   {
00354     TTO_Coverage          Coverage;     /* Coverage table                   */
00355     FT_UShort             ChainSubRuleSetCount;
00356                                         /* number of ChainSubRuleSet tables */
00357     TTO_ChainSubRuleSet*  ChainSubRuleSet;
00358                                         /* array of ChainSubRuleSet tables  */
00359   };
00360 
00361   typedef struct TTO_ChainContextSubstFormat1_  TTO_ChainContextSubstFormat1;
00362 
00363 
00364   struct  TTO_ChainSubClassRule_
00365   {
00366     FT_UShort               BacktrackGlyphCount;
00367                                         /* total number of backtrack
00368                                            classes                         */
00369     FT_UShort*              Backtrack;  /* array of backtrack classes      */
00370     FT_UShort               InputGlyphCount;
00371                                         /* total number of context classes */
00372     FT_UShort*              Input;      /* array of context classes        */
00373     FT_UShort               LookaheadGlyphCount;
00374                                         /* total number of lookahead
00375                                            classes                         */
00376     FT_UShort*              Lookahead;  /* array of lookahead classes      */
00377     FT_UShort               SubstCount; /* number of SubstLookupRecords    */
00378     TTO_SubstLookupRecord*  SubstLookupRecord;
00379                                         /* array of substitution lookups   */
00380   };
00381 
00382   typedef struct TTO_ChainSubClassRule_  TTO_ChainSubClassRule;
00383 
00384 
00385   struct  TTO_ChainSubClassSet_
00386   {
00387     FT_UShort               ChainSubClassRuleCount;
00388                                         /* number of ChainSubClassRule
00389                                            tables                      */
00390     TTO_ChainSubClassRule*  ChainSubClassRule;
00391                                         /* array of ChainSubClassRule
00392                                            tables                      */
00393   };
00394 
00395   typedef struct TTO_ChainSubClassSet_  TTO_ChainSubClassSet;
00396 
00397 
00398   /* The `MaxXXXLength' fields are not defined in the TTO specification
00399      but simplifies the implementation of this format.  It holds the
00400      maximal context length used in the specific context rules.         */
00401 
00402   struct  TTO_ChainContextSubstFormat2_
00403   {
00404     TTO_Coverage           Coverage;    /* Coverage table             */
00405 
00406     FT_UShort              MaxBacktrackLength;
00407                                         /* maximal backtrack length   */
00408     TTO_ClassDefinition    BacktrackClassDef;
00409                                         /* BacktrackClassDef table    */
00410     FT_UShort              MaxInputLength;
00411                                         /* maximal input length       */
00412     TTO_ClassDefinition    InputClassDef;
00413                                         /* InputClassDef table        */
00414     FT_UShort              MaxLookaheadLength;
00415                                         /* maximal lookahead length   */
00416     TTO_ClassDefinition    LookaheadClassDef;
00417                                         /* LookaheadClassDef table    */
00418 
00419     FT_UShort              ChainSubClassSetCount;
00420                                         /* number of ChainSubClassSet
00421                                            tables                     */
00422     TTO_ChainSubClassSet*  ChainSubClassSet;
00423                                         /* array of ChainSubClassSet
00424                                            tables                     */
00425   };
00426 
00427   typedef struct TTO_ChainContextSubstFormat2_  TTO_ChainContextSubstFormat2;
00428 
00429 
00430   struct  TTO_ChainContextSubstFormat3_
00431   {
00432     FT_UShort               BacktrackGlyphCount;
00433                                         /* number of backtrack glyphs    */
00434     TTO_Coverage*           BacktrackCoverage;
00435                                         /* array of backtrack Coverage
00436                                            tables                        */
00437     FT_UShort               InputGlyphCount;
00438                                         /* number of input glyphs        */
00439     TTO_Coverage*           InputCoverage;
00440                                         /* array of input coverage
00441                                            tables                        */
00442     FT_UShort               LookaheadGlyphCount;
00443                                         /* number of lookahead glyphs    */
00444     TTO_Coverage*           LookaheadCoverage;
00445                                         /* array of lookahead coverage
00446                                            tables                        */
00447     FT_UShort               SubstCount; /* number of SubstLookupRecords  */
00448     TTO_SubstLookupRecord*  SubstLookupRecord;
00449                                         /* array of substitution lookups */
00450   };
00451 
00452   typedef struct TTO_ChainContextSubstFormat3_  TTO_ChainContextSubstFormat3;
00453 
00454 
00455   struct  TTO_ChainContextSubst_
00456   {
00457     FT_UShort  SubstFormat;             /* 1, 2, or 3 */
00458 
00459     union
00460     {
00461       TTO_ChainContextSubstFormat1  ccsf1;
00462       TTO_ChainContextSubstFormat2  ccsf2;
00463       TTO_ChainContextSubstFormat3  ccsf3;
00464     } ccsf;
00465   };
00466 
00467   typedef struct TTO_ChainContextSubst_  TTO_ChainContextSubst;
00468 
00469 
00470   union  TTO_GSUB_SubTable_
00471   {
00472     TTO_SingleSubst        single;
00473     TTO_MultipleSubst      multiple;
00474     TTO_AlternateSubst     alternate;
00475     TTO_LigatureSubst      ligature;
00476     TTO_ContextSubst       context;
00477     TTO_ChainContextSubst  chain;
00478   };
00479 
00480   typedef union TTO_GSUB_SubTable_  TTO_GSUB_SubTable;
00481 
00482 
00483   /* A simple string object.  It can both `send' and `receive' data.
00484      In case of sending, `length' and `pos' will be used.  In case of
00485      receiving, `pos' points to the first free slot, and `allocated'
00486      specifies the amount of allocated memory (and the `length' field
00487      will be ignored).  The routine TT_Add_String() will increase the
00488      amount of memory if necessary.  After end of receive, `length'
00489      should be set to the value of `pos', and `pos' will be set to zero.
00490 
00491      `properties' (which is treated as a bit field) gives the glyph's
00492      properties: If a certain bit is set for a glyph, the feature which
00493      has the same bit set in its property value is applied.
00494 
00495      `components' is an internal array which tracks components of
00496      ligatures.  We need this for MarkToLigature Attachment Positioning
00497      Subtables (in GPOS) together with `ligIDs' (which is used to mark
00498      ligatures and the skipped glyphs during a ligature lookup).
00499      `max_ligID' is increased after a successful ligature lookup.
00500 
00501      NEVER modify any elements of the structure!  You should rather copy
00502      its contents if necessary.
00503 
00504      TT_Add_String() will also handle allocation; you should use
00505      free() in case you want to destroy the arrays in the object. */
00506 
00507 
00508   /* finally, the GSUB API */
00509 
00510   /*  EXPORT_DEF
00511       TT_Error  TT_Init_GSUB_Extension( TT_Engine  engine ); */
00512 
00513   EXPORT_DEF
00514   FT_Error  TT_Load_GSUB_Table( FT_Face          face,
00515                                 TTO_GSUBHeader** gsub,
00516                                 TTO_GDEFHeader*  gdef );
00517 
00518   EXPORT_DEF
00519   FT_Error  TT_Done_GSUB_Table( TTO_GSUBHeader*  gsub );
00520 
00521   EXPORT_DEF
00522   FT_Error  TT_GSUB_Select_Script( TTO_GSUBHeader*  gsub,
00523                                    FT_ULong         script_tag,
00524                                    FT_UShort*       script_index );
00525   EXPORT_DEF
00526   FT_Error  TT_GSUB_Select_Language( TTO_GSUBHeader*  gsub,
00527                                      FT_ULong         language_tag,
00528                                      FT_UShort        script_index,
00529                                      FT_UShort*       language_index,
00530                                      FT_UShort*       req_feature_index );
00531   EXPORT_DEF
00532   FT_Error  TT_GSUB_Select_Feature( TTO_GSUBHeader*  gsub,
00533                                     FT_ULong         feature_tag,
00534                                     FT_UShort        script_index,
00535                                     FT_UShort        language_index,
00536                                     FT_UShort*       feature_index );
00537 
00538   EXPORT_DEF
00539   FT_Error  TT_GSUB_Query_Scripts( TTO_GSUBHeader*  gsub,
00540                                    FT_ULong**       script_tag_list );
00541   EXPORT_DEF
00542   FT_Error  TT_GSUB_Query_Languages( TTO_GSUBHeader*  gsub,
00543                                      FT_UShort        script_index,
00544                                      FT_ULong**       language_tag_list );
00545   EXPORT_DEF
00546   FT_Error  TT_GSUB_Query_Features( TTO_GSUBHeader*  gsub,
00547                                     FT_UShort        script_index,
00548                                     FT_UShort        language_index,
00549                                     FT_ULong**       feature_tag_list );
00550 
00551   EXPORT_DEF
00552   FT_Error  TT_GSUB_Add_Feature( TTO_GSUBHeader*  gsub,
00553                                  FT_UShort        feature_index,
00554                                  FT_UInt          property );
00555   EXPORT_DEF
00556   FT_Error  TT_GSUB_Clear_Features( TTO_GSUBHeader*  gsub );
00557 
00558   EXPORT_DEF
00559   FT_Error  TT_GSUB_Register_Alternate_Function( TTO_GSUBHeader*  gsub,
00560                                                  TTO_AltFunction  altfunc,
00561                                                  void*            data );
00562   
00563   EXPORT_DEF
00564   FT_Error  TT_GSUB_Apply_String( TTO_GSUBHeader*   gsub,
00565                                   OTL_Buffer        buffer );
00566 
00567 
00568 #ifdef __cplusplus
00569 }
00570 #endif
00571 
00572 #endif /* FTXGSUB_H */
00573 
00574 
00575 /* END */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'