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