Home | History | Annotate | Download | only in hb-icu-le
      1 /***************************************************************************
      2 *
      3 *   Copyright (C) 1998-2011, International Business Machines
      4 *   Corporation and others.  All Rights Reserved.
      5 *
      6 ************************************************************************/
      7 
      8 #ifndef __SFNT_H
      9 #define __SFNT_H
     10 
     11 #include "layout/LETypes.h"
     12 #include "letest.h"
     13 
     14 HB_BEGIN_VISIBILITY
     15 
     16 U_NAMESPACE_USE
     17 
     18 #ifndef ANY_NUMBER
     19 #define ANY_NUMBER 1
     20 #endif
     21 
     22 struct DirectoryEntry
     23 {
     24     le_uint32   tag;
     25     le_uint32   checksum;
     26     le_uint32   offset;
     27     le_uint32   length;
     28 };
     29 
     30 #ifndef __cplusplus
     31 typedef struct DirectoryEntry DirectoryEntry;
     32 #endif
     33 
     34 struct SFNTDirectory
     35 {
     36     le_uint32       scalerType;
     37     le_uint16       numTables;
     38     le_uint16       searchRange;
     39     le_uint16       entrySelector;
     40     le_uint16       rangeShift;
     41     DirectoryEntry  tableDirectory[ANY_NUMBER];
     42 };
     43 
     44 #ifndef __cplusplus
     45 typedef struct SFNTDirectory SFNTDirectory;
     46 #endif
     47 
     48 
     49 struct CMAPEncodingSubtableHeader
     50 {
     51     le_uint16   platformID;
     52     le_uint16   platformSpecificID;
     53     le_uint32   encodingOffset;
     54 };
     55 
     56 #ifndef __cplusplus
     57 typedef struct CMAPEncodingSubtableHeader CMAPEncodingSubtableHeader;
     58 #endif
     59 
     60 struct CMAPTable
     61 {
     62     le_uint16   version;
     63     le_uint16   numberSubtables;
     64     CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
     65 };
     66 
     67 #ifndef __cplusplus
     68 typedef struct CMAPTable CMAPTable;
     69 #endif
     70 
     71 struct CMAPEncodingSubtable
     72 {
     73     le_uint16   format;
     74     le_uint16   length;
     75     le_uint16   language;
     76 };
     77 
     78 #ifndef __cplusplus
     79 typedef struct CMAPEncodingSubtable CMAPEncodingSubtable;
     80 #endif
     81 
     82 #ifdef __cplusplus
     83 struct CMAPFormat0Encoding : CMAPEncodingSubtable
     84 {
     85     le_uint8    glyphIndexArray[256];
     86 };
     87 #else
     88 struct CMAPFormat0Encoding
     89 {
     90 	CMAPEncodingSubtable base;
     91 
     92 	le_uint8 glyphIndexArray[256];
     93 };
     94 
     95 typedef struct CMAPFormat0Encoding CMAPFormat0Encoding;
     96 #endif
     97 
     98 struct CMAPFormat2Subheader
     99 {
    100     le_uint16   firstCode;
    101     le_uint16   entryCount;
    102     le_int16    idDelta;
    103     le_uint16   idRangeOffset;
    104 };
    105 
    106 #ifndef __cplusplus
    107 typedef struct CMAPFormat2Subheader CMAPFormat2Subheader;
    108 #endif
    109 
    110 #ifdef __cplusplus
    111 struct CMAPFormat2Encoding : CMAPEncodingSubtable
    112 {
    113     le_uint16  subHeadKeys[256];
    114     CMAPFormat2Subheader subheaders[ANY_NUMBER];
    115 };
    116 #else
    117 struct CMAPFormat2Encoding
    118 {
    119 	CMAPEncodingSubtable base;
    120 
    121     le_uint16  subHeadKeys[256];
    122     CMAPFormat2Subheader subheaders[ANY_NUMBER];
    123 };
    124 
    125 typedef struct CMAPFormat2Encoding CMAPFormat2Encoding;
    126 #endif
    127 
    128 #ifdef __cplusplus
    129 struct CMAPFormat4Encoding : CMAPEncodingSubtable
    130 {
    131     le_uint16   segCountX2;
    132     le_uint16   searchRange;
    133     le_uint16   entrySelector;
    134     le_uint16   rangeShift;
    135     le_uint16   endCodes[ANY_NUMBER];
    136 /*
    137     le_uint16   reservedPad;
    138     le_uint16   startCodes[ANY_NUMBER];
    139     le_uint16   idDelta[ANY_NUMBER];
    140     le_uint16   idRangeOffset[ANY_NUMBER];
    141     le_uint16   glyphIndexArray[ANY_NUMBER];
    142 */
    143 };
    144 #else
    145 struct CMAPFormat4Encoding
    146 {
    147 	CMAPEncodingSubtable base;
    148 
    149     le_uint16   segCountX2;
    150     le_uint16   searchRange;
    151     le_uint16   entrySelector;
    152     le_uint16   rangeShift;
    153     le_uint16   endCodes[ANY_NUMBER];
    154 /*
    155 //  le_uint16   reservedPad;
    156 //  le_uint16   startCodes[ANY_NUMBER];
    157 //  le_uint16   idDelta[ANY_NUMBER];
    158 //  le_uint16   idRangeOffset[ANY_NUMBER];
    159 //  le_uint16   glyphIndexArray[ANY_NUMBER];
    160 */
    161 };
    162 
    163 typedef struct CMAPFormat4Encoding CMAPFormat4Encoding;
    164 #endif
    165 
    166 #ifdef __cplusplus
    167 struct CMAPFormat6Encoding : CMAPEncodingSubtable
    168 {
    169     le_uint16   firstCode;
    170     le_uint16   entryCount;
    171     le_uint16   glyphIndexArray[ANY_NUMBER];
    172 };
    173 #else
    174 struct CMAPFormat6Encoding
    175 {
    176 	CMAPEncodingSubtable base;
    177 
    178     le_uint16   firstCode;
    179     le_uint16   entryCount;
    180     le_uint16   glyphIndexArray[ANY_NUMBER];
    181 };
    182 
    183 typedef struct CMAPFormat6Encoding CMAPFormat6Encoding;
    184 #endif
    185 
    186 struct CMAPEncodingSubtable32
    187 {
    188     le_uint32   format;
    189     le_uint32   length;
    190     le_uint32   language;
    191 };
    192 
    193 #ifndef __cplusplus
    194 typedef struct CMAPEncodingSubtable32 CMAPEncodingSubtable32;
    195 #endif
    196 
    197 struct CMAPGroup
    198 {
    199     le_uint32   startCharCode;
    200     le_uint32   endCharCode;
    201     le_uint32   startGlyphCode;
    202 };
    203 
    204 #ifndef __cplusplus
    205 typedef struct CMAPGroup CMAPGroup;
    206 #endif
    207 
    208 #ifdef __cplusplus
    209 struct CMAPFormat8Encoding : CMAPEncodingSubtable32
    210 {
    211     le_uint32   is32[65536/32];
    212     le_uint32   nGroups;
    213     CMAPGroup   groups[ANY_NUMBER];
    214 };
    215 #else
    216 struct CMAPFormat8Encoding
    217 {
    218 	CMAPEncodingSubtable32 base;
    219 
    220     le_uint32   is32[65536/32];
    221     le_uint32   nGroups;
    222     CMAPGroup   groups[ANY_NUMBER];
    223 };
    224 
    225 typedef struct CMAPFormat8Encoding CMAPFormat8Encoding;
    226 #endif
    227 
    228 #ifdef __cplusplus
    229 struct CMAPFormat10Encoding : CMAPEncodingSubtable32
    230 {
    231     le_uint32   startCharCode;
    232     le_uint32   numCharCodes;
    233     le_uint16   glyphs[ANY_NUMBER];
    234 };
    235 #else
    236 struct CMAPFormat10Encoding
    237 {
    238 	CMAPEncodingSubtable32 base;
    239 
    240     le_uint32   startCharCode;
    241     le_uint32   numCharCodes;
    242     le_uint16   glyphs[ANY_NUMBER];
    243 };
    244 
    245 typedef struct CMAPFormat10Encoding CMAPFormat10Encoding;
    246 #endif
    247 
    248 #ifdef __cplusplus
    249 struct CMAPFormat12Encoding : CMAPEncodingSubtable32
    250 {
    251     le_uint32   nGroups;
    252     CMAPGroup   groups[ANY_NUMBER];
    253 };
    254 #else
    255 struct CMAPFormat12Encoding
    256 {
    257 	CMAPEncodingSubtable32 base;
    258 
    259     le_uint32   nGroups;
    260     CMAPGroup   groups[ANY_NUMBER];
    261 };
    262 
    263 typedef struct CMAPFormat12Encoding CMAPFormat12Encoding;
    264 #endif
    265 
    266 typedef le_int32 fixed;
    267 
    268 struct BigDate
    269 {
    270     le_uint32   bc;
    271     le_uint32   ad;
    272 };
    273 
    274 #ifndef __cplusplus
    275 typedef struct BigDate BigDate;
    276 #endif
    277 
    278 struct HEADTable
    279 {
    280     fixed       version;
    281     fixed       fontRevision;
    282     le_uint32   checksumAdjustment;
    283     le_uint32   magicNumber;
    284     le_uint16   flags;
    285     le_uint16   unitsPerEm;
    286     BigDate     created;
    287     BigDate     modified;
    288     le_int16    xMin;
    289     le_int16    yMin;
    290     le_int16    xMax;
    291     le_int16    yMax;
    292     le_int16    lowestRecPPEM;
    293     le_int16    fontDirectionHint;
    294     le_int16    indexToLocFormat;
    295     le_int16    glyphDataFormat;
    296 };
    297 
    298 #ifndef __cplusplus
    299 typedef struct HEADTable HEADTable;
    300 #endif
    301 
    302 struct MAXPTable
    303 {
    304     fixed       version;
    305     le_uint16   numGlyphs;
    306     le_uint16   maxPoints;
    307     le_uint16   maxContours;
    308     le_uint16   maxComponentPoints;
    309     le_uint16   maxComponentContours;
    310     le_uint16   maxZones;
    311     le_uint16   maxTwilightPoints;
    312     le_uint16   maxStorage;
    313     le_uint16   maxFunctionDefs;
    314     le_uint16   maxInstructionDefs;
    315     le_uint16   maxStackElements;
    316     le_uint16   maxSizeOfInstructions;
    317     le_uint16   maxComponentElements;
    318     le_uint16   maxComponentDepth;
    319 };
    320 
    321 #ifndef __cplusplus
    322 typedef struct MAXPTable MAXPTable;
    323 #endif
    324 
    325 struct HHEATable
    326 {
    327     fixed       version;
    328     le_int16    ascent;
    329     le_int16    descent;
    330     le_int16    lineGap;
    331     le_uint16   advanceWidthMax;
    332     le_int16    minLeftSideBearing;
    333     le_int16    minRightSideBearing;
    334     le_int16    xMaxExtent;
    335     le_int16    caretSlopeRise;
    336     le_int16    caretSlopeRun;
    337     le_int16    caretOffset;
    338     le_int16    reserved1;
    339     le_int16    reserved2;
    340     le_int16    reserved3;
    341     le_int16    reserved4;
    342     le_int16    metricDataFormat;
    343     le_uint16   numOfLongHorMetrics;
    344 };
    345 
    346 #ifndef __cplusplus
    347 typedef struct HHEATable HHEATable;
    348 #endif
    349 
    350 struct LongHorMetric
    351 {
    352     le_uint16   advanceWidth;
    353     le_int16    leftSideBearing;
    354 };
    355 
    356 #ifndef __cplusplus
    357 typedef struct LongHorMetric LongHorMetric;
    358 #endif
    359 
    360 struct HMTXTable
    361 {
    362     LongHorMetric hMetrics[ANY_NUMBER];       /* ANY_NUMBER = numOfLongHorMetrics from hhea table */
    363 /* le_int16        leftSideBearing[ANY_NUMBER];  ANY_NUMBER = numGlyphs - numOfLongHorMetrics     */
    364 };
    365 
    366 #ifndef __cplusplus
    367 typedef struct HMTXTable HMTXTable;
    368 #endif
    369 
    370 enum PlatformID
    371 {
    372     PLATFORM_UNICODE = 0,
    373     PLATFORM_MACINTOSH = 1,
    374     PLATFORM_ISO       = 2,
    375     PLATFORM_MICROSOFT = 3,
    376     PLATFORM_CUSTOM    = 4
    377 };
    378 
    379 enum MacintoshEncodingID
    380 {
    381     MACINTOSH_ROMAN = 0
    382 };
    383 
    384 enum MacintoshLanguageID
    385 {
    386     MACINTOSH_ENGLISH = 0
    387 };
    388 
    389 enum MicrosoftEncodingID
    390 {
    391     MICROSOFT_UNICODE_BMP  =  1,
    392     MICROSOFT_UNICODE_FULL = 10
    393 };
    394 
    395 enum MicrosoftLanguageID
    396 {
    397     MICROSOFT_ENGLISH = 0x409
    398 };
    399 
    400 enum NameID
    401 {
    402     NAME_COPYRIGHT_NOTICE     = 0,
    403     NAME_FONT_FAMILY          = 1,
    404     NAME_FONT_SUB_FAMILY      = 2,
    405     NAME_UNIQUE_FONT_ID       = 3,
    406     NAME_FULL_FONT_NAME       = 4,
    407     NAME_VERSION_STRING       = 5,
    408     NAME_POSTSCRIPT_NAME      = 6,
    409     NAME_TRADEMARK            = 7,
    410     NAME_MANUFACTURER         = 8,
    411     NAME_DESIGNER             = 9,
    412     NAME_DESCRIPTION          = 10,
    413     NAME_VENDOR_URL           = 11,
    414     NAME_DESIGNER_URL         = 12,
    415     NAME_LICENSE_DESCRIPTION  = 13,
    416     NAME_LICENSE_URL          = 14,
    417     NAME_RESERVED             = 15,
    418     NAME_PREFERRED_FAMILY     = 16,
    419     NAME_PREFERRED_SUB_FAMILY = 17,
    420     NAME_COMPATIBLE_FULL      = 18,
    421     NAME_SAMPLE_TEXT          = 19,
    422     NAME_POSTSCRIPT_CID       = 20
    423 };
    424 
    425 struct NameRecord
    426 {
    427     le_uint16 platformID;
    428     le_uint16 encodingID;
    429     le_uint16 languageID;
    430     le_uint16 nameID;
    431     le_uint16 length;
    432     le_uint16 offset;
    433 };
    434 
    435 #ifndef __cplusplus
    436 typedef struct NameRecord NameRecord;
    437 #endif
    438 
    439 struct NAMETable
    440 {
    441     le_uint16 version;
    442     le_uint16 count;
    443     le_uint16 stringOffset;
    444     NameRecord nameRecords[ANY_NUMBER];
    445 };
    446 
    447 #ifndef __cplusplus
    448 typedef struct NAMETable NAMETable;
    449 #endif
    450 
    451 HB_END_VISIBILITY
    452 
    453 #endif
    454