Home | History | Annotate | Download | only in layout
      1 /*
      2  *
      3  * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
      4  *
      5  */
      6 
      7 #ifndef __MORPHTABLES_H
      8 #define __MORPHTABLES_H
      9 
     10 /**
     11  * \file
     12  * \internal
     13  */
     14 
     15 #include "LETypes.h"
     16 #include "LayoutTables.h"
     17 #include "LETableReference.h"
     18 
     19 U_NAMESPACE_BEGIN
     20 
     21 class LEGlyphStorage;
     22 
     23 typedef le_uint32 FeatureFlags;
     24 
     25 typedef le_int16 FeatureType;
     26 typedef le_int16 FeatureSetting;
     27 
     28 struct FeatureTableEntry
     29 {
     30     FeatureType     featureType;
     31     FeatureSetting  featureSetting;
     32     FeatureFlags    enableFlags;
     33     FeatureFlags    disableFlags;
     34 };
     35 
     36 struct ChainHeader
     37 {
     38     FeatureFlags        defaultFlags;
     39     le_uint32           chainLength;
     40     le_int16           nFeatureEntries;
     41     le_int16           nSubtables;
     42     FeatureTableEntry   featureTable[ANY_NUMBER];
     43 };
     44 LE_VAR_ARRAY(ChainHeader, featureTable)
     45 
     46 struct MorphTableHeader
     47 {
     48     le_int32    version;
     49     le_uint32   nChains;
     50     ChainHeader chains[ANY_NUMBER];
     51 
     52   void process(const LETableReference& base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const;
     53 };
     54 LE_VAR_ARRAY(MorphTableHeader, chains)
     55 
     56 typedef le_int16 SubtableCoverage;
     57 typedef le_uint32 SubtableCoverage2;
     58 
     59 enum SubtableCoverageFlags
     60 {
     61     scfVertical = 0x8000,
     62     scfReverse  = 0x4000,
     63     scfIgnoreVt = 0x2000,
     64     scfReserved = 0x1FF8,
     65     scfTypeMask = 0x0007
     66 };
     67 
     68 enum MorphSubtableType
     69 {
     70     mstIndicRearrangement               = 0,
     71     mstContextualGlyphSubstitution      = 1,
     72     mstLigatureSubstitution             = 2,
     73     mstReservedUnused                   = 3,
     74     mstNonContextualGlyphSubstitution   = 4,
     75     mstContextualGlyphInsertion         = 5
     76 };
     77 
     78 struct MorphSubtableHeader
     79 {
     80     le_int16           length;
     81     SubtableCoverage    coverage;
     82     FeatureFlags        subtableFeatures;
     83 
     84   void process(const LEReferenceTo<MorphSubtableHeader> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const;
     85 };
     86 
     87 enum SubtableCoverageFlags2
     88 {
     89     scfVertical2 = 0x80000000,
     90     scfReverse2  = 0x40000000,
     91     scfIgnoreVt2 = 0x20000000,
     92     scfReserved2 = 0x1FFFFF00,
     93     scfTypeMask2 = 0x000000FF
     94 };
     95 
     96 struct MorphSubtableHeader2
     97 {
     98     le_uint32           length;
     99     SubtableCoverage2    coverage;
    100     FeatureFlags        subtableFeatures;
    101 
    102     void process(const LEReferenceTo<MorphSubtableHeader2> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const;
    103 };
    104 
    105 struct ChainHeader2
    106 {
    107     FeatureFlags        defaultFlags;
    108     le_uint32           chainLength;
    109     le_uint32           nFeatureEntries;
    110     le_uint32           nSubtables;
    111     FeatureTableEntry   featureTable[ANY_NUMBER];
    112 };
    113 LE_VAR_ARRAY(ChainHeader2, featureTable)
    114 
    115 struct MorphTableHeader2
    116 {
    117     le_int32    version;
    118     le_uint32   nChains;
    119     ChainHeader2 chains[ANY_NUMBER];
    120 
    121     void process(const LEReferenceTo<MorphTableHeader2> &base, LEGlyphStorage &glyphStorage, le_int32 typoFlags, LEErrorCode &success) const;
    122 };
    123 LE_VAR_ARRAY(MorphTableHeader2, chains)
    124 
    125 /*
    126  * AAT Font Features
    127  * source: https://developer.apple.com/fonts/registry/
    128  * (plus addition from ATS/SFNTLayoutTypes.h)
    129  */
    130 
    131 enum {
    132 
    133    allTypographicFeaturesType = 0,
    134 
    135       allTypeFeaturesOnSelector            = 0,
    136       allTypeFeaturesOffSelector           = 1,
    137 
    138    ligaturesType = 1,
    139 
    140       requiredLigaturesOnSelector          = 0,
    141       requiredLigaturesOffSelector         = 1,
    142       commonLigaturesOnSelector            = 2,
    143       commonLigaturesOffSelector           = 3,
    144       rareLigaturesOnSelector              = 4,
    145       rareLigaturesOffSelector             = 5,
    146       logosOnSelector                      = 6,
    147       logosOffSelector                     = 7,
    148       rebusPicturesOnSelector              = 8,
    149       rebusPicturesOffSelector             = 9,
    150       diphthongLigaturesOnSelector         = 10,
    151       diphthongLigaturesOffSelector        = 11,
    152       squaredLigaturesOnSelector           = 12,
    153       squaredLigaturesOffSelector          = 13,
    154       abbrevSquaredLigaturesOnSelector     = 14,
    155       abbrevSquaredLigaturesOffSelector    = 15,
    156       symbolLigaturesOnSelector            = 16,
    157       symbolLigaturesOffSelector           = 17,
    158       contextualLigaturesOnSelector        = 18,
    159       contextualLigaturesOffSelector       = 19,
    160       historicalLigaturesOnSelector        = 20,
    161       historicalLigaturesOffSelector       = 21,
    162 
    163    cursiveConnectionType = 2,
    164 
    165       unconnectedSelector                  = 0,
    166       partiallyConnectedSelector           = 1,
    167       cursiveSelector                      = 2,
    168 
    169    letterCaseType = 3,
    170 
    171       upperAndLowerCaseSelector            = 0,
    172       allCapsSelector                      = 1,
    173       allLowerCaseSelector                 = 2,
    174       smallCapsSelector                    = 3,
    175       initialCapsSelector                  = 4,
    176       initialCapsAndSmallCapsSelector      = 5,
    177 
    178    verticalSubstitutionType = 4,
    179 
    180       substituteVerticalFormsOnSelector    = 0,
    181       substituteVerticalFormsOffSelector   = 1,
    182 
    183    linguisticRearrangementType = 5,
    184 
    185       linguisticRearrangementOnSelector    = 0,
    186       linguisticRearrangementOffSelector   = 1,
    187 
    188    numberSpacingType = 6,
    189 
    190       monospacedNumbersSelector            = 0,
    191       proportionalNumbersSelector          = 1,
    192 
    193    /*
    194    appleReserved1Type = 7,
    195    */
    196 
    197    smartSwashType = 8,
    198 
    199       wordInitialSwashesOnSelector         = 0,
    200       wordInitialSwashesOffSelector        = 1,
    201       wordFinalSwashesOnSelector           = 2,
    202       wordFinalSwashesOffSelector          = 3,
    203       lineInitialSwashesOnSelector         = 4,
    204       lineInitialSwashesOffSelector        = 5,
    205       lineFinalSwashesOnSelector           = 6,
    206       lineFinalSwashesOffSelector          = 7,
    207       nonFinalSwashesOnSelector            = 8,
    208       nonFinalSwashesOffSelector           = 9,
    209 
    210    diacriticsType = 9,
    211 
    212       showDiacriticsSelector               = 0,
    213       hideDiacriticsSelector               = 1,
    214       decomposeDiacriticsSelector          = 2,
    215 
    216    verticalPositionType = 10,
    217 
    218       normalPositionSelector               = 0,
    219       superiorsSelector                    = 1,
    220       inferiorsSelector                    = 2,
    221       ordinalsSelector                     = 3,
    222 
    223    fractionsType = 11,
    224 
    225       noFractionsSelector                  = 0,
    226       verticalFractionsSelector            = 1,
    227       diagonalFractionsSelector            = 2,
    228 
    229    /*
    230    appleReserved2Type = 12,
    231    */
    232 
    233    overlappingCharactersType = 13,
    234 
    235       preventOverlapOnSelector             = 0,
    236       preventOverlapOffSelector            = 1,
    237 
    238    typographicExtrasType = 14,
    239 
    240       hyphensToEmDashOnSelector            = 0,
    241       hyphensToEmDashOffSelector           = 1,
    242       hyphenToEnDashOnSelector             = 2,
    243       hyphenToEnDashOffSelector            = 3,
    244       unslashedZeroOnSelector              = 4,
    245       slashedZeroOffSelector               = 4,
    246       unslashedZeroOffSelector             = 5,
    247       slashedZeroOnSelector                = 5,
    248       formInterrobangOnSelector            = 6,
    249       formInterrobangOffSelector           = 7,
    250       smartQuotesOnSelector                = 8,
    251       smartQuotesOffSelector               = 9,
    252       periodsToEllipsisOnSelector          = 10,
    253       periodsToEllipsisOffSelector         = 11,
    254 
    255    mathematicalExtrasType = 15,
    256 
    257       hyphenToMinusOnSelector              = 0,
    258       hyphenToMinusOffSelector             = 1,
    259       asteriskToMultiplyOnSelector         = 2,
    260       asteriskToMultiplyOffSelector        = 3,
    261       slashToDivideOnSelector              = 4,
    262       slashToDivideOffSelector             = 5,
    263       inequalityLigaturesOnSelector        = 6,
    264       inequalityLigaturesOffSelector       = 7,
    265       exponentsOnSelector                  = 8,
    266       exponentsOffSelector                 = 9,
    267 
    268    ornamentSetsType = 16,
    269 
    270       noOrnamentsSelector                  = 0,
    271       dingbatsSelector                     = 1,
    272       piCharactersSelector                 = 2,
    273       fleuronsSelector                     = 3,
    274       decorativeBordersSelector            = 4,
    275       internationalSymbolsSelector         = 5,
    276       mathSymbolsSelector                  = 6,
    277 
    278    characterAlternativesType = 17,
    279 
    280       noAlternatesSelector                 = 0,
    281 
    282    designComplexityType = 18,
    283 
    284       designLevel1Selector                 = 0,
    285       designLevel2Selector                 = 1,
    286       designLevel3Selector                 = 2,
    287       designLevel4Selector                 = 3,
    288       designLevel5Selector                 = 4,
    289       designLevel6Selector                 = 5,
    290       designLevel7Selector                 = 6,
    291 
    292    styleOptionsType = 19,
    293 
    294       noStyleOptionsSelector               = 0,
    295       displayTextSelector                  = 1,
    296       engravedTextSelector                 = 2,
    297       illuminatedCapsSelector              = 3,
    298       titlingCapsSelector                  = 4,
    299       tallCapsSelector                     = 5,
    300 
    301    characterShapeType = 20,
    302 
    303       traditionalCharactersSelector        = 0,
    304       simplifiedCharactersSelector         = 1,
    305       jis1978CharactersSelector            = 2,
    306       jis1983CharactersSelector            = 3,
    307       jis1990CharactersSelector            = 4,
    308       traditionalAltOneSelector            = 5,
    309       traditionalAltTwoSelector            = 6,
    310       traditionalAltThreeSelector          = 7,
    311       traditionalAltFourSelector           = 8,
    312       traditionalAltFiveSelector           = 9,
    313       expertCharactersSelector             = 10,
    314 
    315    numberCaseType = 21,
    316 
    317       lowerCaseNumbersSelector             = 0,
    318       upperCaseNumbersSelector             = 1,
    319 
    320    textSpacingType = 22,
    321 
    322       proportionalTextSelector             = 0,
    323       monospacedTextSelector               = 1,
    324       halfWidthTextSelector                = 2,
    325       normallySpacedTextSelector           = 3,
    326 
    327    transliterationType = 23,
    328 
    329       noTransliterationSelector            = 0,
    330       hanjaToHangulSelector                = 1,
    331       hiraganaToKatakanaSelector           = 2,
    332       katakanaToHiraganaSelector           = 3,
    333       kanaToRomanizationSelector           = 4,
    334       romanizationToHiraganaSelector       = 5,
    335       romanizationToKatakanaSelector       = 6,
    336       hanjaToHangulAltOneSelector          = 7,
    337       hanjaToHangulAltTwoSelector          = 8,
    338       hanjaToHangulAltThreeSelector        = 9,
    339 
    340    annotationType = 24,
    341 
    342       noAnnotationSelector                 = 0,
    343       boxAnnotationSelector                = 1,
    344       roundedBoxAnnotationSelector         = 2,
    345       circleAnnotationSelector             = 3,
    346       invertedCircleAnnotationSelector     = 4,
    347       parenthesisAnnotationSelector        = 5,
    348       periodAnnotationSelector             = 6,
    349       romanNumeralAnnotationSelector       = 7,
    350       diamondAnnotationSelector            = 8,
    351 
    352    kanaSpacingType = 25,
    353 
    354       fullWidthKanaSelector                = 0,
    355       proportionalKanaSelector             = 1,
    356 
    357    ideographicSpacingType = 26,
    358 
    359       fullWidthIdeographsSelector          = 0,
    360       proportionalIdeographsSelector       = 1,
    361 
    362    cjkRomanSpacingType = 103,
    363 
    364       halfWidthCJKRomanSelector            = 0,
    365       proportionalCJKRomanSelector         = 1,
    366       defaultCJKRomanSelector              = 2,
    367       fullWidthCJKRomanSelector            = 3,
    368 
    369    rubyKanaType = 28,
    370 
    371       rubyKanaOnSelector                = 2,
    372       rubyKanaOffSelector               = 3,
    373 
    374 /* The following types are provided for compatibility; note that
    375    their use is deprecated. */
    376 
    377    adobeCharacterSpacingType = 100,        /* prefer 22 */
    378    adobeKanaSpacingType = 101,             /* prefer 25 */
    379    adobeKanjiSpacingType = 102,            /* prefer 26 */
    380    adobeSquareLigatures = 104,             /* prefer 1 */
    381 
    382    lastFeatureType = -1
    383 };
    384 
    385 U_NAMESPACE_END
    386 #endif
    387 
    388