SFNTTypes.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:16k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       SFNTTypes.h
  3.  
  4.      Contains:   Font file structures.
  5.  
  6.      Version:    Technology: Quickdraw GX 1.1
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1994-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __SFNTTYPES__
  18. #define __SFNTTYPES__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if PRAGMA_IMPORT
  29. #pragma import on
  30. #endif
  31. #if PRAGMA_STRUCT_ALIGN
  32.     #pragma options align=mac68k
  33. #elif PRAGMA_STRUCT_PACKPUSH
  34.     #pragma pack(push, 2)
  35. #elif PRAGMA_STRUCT_PACK
  36.     #pragma pack(2)
  37. #endif
  38. struct sfntDirectoryEntry {
  39.     FourCharCode                    tableTag;
  40.     UInt32                          checkSum;
  41.     UInt32                          offset;
  42.     UInt32                          length;
  43. };
  44. typedef struct sfntDirectoryEntry       sfntDirectoryEntry;
  45. /* The search fields limits numOffsets to 4096. */
  46. struct sfntDirectory {
  47.     FourCharCode                    format;
  48.     UInt16                          numOffsets;                 /* number of tables */
  49.     UInt16                          searchRange;                /* (max2 <= numOffsets)*16 */
  50.     UInt16                          entrySelector;              /* log2(max2 <= numOffsets) */
  51.     UInt16                          rangeShift;                 /* numOffsets*16-searchRange*/
  52.     sfntDirectoryEntry              table[1];                   /* table[numOffsets] */
  53. };
  54. typedef struct sfntDirectory            sfntDirectory;
  55. enum {
  56.     sizeof_sfntDirectory        = 12
  57. };
  58. /* Cmap - character id to glyph id mapping */
  59. enum {
  60.     cmapFontTableTag            = FOUR_CHAR_CODE('cmap')
  61. };
  62. enum {
  63.     kFontUnicodePlatform        = 0,
  64.     kFontMacintoshPlatform      = 1,
  65.     kFontReservedPlatform       = 2,
  66.     kFontMicrosoftPlatform      = 3,
  67.     kFontCustomPlatform         = 4
  68. };
  69. enum {
  70.     kFontUnicodeDefaultSemantics = 0,
  71.     kFontUnicodeV1_1Semantics   = 1,
  72.     kFontISO10646_1993Semantics = 2
  73. };
  74. enum {
  75.     kFontRomanScript            = 0,
  76.     kFontJapaneseScript         = 1,
  77.     kFontTraditionalChineseScript = 2,
  78.     kFontChineseScript          = kFontTraditionalChineseScript,
  79.     kFontKoreanScript           = 3,
  80.     kFontArabicScript           = 4,
  81.     kFontHebrewScript           = 5,
  82.     kFontGreekScript            = 6,
  83.     kFontCyrillicScript         = 7,
  84.     kFontRussian                = kFontCyrillicScript,
  85.     kFontRSymbolScript          = 8,
  86.     kFontDevanagariScript       = 9,
  87.     kFontGurmukhiScript         = 10,
  88.     kFontGujaratiScript         = 11,
  89.     kFontOriyaScript            = 12,
  90.     kFontBengaliScript          = 13,
  91.     kFontTamilScript            = 14,
  92.     kFontTeluguScript           = 15,
  93.     kFontKannadaScript          = 16,
  94.     kFontMalayalamScript        = 17,
  95.     kFontSinhaleseScript        = 18,
  96.     kFontBurmeseScript          = 19,
  97.     kFontKhmerScript            = 20,
  98.     kFontThaiScript             = 21,
  99.     kFontLaotianScript          = 22,
  100.     kFontGeorgianScript         = 23,
  101.     kFontArmenianScript         = 24,
  102.     kFontSimpleChineseScript    = 25,
  103.     kFontTibetanScript          = 26,
  104.     kFontMongolianScript        = 27,
  105.     kFontGeezScript             = 28,
  106.     kFontEthiopicScript         = kFontGeezScript,
  107.     kFontAmharicScript          = kFontGeezScript,
  108.     kFontSlavicScript           = 29,
  109.     kFontEastEuropeanRomanScript = kFontSlavicScript,
  110.     kFontVietnameseScript       = 30,
  111.     kFontExtendedArabicScript   = 31,
  112.     kFontSindhiScript           = kFontExtendedArabicScript,
  113.     kFontUninterpretedScript    = 32
  114. };
  115. enum {
  116.     kFontMicrosoftSymbolScript  = 0,
  117.     kFontMicrosoftStandardScript = 1
  118. };
  119. enum {
  120.     kFontCustom8BitScript       = 0,
  121.     kFontCustom816BitScript     = 1,
  122.     kFontCustom16BitScript      = 2
  123. };
  124. /* Language codes are zero based everywhere but within a 'cmap' table */
  125. enum {
  126.     kFontEnglishLanguage        = 0,
  127.     kFontFrenchLanguage         = 1,
  128.     kFontGermanLanguage         = 2,
  129.     kFontItalianLanguage        = 3,
  130.     kFontDutchLanguage          = 4,
  131.     kFontSwedishLanguage        = 5,
  132.     kFontSpanishLanguage        = 6,
  133.     kFontDanishLanguage         = 7,
  134.     kFontPortugueseLanguage     = 8,
  135.     kFontNorwegianLanguage      = 9,
  136.     kFontHebrewLanguage         = 10,
  137.     kFontJapaneseLanguage       = 11,
  138.     kFontArabicLanguage         = 12,
  139.     kFontFinnishLanguage        = 13,
  140.     kFontGreekLanguage          = 14,
  141.     kFontIcelandicLanguage      = 15,
  142.     kFontMalteseLanguage        = 16,
  143.     kFontTurkishLanguage        = 17,
  144.     kFontCroatianLanguage       = 18,
  145.     kFontTradChineseLanguage    = 19,
  146.     kFontUrduLanguage           = 20,
  147.     kFontHindiLanguage          = 21,
  148.     kFontThaiLanguage           = 22,
  149.     kFontKoreanLanguage         = 23,
  150.     kFontLithuanianLanguage     = 24,
  151.     kFontPolishLanguage         = 25,
  152.     kFontHungarianLanguage      = 26,
  153.     kFontEstonianLanguage       = 27,
  154.     kFontLettishLanguage        = 28,
  155.     kFontLatvianLanguage        = kFontLettishLanguage,
  156.     kFontSaamiskLanguage        = 29,
  157.     kFontLappishLanguage        = kFontSaamiskLanguage,
  158.     kFontFaeroeseLanguage       = 30,
  159.     kFontFarsiLanguage          = 31,
  160.     kFontPersianLanguage        = kFontFarsiLanguage,
  161.     kFontRussianLanguage        = 32,
  162.     kFontSimpChineseLanguage    = 33,
  163.     kFontFlemishLanguage        = 34,
  164.     kFontIrishLanguage          = 35,
  165.     kFontAlbanianLanguage       = 36,
  166.     kFontRomanianLanguage       = 37,
  167.     kFontCzechLanguage          = 38,
  168.     kFontSlovakLanguage         = 39,
  169.     kFontSlovenianLanguage      = 40,
  170.     kFontYiddishLanguage        = 41,
  171.     kFontSerbianLanguage        = 42,
  172.     kFontMacedonianLanguage     = 43,
  173.     kFontBulgarianLanguage      = 44,
  174.     kFontUkrainianLanguage      = 45,
  175.     kFontByelorussianLanguage   = 46,
  176.     kFontUzbekLanguage          = 47,
  177.     kFontKazakhLanguage         = 48,
  178.     kFontAzerbaijaniLanguage    = 49,
  179.     kFontAzerbaijanArLanguage   = 50,
  180.     kFontArmenianLanguage       = 51,
  181.     kFontGeorgianLanguage       = 52,
  182.     kFontMoldavianLanguage      = 53,
  183.     kFontKirghizLanguage        = 54,
  184.     kFontTajikiLanguage         = 55,
  185.     kFontTurkmenLanguage        = 56,
  186.     kFontMongolianLanguage      = 57,
  187.     kFontMongolianCyrLanguage   = 58,
  188.     kFontPashtoLanguage         = 59,
  189.     kFontKurdishLanguage        = 60,
  190.     kFontKashmiriLanguage       = 61,
  191.     kFontSindhiLanguage         = 62,
  192.     kFontTibetanLanguage        = 63,
  193.     kFontNepaliLanguage         = 64,
  194.     kFontSanskritLanguage       = 65,
  195.     kFontMarathiLanguage        = 66,
  196.     kFontBengaliLanguage        = 67,
  197.     kFontAssameseLanguage       = 68,
  198.     kFontGujaratiLanguage       = 69,
  199.     kFontPunjabiLanguage        = 70,
  200.     kFontOriyaLanguage          = 71,
  201.     kFontMalayalamLanguage      = 72,
  202.     kFontKannadaLanguage        = 73,
  203.     kFontTamilLanguage          = 74,
  204.     kFontTeluguLanguage         = 75,
  205.     kFontSinhaleseLanguage      = 76,
  206.     kFontBurmeseLanguage        = 77,
  207.     kFontKhmerLanguage          = 78,
  208.     kFontLaoLanguage            = 79,
  209.     kFontVietnameseLanguage     = 80,
  210.     kFontIndonesianLanguage     = 81,
  211.     kFontTagalogLanguage        = 82,
  212.     kFontMalayRomanLanguage     = 83,
  213.     kFontMalayArabicLanguage    = 84,
  214.     kFontAmharicLanguage        = 85,
  215.     kFontTigrinyaLanguage       = 86,
  216.     kFontGallaLanguage          = 87,
  217.     kFontOromoLanguage          = kFontGallaLanguage,
  218.     kFontSomaliLanguage         = 88,
  219.     kFontSwahiliLanguage        = 89,
  220.     kFontRuandaLanguage         = 90,
  221.     kFontRundiLanguage          = 91,
  222.     kFontChewaLanguage          = 92,
  223.     kFontMalagasyLanguage       = 93,
  224.     kFontEsperantoLanguage      = 94,
  225.     kFontWelshLanguage          = 128,
  226.     kFontBasqueLanguage         = 129,
  227.     kFontCatalanLanguage        = 130,
  228.     kFontLatinLanguage          = 131,
  229.     kFontQuechuaLanguage        = 132,
  230.     kFontGuaraniLanguage        = 133,
  231.     kFontAymaraLanguage         = 134,
  232.     kFontTatarLanguage          = 135,
  233.     kFontUighurLanguage         = 136,
  234.     kFontDzongkhaLanguage       = 137,
  235.     kFontJavaneseRomLanguage    = 138,
  236.     kFontSundaneseRomLanguage   = 139
  237. };
  238. /* The following are special "don't care" values to be used in interfaces */
  239. enum {
  240.     kFontNoPlatform             = -1,
  241.     kFontNoScript               = -1,
  242.     kFontNoLanguage             = -1
  243. };
  244. struct sfntCMapSubHeader {
  245.     UInt16                          format;
  246.     UInt16                          length;
  247.     UInt16                          languageID;                 /* base-1 */
  248. };
  249. typedef struct sfntCMapSubHeader        sfntCMapSubHeader;
  250. enum {
  251.     sizeof_sfntCMapSubHeader    = 6
  252. };
  253. struct sfntCMapEncoding {
  254.     UInt16                          platformID;                 /* base-0 */
  255.     UInt16                          scriptID;                   /* base-0 */
  256.     UInt32                          offset;
  257. };
  258. typedef struct sfntCMapEncoding         sfntCMapEncoding;
  259. enum {
  260.     sizeof_sfntCMapEncoding     = 8
  261. };
  262. struct sfntCMapHeader {
  263.     UInt16                          version;
  264.     UInt16                          numTables;
  265.     sfntCMapEncoding                encoding[1];
  266. };
  267. typedef struct sfntCMapHeader           sfntCMapHeader;
  268. enum {
  269.     sizeof_sfntCMapHeader       = 4
  270. };
  271. /* Name table */
  272. enum {
  273.     nameFontTableTag            = FOUR_CHAR_CODE('name')
  274. };
  275. enum {
  276.     kFontCopyrightName          = 0,
  277.     kFontFamilyName             = 1,
  278.     kFontStyleName              = 2,
  279.     kFontUniqueName             = 3,
  280.     kFontFullName               = 4,
  281.     kFontVersionName            = 5,
  282.     kFontPostscriptName         = 6,
  283.     kFontTrademarkName          = 7,
  284.     kFontManufacturerName       = 8,
  285.     kFontDesignerName           = 9,
  286.     kFontDescriptionName        = 10,
  287.     kFontVendorURLName          = 11,
  288.     kFontDesignerURLName        = 12,
  289.     kFontLicenseDescriptionName = 13,
  290.     kFontLicenseInfoURLName     = 14,
  291.     kFontLastReservedName       = 255
  292. };
  293. /* The following is a special "don't care" value to be used in interfaces */
  294. enum {
  295.     kFontNoName                 = -1
  296. };
  297. struct sfntNameRecord {
  298.     UInt16                          platformID;                 /* base-0 */
  299.     UInt16                          scriptID;                   /* base-0 */
  300.     UInt16                          languageID;                 /* base-0 */
  301.     UInt16                          nameID;                     /* base-0 */
  302.     UInt16                          length;
  303.     UInt16                          offset;
  304. };
  305. typedef struct sfntNameRecord           sfntNameRecord;
  306. enum {
  307.     sizeof_sfntNameRecord       = 12
  308. };
  309. struct sfntNameHeader {
  310.     UInt16                          format;
  311.     UInt16                          count;
  312.     UInt16                          stringOffset;
  313.     sfntNameRecord                  rec[1];
  314. };
  315. typedef struct sfntNameHeader           sfntNameHeader;
  316. enum {
  317.     sizeof_sfntNameHeader       = 6
  318. };
  319. /* Fvar table - font variations */
  320. enum {
  321.     variationFontTableTag       = FOUR_CHAR_CODE('fvar')
  322. };
  323. /* These define each font variation */
  324. struct sfntVariationAxis {
  325.     FourCharCode                    axisTag;
  326.     Fixed                           minValue;
  327.     Fixed                           defaultValue;
  328.     Fixed                           maxValue;
  329.     SInt16                          flags;
  330.     SInt16                          nameID;
  331. };
  332. typedef struct sfntVariationAxis        sfntVariationAxis;
  333. enum {
  334.     sizeof_sfntVariationAxis    = 20
  335. };
  336. /* These are named locations in style-space for the user */
  337. struct sfntInstance {
  338.     SInt16                          nameID;
  339.     SInt16                          flags;
  340.     Fixed                           coord[1];                   /* [axisCount] */
  341.                                                                 /* room to grow since the header carries a tupleSize field */
  342. };
  343. typedef struct sfntInstance             sfntInstance;
  344. enum {
  345.     sizeof_sfntInstance         = 4
  346. };
  347. struct sfntVariationHeader {
  348.     Fixed                           version;                    /* 1.0 Fixed */
  349.     UInt16                          offsetToData;               /* to first axis = 16*/
  350.     UInt16                          countSizePairs;             /* axis+inst = 2 */
  351.     UInt16                          axisCount;
  352.     UInt16                          axisSize;
  353.     UInt16                          instanceCount;
  354.     UInt16                          instanceSize;
  355.                                                                 /* ...other <count,size> pairs */
  356.     sfntVariationAxis               axis[1];                    /* [axisCount] */
  357.     sfntInstance                    instance[1];                /* [instanceCount]  ...other arrays of data */
  358. };
  359. typedef struct sfntVariationHeader      sfntVariationHeader;
  360. enum {
  361.     sizeof_sfntVariationHeader  = 16
  362. };
  363. /* Fdsc table - font descriptor */
  364. enum {
  365.     descriptorFontTableTag      = FOUR_CHAR_CODE('fdsc')
  366. };
  367. struct sfntFontDescriptor {
  368.     FourCharCode                    name;
  369.     Fixed                           value;
  370. };
  371. typedef struct sfntFontDescriptor       sfntFontDescriptor;
  372. struct sfntDescriptorHeader {
  373.     Fixed                           version;                    /* 1.0 in Fixed */
  374.     SInt32                          descriptorCount;
  375.     sfntFontDescriptor              descriptor[1];
  376. };
  377. typedef struct sfntDescriptorHeader     sfntDescriptorHeader;
  378. enum {
  379.     sizeof_sfntDescriptorHeader = 8
  380. };
  381. /* Feat Table - layout feature table */
  382. enum {
  383.     featureFontTableTag         = FOUR_CHAR_CODE('feat')
  384. };
  385. struct sfntFeatureName {
  386.     UInt16                          featureType;
  387.     UInt16                          settingCount;
  388.     SInt32                          offsetToSettings;
  389.     UInt16                          featureFlags;
  390.     UInt16                          nameID;
  391. };
  392. typedef struct sfntFeatureName          sfntFeatureName;
  393. struct sfntFontFeatureSetting {
  394.     UInt16                          setting;
  395.     UInt16                          nameID;
  396. };
  397. typedef struct sfntFontFeatureSetting   sfntFontFeatureSetting;
  398. struct sfntFontRunFeature {
  399.     UInt16                          featureType;
  400.     UInt16                          setting;
  401. };
  402. typedef struct sfntFontRunFeature       sfntFontRunFeature;
  403. struct sfntFeatureHeader {
  404.     SInt32                          version;                    /* 1.0 */
  405.     UInt16                          featureNameCount;
  406.     UInt16                          featureSetCount;
  407.     SInt32                          reserved;                   /* set to 0 */
  408.     sfntFeatureName                 names[1];
  409.     sfntFontFeatureSetting          settings[1];
  410.     sfntFontRunFeature              runs[1];
  411. };
  412. typedef struct sfntFeatureHeader        sfntFeatureHeader;
  413. /* OS/2 Table */
  414. enum {
  415.     os2FontTableTag             = FOUR_CHAR_CODE('OS/2')
  416. };
  417. /*  Special invalid glyph ID value, useful as a sentinel value, for example */
  418. enum {
  419.     nonGlyphID                  = 65535L
  420. };
  421. /*  Data type used to access names from font name table */
  422. typedef UInt32                          FontNameCode;
  423. /* Data types for encoding components as used in interfaces */
  424. typedef UInt32                          FontPlatformCode;
  425. typedef UInt32                          FontScriptCode;
  426. typedef UInt32                          FontLanguageCode;
  427. /*
  428. **  FontVariation is used to specify a coordinate along a variation axis. The name
  429. **  identifies the axes to be applied, and value is the setting to be used.
  430. */
  431. struct FontVariation {
  432.     FourCharCode                    name;
  433.     Fixed                           value;
  434. };
  435. typedef struct FontVariation            FontVariation;
  436. #if PRAGMA_STRUCT_ALIGN
  437.     #pragma options align=reset
  438. #elif PRAGMA_STRUCT_PACKPUSH
  439.     #pragma pack(pop)
  440. #elif PRAGMA_STRUCT_PACK
  441.     #pragma pack()
  442. #endif
  443. #ifdef PRAGMA_IMPORT_OFF
  444. #pragma import off
  445. #elif PRAGMA_IMPORT
  446. #pragma import reset
  447. #endif
  448. #ifdef __cplusplus
  449. }
  450. #endif
  451. #endif /* __SFNTTYPES__ */