SFNTTypes.pas 14 KB

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