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