ATSUnicodeFlattening.pas 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. {
  2. File: QD/ATSUnicodeFlattening.h
  3. Contains: Public interfaces for Apple Type Services for Unicode Imaging
  4. Version: Quickdraw-262~1
  5. Copyright: © 2002-2008 by Apple Inc. all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  11. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  12. {
  13. Modified for use with Free Pascal
  14. Version 308
  15. Please report any bugs to <[email protected]>
  16. }
  17. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  18. {$mode macpas}
  19. {$packenum 1}
  20. {$macro on}
  21. {$inline on}
  22. {$calling mwpascal}
  23. unit ATSUnicodeFlattening;
  24. interface
  25. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  26. {$setc GAP_INTERFACES_VERSION := $0308}
  27. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  28. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  29. {$endc}
  30. {$ifc defined CPUPOWERPC and defined CPUI386}
  31. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  32. {$endc}
  33. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  34. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  35. {$endc}
  36. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  37. {$setc __ppc__ := 1}
  38. {$elsec}
  39. {$setc __ppc__ := 0}
  40. {$endc}
  41. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  42. {$setc __ppc64__ := 1}
  43. {$elsec}
  44. {$setc __ppc64__ := 0}
  45. {$endc}
  46. {$ifc not defined __i386__ and defined CPUI386}
  47. {$setc __i386__ := 1}
  48. {$elsec}
  49. {$setc __i386__ := 0}
  50. {$endc}
  51. {$ifc not defined __x86_64__ and defined CPUX86_64}
  52. {$setc __x86_64__ := 1}
  53. {$elsec}
  54. {$setc __x86_64__ := 0}
  55. {$endc}
  56. {$ifc not defined __arm__ and defined CPUARM}
  57. {$setc __arm__ := 1}
  58. {$elsec}
  59. {$setc __arm__ := 0}
  60. {$endc}
  61. {$ifc defined cpu64}
  62. {$setc __LP64__ := 1}
  63. {$elsec}
  64. {$setc __LP64__ := 0}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  67. {$error Conflicting definitions for __ppc__ and __i386__}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__}
  70. {$setc TARGET_CPU_PPC := TRUE}
  71. {$setc TARGET_CPU_PPC64 := FALSE}
  72. {$setc TARGET_CPU_X86 := FALSE}
  73. {$setc TARGET_CPU_X86_64 := FALSE}
  74. {$setc TARGET_CPU_ARM := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_IPHONE := FALSE}
  77. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  78. {$elifc defined __ppc64__ and __ppc64__}
  79. {$setc TARGET_CPU_PPC := FALSE}
  80. {$setc TARGET_CPU_PPC64 := TRUE}
  81. {$setc TARGET_CPU_X86 := FALSE}
  82. {$setc TARGET_CPU_X86_64 := FALSE}
  83. {$setc TARGET_CPU_ARM := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_IPHONE := FALSE}
  86. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  87. {$elifc defined __i386__ and __i386__}
  88. {$setc TARGET_CPU_PPC := FALSE}
  89. {$setc TARGET_CPU_PPC64 := FALSE}
  90. {$setc TARGET_CPU_X86 := TRUE}
  91. {$setc TARGET_CPU_X86_64 := FALSE}
  92. {$setc TARGET_CPU_ARM := FALSE}
  93. {$ifc defined(iphonesim)}
  94. {$setc TARGET_OS_MAC := FALSE}
  95. {$setc TARGET_OS_IPHONE := TRUE}
  96. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  97. {$elsec}
  98. {$setc TARGET_OS_MAC := TRUE}
  99. {$setc TARGET_OS_IPHONE := FALSE}
  100. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  101. {$endc}
  102. {$elifc defined __x86_64__ and __x86_64__}
  103. {$setc TARGET_CPU_PPC := FALSE}
  104. {$setc TARGET_CPU_PPC64 := FALSE}
  105. {$setc TARGET_CPU_X86 := FALSE}
  106. {$setc TARGET_CPU_X86_64 := TRUE}
  107. {$setc TARGET_CPU_ARM := FALSE}
  108. {$setc TARGET_OS_MAC := TRUE}
  109. {$setc TARGET_OS_IPHONE := FALSE}
  110. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  111. {$elifc defined __arm__ and __arm__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := FALSE}
  115. {$setc TARGET_CPU_X86_64 := FALSE}
  116. {$setc TARGET_CPU_ARM := TRUE}
  117. { will require compiler define when/if other Apple devices with ARM cpus ship }
  118. {$setc TARGET_OS_MAC := FALSE}
  119. {$setc TARGET_OS_IPHONE := TRUE}
  120. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  121. {$elsec}
  122. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  123. {$endc}
  124. {$ifc defined __LP64__ and __LP64__ }
  125. {$setc TARGET_CPU_64 := TRUE}
  126. {$elsec}
  127. {$setc TARGET_CPU_64 := FALSE}
  128. {$endc}
  129. {$ifc defined FPC_BIG_ENDIAN}
  130. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  131. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  132. {$elifc defined FPC_LITTLE_ENDIAN}
  133. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  134. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  135. {$elsec}
  136. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  137. {$endc}
  138. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  139. {$setc CALL_NOT_IN_CARBON := FALSE}
  140. {$setc OLDROUTINENAMES := FALSE}
  141. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  142. {$setc OPAQUE_UPP_TYPES := TRUE}
  143. {$setc OTCARBONAPPLICATION := TRUE}
  144. {$setc OTKERNEL := FALSE}
  145. {$setc PM_USE_SESSION_APIS := TRUE}
  146. {$setc TARGET_API_MAC_CARBON := TRUE}
  147. {$setc TARGET_API_MAC_OS8 := FALSE}
  148. {$setc TARGET_API_MAC_OSX := TRUE}
  149. {$setc TARGET_CARBON := TRUE}
  150. {$setc TARGET_CPU_68K := FALSE}
  151. {$setc TARGET_CPU_MIPS := FALSE}
  152. {$setc TARGET_CPU_SPARC := FALSE}
  153. {$setc TARGET_OS_UNIX := FALSE}
  154. {$setc TARGET_OS_WIN32 := FALSE}
  155. {$setc TARGET_RT_MAC_68881 := FALSE}
  156. {$setc TARGET_RT_MAC_CFM := FALSE}
  157. {$setc TARGET_RT_MAC_MACHO := TRUE}
  158. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  159. {$setc TYPE_BOOL := FALSE}
  160. {$setc TYPE_EXTENDED := FALSE}
  161. {$setc TYPE_LONGLONG := TRUE}
  162. uses MacTypes,ATSUnicodeTypes,SFNTTypes;
  163. {$endc} {not MACOSALLINCLUDE}
  164. {$ifc TARGET_OS_MAC}
  165. { ---------------------------------------------------------------------------- }
  166. { Constants }
  167. { ---------------------------------------------------------------------------- }
  168. {
  169. ATSUFlattenedDataStreamFormat is used to inform the APIs which flatten and
  170. unflatten style runs exactly what type of data that they should be generating
  171. or parsing.
  172. }
  173. {$ALIGN MAC68K}
  174. type
  175. ATSUFlattenedDataStreamFormat = UInt32;
  176. const
  177. kATSUDataStreamUnicodeStyledText = FourCharCode('ustl');
  178. {
  179. ATSUFlattenStyleRunOptions is a bitfield list of options that can be passed
  180. into the ATSUFlattenStyleRunsToStream API. Currently, there are no options.
  181. This is here for future expansion.
  182. }
  183. type
  184. ATSUFlattenStyleRunOptions = UInt32;
  185. const
  186. kATSUFlattenOptionNoOptionsMask = $00000000;
  187. {
  188. ATSUUnFlattenStyleRunOptions is a bitfield list of options that can be passed
  189. into the ATSUUnFlattenStyleRunsToStream API. Currently, there are no options.
  190. This is here for future expansion.
  191. }
  192. type
  193. ATSUUnFlattenStyleRunOptions = UInt32;
  194. const
  195. kATSUUnFlattenOptionNoOptionsMask = $00000000;
  196. { ---------------------------------------------------------------------------- }
  197. { Data Types }
  198. { ---------------------------------------------------------------------------- }
  199. {
  200. ATSUStyleRunInfo is a structure that contains an index into an array of
  201. unique ATSUStyle objects as well as the length of the run that the style run
  202. object covers. This structure is utilized by ATSUUnflattenStyleRunsFromStream()
  203. to return the style run info to the caller.
  204. }
  205. type
  206. ATSUStyleRunInfo = record
  207. runLength: UInt32;
  208. styleObjectIndex: UInt32;
  209. end;
  210. ATSUStyleRunInfoPtr = ^ATSUStyleRunInfo;
  211. { ---------------------------------------------------------------------------- }
  212. { 'ustl' structure data structures and definitions }
  213. { ---------------------------------------------------------------------------- }
  214. {
  215. The 'ustl' data structure follows this format:
  216. 1. Main Data Structure Block Header
  217. 2. Flattened Text Layout Data
  218. 3. Flattened Style Run Data
  219. 4. Flattened Style Data
  220. Per the 'ustl' spec, these structures should maintain four-byte alignment.
  221. For things that are variable width (such as font names), padding bytes must
  222. be added to ensure that this alignment is always kept.
  223. }
  224. {
  225. structure versioning - the version of the 'ustl' that the ATSUI parsing
  226. and generating functions will handle is version 2 or greater. Earlier
  227. versions were not completly specified and have been obsoleted.
  228. }
  229. const
  230. kATSFlatDataUstlVersion0 = 0;
  231. kATSFlatDataUstlVersion1 = 1;
  232. kATSFlatDataUstlVersion2 = 2;
  233. kATSFlatDataUstlCurrentVersion = kATSFlatDataUstlVersion2;
  234. { ------------------ }
  235. { Block 1 Structures }
  236. { ------------------ }
  237. {
  238. This is the main data structure block header. It describes the rest
  239. of the data and how it is structured.
  240. }
  241. type
  242. ATSFlatDataMainHeaderBlock = record
  243. { the 'ustl' version number. This needs to be the first item in the}
  244. { data block do as not to confuse parsers of earlier (and possibly}
  245. { later) versions of the spec *|}
  246. version: UInt32;
  247. { the total size of the stream in bytes, including the four bytes in}
  248. { the version above}
  249. sizeOfDataBlock: UInt32;
  250. { offset from the beginning of the stream to the flattened text layout data.}
  251. { This can be set to 0 if there are no text layouts stored in the stream.}
  252. offsetToTextLayouts: UInt32;
  253. { offset from the beginning of the stream to the flattened style run data. }
  254. { This can be set to 0 if there is no flattened style run data in the stream}
  255. offsetToStyleRuns: UInt32;
  256. { offset to the flattened style list data. This can be set to 0 if there}
  257. { is no flattened style list data}
  258. offsetToStyleList: UInt32;
  259. end;
  260. ATSFlatDataMainHeaderBlockPtr = ^ATSFlatDataMainHeaderBlock;
  261. { ------------------ }
  262. { Block 2 Structures }
  263. { ------------------ }
  264. {
  265. The Block 2 Structures are not currently used by any of ATSUI's internal parsing
  266. or packing routines. They are, however, part of the 'ustl' standard and are put
  267. here for developer conveniance, as well as to properly define the standard.
  268. }
  269. {
  270. This is the header that is attached to each flattened text layout. The
  271. number of flattened text layouts in the stucture is specified by the
  272. ATSFlatDataTextLayoutHeader structure that is below.
  273. }
  274. type
  275. ATSFlatDataTextLayoutDataHeader = record
  276. { the total size of this particular flattened text layout, including any}
  277. { padding bytes and such. }
  278. sizeOfLayoutData: UInt32;
  279. { the number of characters covered by this flattened text layout}
  280. textLayoutLength: UInt32;
  281. { the byte offset relative to the start of this structure to the flattened}
  282. { layout control data. This can be set to zero if there are no layout}
  283. { controls.}
  284. offsetToLayoutControls: UInt32;
  285. { the byte offset, relative to the start of this structure to the}
  286. { flattened line info. This can be set to zero if there is no line info }
  287. { in this layout.}
  288. offsetToLineInfo: UInt32;
  289. { if the offsetToLayoutControls is non-zero, then following this block}
  290. { there will be a ATSFlattenedLayoutDataFlattenedLayoutControlsHeader}
  291. { followed by an array of ATSFlattenedLayoutDataFlattenedLayoutControls}
  292. { structures. If the offsetToLineInfo is non-zero, then following the}
  293. { flattened layout controls will be a ATSFlatDataLineInfoHeader}
  294. { structure.}
  295. end;
  296. ATSFlatDataTextLayoutDataHeaderPtr = ^ATSFlatDataTextLayoutDataHeader;
  297. {
  298. This is the the main header for block 2. If there is a block 2, then there
  299. needs to be one of these. This structure is what the offsetToTextLayouts
  300. points to in block 1.
  301. }
  302. type
  303. ATSFlatDataTextLayoutHeader = record
  304. { the total number of flattened text layouts stored in this block.}
  305. { This must be non-zero, as if there were no flattened text layouts, the}
  306. { entire block 2 would not exist}
  307. numFlattenedTextLayouts: UInt32;
  308. { first of possibly many flattened text layouts. There should be one of}
  309. { these for each flattened text layout as determined by the}
  310. { numFlattenedTextLayouts above. }
  311. flattenedTextLayouts: array[0..0] of ATSFlatDataTextLayoutDataHeader;
  312. end;
  313. ATSFlatDataTextLayoutHeaderPtr = ^ATSFlatDataTextLayoutHeader;
  314. {
  315. This is the header for the flattened layout controls structure. This is
  316. the structure that a non-zero offsetToLayoutControls points to in the
  317. ATSFlatDataTextLayoutDataHeader
  318. }
  319. type
  320. ATSFlatDataLayoutControlsDataHeader = record
  321. { the number of flattened layout controls. It is suggested that there be}
  322. { at least one layout control to output the line direction for the layout}
  323. numberOfLayoutControls: UInt32;
  324. { first of possibly many flattened layout controls. There should be one }
  325. { of these for each layout control as determined by the}
  326. { numberOfLayoutControls above. Of course, if there are no layout controls,}
  327. { then this structure shouldn't even exist. Each attribute info structure}
  328. { in the array could be followed by additional padding bytes in order}
  329. { to maintain four-byte alignment. These padding bytes are not to be}
  330. { included in the fValueSize member of each structure. }
  331. controlArray: array[0..0] of ATSUAttributeInfo;
  332. end;
  333. ATSFlatDataLayoutControlsDataHeaderPtr = ^ATSFlatDataLayoutControlsDataHeader;
  334. type
  335. ATSFlatDataLineInfoData = record
  336. { the length of this particular line in UniChars}
  337. lineLength: UInt32;
  338. { the number of line controls applied to this line. This can be set}
  339. { to zero if there are no special line controls applied to this line.}
  340. numberOfLineControls: UInt32;
  341. { the numberOfLineControls is non-zero, then following this structure}
  342. { must be an array of ATSUAttributeInfo structures. There must be one}
  343. { ATSUAttributeInfo structure for each numberOfLineControls above.}
  344. end;
  345. ATSFlatDataLineInfoDataPtr = ^ATSFlatDataLineInfoData;
  346. {
  347. This structure is the main data header for the flattened line info data. This
  348. is what a non-zero offsetToLineInfo points to in the
  349. ATSFlatDataTextLayoutDataHeader structure above.
  350. }
  351. type
  352. ATSFlatDataLineInfoHeader = record
  353. { the number of flattened line info structures that are stored in this}
  354. { block. This value should really be equal to the number of soft line}
  355. { breaks in the layout + 1. Of course if numberOfLines is zero, then}
  356. { this structure shouldn't even be used.}
  357. numberOfLines: UInt32;
  358. { the first in a array of ATSFlatDataLineInfoData structures. There}
  359. { needs to be a ATSFlatDataLineInfoData for each numberOfLines}
  360. { specified above.}
  361. lineInfoArray: array[0..0] of ATSFlatDataLineInfoData;
  362. end;
  363. ATSFlatDataLineInfoHeaderPtr = ^ATSFlatDataLineInfoHeader;
  364. { ------------------ }
  365. { Block 3 Structures }
  366. { ------------------ }
  367. {
  368. The block 3 structures are used by ATSUI style run flattening and parsing
  369. functions, ATSUFlattenStyleRunsToStream and ATSUUnflattenStyleRunsFromStream
  370. to represent flattened style run information. These structures go hand and
  371. hand with the block 4 structures.
  372. }
  373. {
  374. This is the data header that appears before the style run data structures.
  375. This structure is what a non-zero offsetToStyleRuns in the
  376. ATSFlatDataMainHeaderBlock points to in block 1.
  377. }
  378. type
  379. ATSFlatDataStyleRunDataHeader = record
  380. { the number of style run data structures stored in this block}
  381. numberOfStyleRuns: UInt32;
  382. { the first in an array of ATSUStyleRunInfo structures. There needs to}
  383. { be a ATSUStyleRunInfo structure for each numberOfStyleRuns specified}
  384. { above. This structure is defined in ATSUnicode.h}
  385. styleRunArray: array[0..0] of ATSUStyleRunInfo;
  386. end;
  387. ATSFlatDataStyleRunDataHeaderPtr = ^ATSFlatDataStyleRunDataHeader;
  388. { ------------------ }
  389. { Block 4 Structures }
  390. { ------------------ }
  391. {
  392. The block 4 structures store flattened ATSUStyle objects. This too, is
  393. currently used by the ATSUI style run flattening and parsing functions,
  394. ATSUFlattenStyleRunsToStream and ATSUUnflattenStyleRunsFromStream.
  395. }
  396. {
  397. this structure forms the beginning of an individually flattened ATSUStyle
  398. object.
  399. }
  400. type
  401. ATSFlatDataStyleListStyleDataHeader = record
  402. { the size of this flattened style object, including these four bytes and}
  403. { any padding bytes at the end of the structure. Basically, this can be}
  404. { used to determine where the next structure in the array begins.}
  405. sizeOfStyleInfo: UInt32;
  406. { the number of attributes set in this flattened style object. This should }
  407. { be at least one for the font data, although it can be 0 if this is to be}
  408. { unspecfied.}
  409. numberOfSetAttributes: UInt32;
  410. { the number of font features set in the flattened style object. This can}
  411. { be set to 0 if there are no font features set in the style object. }
  412. numberOfSetFeatures: UInt32;
  413. { the number of font variations set in the flattened style object. This}
  414. { can be set to 0 if there are no font variations set in the style object.}
  415. numberOfSetVariations: UInt32;
  416. { after this structure header, there is the following data in this block:}
  417. { 1. if the numberOfSetAttributes is non-zero, then there will be an}
  418. { array of ATSUAttributeInfo structures immediately following the}
  419. { above header data to store the style attributes. This is a variable}
  420. { structure array. There must be one ATSUAttributeInfo for}
  421. { for each numberOfSetAttributes. If numberOfSetAttributes is zero,}
  422. { then skip to the next data section 2.}
  423. { 2. if the numberOfSetFeatures is non-zero, then there will be an array}
  424. { of ATSFlatDataStyleListFeatureData structures immediately after}
  425. { the ATSUAttributeInfo array above (if any). There must be one}
  426. { ATSFlatDataStyleListFeatureData structure for each }
  427. { numberOfSetFeatures set in the header above. If numberOfSetFeatures}
  428. { is zero, then skip to the next data section 3.}
  429. { 3. if the numberOfSetVariations is non-zero, then there will be an}
  430. { array of ATSFlatDataStyleListVariationData immediately after the}
  431. { ATSFlatDataStyleListFeatureData array above (if any). There must be}
  432. { one ATSFlatDataStyleListVariationData structure for each }
  433. { numberOfSetVariations set in the header above.}
  434. end;
  435. ATSFlatDataStyleListStyleDataHeaderPtr = ^ATSFlatDataStyleListStyleDataHeader;
  436. {
  437. this structure is the main header for this block. This structure is what a
  438. non-zero offsetToStyleList in the ATSFlatDataMainHeaderBlock points to in
  439. block 1.
  440. }
  441. type
  442. ATSFlatDataStyleListHeader = record
  443. { the total number of flattened style objects stored in this block}
  444. numberOfStyles: UInt32;
  445. { the first in an array of flattned style entries. The data stored}
  446. { in them is variably sized, so a simply array access won't do for}
  447. { iterating through these. However, there must be one of these}
  448. { ATSFlatDataStyleListStyleDataHeader structures for each }
  449. { numberOfStyles above.}
  450. styleDataArray: array[0..0] of ATSFlatDataStyleListStyleDataHeader;
  451. end;
  452. ATSFlatDataStyleListHeaderPtr = ^ATSFlatDataStyleListHeader;
  453. {
  454. this structure stores flattened font feature data. An array of these comes
  455. after the array of font data attributes (if any) if the numberOfSetFeatures is
  456. non-zero. There must be one of these structures for each numberOfSetFeatures.
  457. }
  458. type
  459. ATSFlatDataStyleListFeatureData = record
  460. { the font feature type}
  461. theFeatureType: ATSUFontFeatureType;
  462. { the font feature selector}
  463. theFeatureSelector: ATSUFontFeatureSelector;
  464. end;
  465. ATSFlatDataStyleListFeatureDataPtr = ^ATSFlatDataStyleListFeatureData;
  466. {
  467. this structure stores the flattened font variation data. An array of these
  468. comes after the array of ATSFlatDataStyleListFeatureData structures (if any)
  469. if the numberOfSetVariations is non-zero. There must be one of these
  470. structures for each numberOfSetFeatures.
  471. }
  472. type
  473. ATSFlatDataStyleListVariationData = record
  474. { the variation axis}
  475. theVariationAxis: ATSUFontVariationAxis;
  476. { the variation value}
  477. theVariationValue: ATSUFontVariationValue;
  478. end;
  479. ATSFlatDataStyleListVariationDataPtr = ^ATSFlatDataStyleListVariationData;
  480. { ------------------------ }
  481. { Flattened Font Data Info }
  482. { ------------------------ }
  483. {
  484. This is somewhat of an addendum to the 'ustl' structure above. These flattened
  485. data structures are stored in block 4 as a font attribute with the attribute
  486. tag of kATSUFontTag. They can store font data in a few different ways, such as
  487. by a FontSync reference or by simple raw font name data. Just as with the
  488. 'ustl' above, this structure must maintain four byte alignment.
  489. }
  490. { these are the currenly supported font specifiers. }
  491. type
  492. ATSFlatDataFontSpeciferType = UInt32;
  493. const
  494. { this specifier allows the storage of font data based on name data. This}
  495. { uses the stuctures below to store the actual data itself.}
  496. kATSFlattenedFontSpecifierRawNameData = FourCharCode('namd');
  497. {
  498. this is the main header for the font data. It dictates what type of data
  499. is stored. The actual data stored must match the type specified by the
  500. nameSpecType.
  501. }
  502. type
  503. ATSFlatDataFontNameDataHeader = record
  504. { the type of data that is flattened in this structure}
  505. nameSpecifierType: ATSFlatDataFontSpeciferType;
  506. { the size of the data that is flattened in this structre, not including }
  507. { any padding bytes that may be necessary to achive the four byte }
  508. { alignment of the data, unless they are specified as part of structure, }
  509. { such as with the ATSFlatDataFontSpecRawNameData structure.}
  510. nameSpecifierSize: UInt32;
  511. { after this header comes the flattened font name data which matches}
  512. { the type specified by the nameSpecifierType above. For instance, if }
  513. { the nameSpecType is kATSFlattenedFontNameSpecifierRawNameData, the}
  514. { structure that immediately follows this would be a}
  515. { ATSFlatDataFontNameRawNameDataHeader structure. }
  516. end;
  517. ATSFlatDataFontNameDataHeaderPtr = ^ATSFlatDataFontNameDataHeader;
  518. {
  519. the next two structures are only used when the nameSpecType is set to
  520. kATSFlattenedFontSpecifierRawNameData. They are setup to store multiple
  521. font name table entries for the purposes of reconstructing an ATSUFontID
  522. for (hopefully) the same font some time in the future.
  523. }
  524. { this is the structure in which raw font name data is actually stored. }
  525. type
  526. ATSFlatDataFontSpecRawNameData = record
  527. { the type of name being specified}
  528. fontNameType: FontNameCode;
  529. { the platform type of the font name, whether it be Unicode, Mac, etc. }
  530. { This should be specified if known. If not known, then specify}
  531. { kFontNoPlatform, but then all matching will be done based on the first}
  532. { font in the name table matching the other parameters.}
  533. fontNamePlatform: FontPlatformCode;
  534. { the script code of the fontÕs name based on the platform that was passed}
  535. { in above. If set to kFontNoScript, then the name will be matched based}
  536. { on the first font in the name table matching the other font name}
  537. { parameters.}
  538. fontNameScript: FontScriptCode;
  539. { the language of the font name. If set to kFontNoLanguage, then the name }
  540. { will be matched based on the first font in the name table matching the}
  541. { other font name parameters.}
  542. fontNameLanguage: FontLanguageCode;
  543. { the length of the font name in bytes, not including any padding bytes}
  544. { added to maintain the four byte alignment}
  545. fontNameLength: UInt32;
  546. { after the name length comes the actual font name data itself, plus any}
  547. { padding bytes needed to maintain the four byte alignment.}
  548. end;
  549. ATSFlatDataFontSpecRawNameDataPtr = ^ATSFlatDataFontSpecRawNameData;
  550. {
  551. this is a header structure that defines some things constant throughout
  552. the entire search for the font name, as well as the array of
  553. ATSFlatDataFontNameData structures. In order to gaurantee that the same font
  554. will be used, more than one name specifer should be stored. The standard ATSUI
  555. style run flattening and parsing functions, ATSUFlattenStyleRunsToStream and
  556. ATSUUnflattenStyleRunsFromStream. These will store both the font's full name
  557. (kFontFullName) as well as the font's manufacturer name (kFontManufacturerName)
  558. and match fonts based on both of
  559. these.
  560. }
  561. type
  562. ATSFlatDataFontSpecRawNameDataHeader = record
  563. { the number of flattened font names. There must be at least one flattened }
  564. { font name, otherwise the structure is malformed.}
  565. numberOfFlattenedNames: UInt32;
  566. { the first in an array of possibly many font name specifiers - depending}
  567. { on how specific the caller wants this. There must be one }
  568. { ATSFlatDataFontNameData structure for each numberOfFlattenedNames}
  569. { above.}
  570. nameDataArray: array[0..0] of ATSFlatDataFontSpecRawNameData;
  571. end;
  572. ATSFlatDataFontSpecRawNameDataHeaderPtr = ^ATSFlatDataFontSpecRawNameDataHeader;
  573. { ---------------------------------------------------------------------------- }
  574. { Style Flattening and Parsing Functions }
  575. { ---------------------------------------------------------------------------- }
  576. {$ifc not TARGET_CPU_64}
  577. {
  578. * ATSUFlattenStyleRunsToStream() *** DEPRECATED ***
  579. *
  580. * Deprecated:
  581. * Use CoreFoundation flattening API instead.
  582. *
  583. * Summary:
  584. * Converts a series of ATSUStyle objects and associated run info to
  585. * a flat binary representation.
  586. *
  587. * Discussion:
  588. * This function takes an array of ATSUStyle objects and style run
  589. * information and flattens the data to the specified format. The
  590. * style runs must all reference the same block of Unicode text
  591. * (usually passed separately as text in the 'utxt' format). The
  592. * style runs must also be in ascending order relative to the text
  593. * in the text block. Typically you use the function
  594. * ATSUFlattenStyleRunsFromStream by calling it twice, as follows:
  595. * (1) Provide appropriate values for the iStreamFormat,
  596. * iFlattenOptions, iNumberOfRunInfo, iRunInfoArray,
  597. * iNumberOfStyleObjects, and iStyleArray parameters. Set
  598. * iStreamBufferSize to 0, oStreamBuffer to NULL, and pass a valid
  599. * reference to a UInt32 variable in the oActualStreamBufferSize
  600. * parameter. Call the function ATSUFlattenStyleRunsToStream. On
  601. * return, oActualStreamBufferSize points to the size needed for the
  602. * buffer. (2) Allocate an appropriately-sized buffer for the
  603. * oStreamBuffer parameter and then call the function
  604. * ATSUFlattenStyleRunsToStream a second time.
  605. *
  606. * Parameters:
  607. *
  608. * iStreamFormat:
  609. * The format of the flattened data. There is only one format
  610. * supported at this time ('ustl'), so you must pass the constant
  611. * kATSUDataStreamUnicodeStyledText.
  612. *
  613. * iFlattenOptions:
  614. * The options you want to use to flatten the data. There are no
  615. * options supported at this time, so you must pass the constant
  616. * kATSUFlattenOptionNoOptionsMask.
  617. *
  618. * iNumberOfRunInfo:
  619. * The number of style run information structures passed in the
  620. * iRunInfoArray parameter. If you pass 0, ATSUI assumes there is
  621. * only one style for the entire text block passed in the
  622. * oStreamBuffer parameter. The flattened data format passed to
  623. * the iStreamFormat parameter must support the use of one style.
  624. *
  625. * iRunInfoArray:
  626. * An array of ATSUStyleRunInfo structures that describes the
  627. * style runs to be flattened. This array must contain
  628. * iNumberOfRunInfo entries. An ATSUStyleRunInfo structure
  629. * contains an index into an array of unique ATSUStyle objects and
  630. * the length of the run to which the style object applies. Each
  631. * index in the ATSUStyleRunInfo structure must reference a valid
  632. * ATSUStyle object passed in the iStyleArray parameter. You can
  633. * pass NULL, only if iNumberOfRunInfo is set to zero.
  634. *
  635. * iNumberOfStyleObjects:
  636. * The number of ATSUStyle objects in the array passed to the
  637. * iStyleArray parameter. You must pass a value that is greater
  638. * than 0.
  639. *
  640. * iStyleArray:
  641. * An array of ATSUStyle objects to be flattened. You cannot pass
  642. * NULL.
  643. *
  644. * iStreamBufferSize:
  645. * The size of the stream buffer, pointed to by the oStreamBuffer
  646. * parameter. You can pass 0only if the iStreamBufferSize
  647. * parameter is set to NULL. If you are uncertain of the size of
  648. * the array, see the Discussion.
  649. *
  650. * oStreamBuffer:
  651. * On input, a pointer to the data you want to flatten. On return,
  652. * points to the flattened data. If you pass NULL for this
  653. * parameter, no data is flattened. Instead, the size of the
  654. * buffer is calculated by ATSUI and returned in oActualStreamSize
  655. * parameter. See the Discussion for more details. You are
  656. * responsible for allocating the text buffer passed in the
  657. * oStreamBuffer parameter.
  658. *
  659. * oActualStreamBufferSize:
  660. * On return, the size of the data written to the oStreamBuffer
  661. * parameter. You can pass NULL only if the oStreamBuffer
  662. * parameter is not NULL.
  663. *
  664. * Result:
  665. * On success, noErr is returned. See MacErrors.h for possible error
  666. * codes.
  667. *
  668. * Availability:
  669. * Mac OS X: in version 10.2 and later in ApplicationServices.framework [32-bit only] but deprecated in 10.6
  670. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  671. * Non-Carbon CFM: not available
  672. }
  673. function ATSUFlattenStyleRunsToStream( iStreamFormat: ATSUFlattenedDataStreamFormat; iFlattenOptions: ATSUFlattenStyleRunOptions; iNumberOfRunInfo: ItemCount; {const} iRunInfoArray: {variable-size-array} ATSUStyleRunInfoPtr; iNumberOfStyleObjects: ItemCount; {const} iStyleArray: {variable-size-array} ATSUStylePtr; iStreamBufferSize: ByteCount; oStreamBuffer: UnivPtr; oActualStreamBufferSize: ByteCountPtr ): OSStatus; external name '_ATSUFlattenStyleRunsToStream';
  674. (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  675. {
  676. * ATSUUnflattenStyleRunsFromStream() *** DEPRECATED ***
  677. *
  678. * Deprecated:
  679. * Use CoreFoundation flattening API instead.
  680. *
  681. * Summary:
  682. * Creates a series of ATSUStyle objects and associated run
  683. * information from a flat binary representation.
  684. *
  685. * Discussion:
  686. * This function extracts the ATSUI style run information from
  687. * previously-flattened data. The style objects and style run
  688. * information structures are returned in two separate arraysÑthe
  689. * array oStyleArray and the array oRunInfoArray. These arrays are
  690. * not parallel. Each ATSUStyle object in the oStyleArray is a
  691. * unique ATSUStyle object. To figure out which ATSUStyle object
  692. * belongs to which text run, the caller must parse the array of
  693. * ATSUStyleRunInfo structures. These structures contain the style
  694. * run lengths and an index into the oStyleArray. Typically you use
  695. * the function ATSUUnflattenStyleRunsFromStream by calling it
  696. * twice, as follows: (1) Provide appropriate values for the
  697. * iStreamFormat, iUnflattenOptions, and iStreamBuffer parameters.
  698. * Pass 0for the iNumberOfRunInfo and iNumberOfStyleObjects
  699. * parameters, NULL for the oRunInfoArray and oStyleArray,
  700. * parameters and valid ItemCount references for the
  701. * oActualNumberOfRunInfo and oActualNumberOfStyleObjects
  702. * parameters. On return, oActualNumberOfRunInfo and
  703. * oActualNumberOfStyleObjects point to the sizes needed to allocate
  704. * these arrays. (2) Allocate appropriately-sized arrays of
  705. * ATSUStyleRunStructures and ATSUStyle object references. Call the
  706. * function ATSUUnflattenStyleRunsFromStream a second time, passing
  707. * the newly allocated arrays in the oRunInfoArray and oStyleArray
  708. * parameters, with the iNumberOfRunInfo and iNumberOfStyleObjects
  709. * parameters set to the values you obtained from the first call.
  710. *
  711. * Parameters:
  712. *
  713. * iStreamFormat:
  714. * The format of the flattened data. There is only one format
  715. * supported at this time ('ustl'), so you must pass the constant
  716. * kATSUDataStreamUnicodeStyledText.
  717. *
  718. * iUnflattenOptions:
  719. * The options you want to use to unflatten the data. There are no
  720. * options supported at this time, so you must pass the constant
  721. * kATSUUnflattenOptionNoOptionsMask.
  722. *
  723. * iStreamBufferSize:
  724. * The size of the buffer pointed to by the iStreamBuffer
  725. * parameter. You must pass a value greater than 0.
  726. *
  727. * iStreamBuffer:
  728. * A pointer to the buffer that contains the flattened data. The
  729. * data must be of the format specified by the iStreamFormat
  730. * parameter and must be of size specified by the
  731. * iStreamBufferSize parameter. You cannot pass NULL .
  732. *
  733. * iNumberOfRunInfo:
  734. * The number of style run information structures passed in the
  735. * oRunInfoArray parameter. If you are uncertain of the number of
  736. * style run information structures, see the Discussion.
  737. *
  738. * iNumberOfStyleObjects:
  739. * The number of ATSUStyle objects in the array passed into the
  740. * iStyleArray parameter. If you are uncertain of the number of
  741. * ATSUStyle objects, see the Discussion.
  742. *
  743. * oRunInfoArray:
  744. * On return, points to an array of style run information
  745. * structures. Each structure contains a style run length and
  746. * index into the oStyleArray array. If you are uncertain of how
  747. * much memory to allocate for this array, see the Discussion. You
  748. * are responsible for disposing of the array when you no longer
  749. * need it.
  750. *
  751. * oStyleArray:
  752. * On return, a pointer to an array of the unique ATSUStyle
  753. * objects obtained from the flattened data. The indices returned
  754. * in the array oRunInfoArray are indices into this array. If you
  755. * are uncertain of how much memory to allocate for this array,
  756. * see the Discussion. You are responsible for disposing of the
  757. * array and the ATSUI style objects in the array when you no
  758. * longer need the array.
  759. *
  760. * oActualNumberOfRunInfo:
  761. * On return, points to the actual number of ATSUStyleRunInfo
  762. * structures obtained from the flattened data. The actual number
  763. * of structures is the number of entries added to the array
  764. * oRunInfoArray. You can pass NULL if you to not want to obtain
  765. * this value.
  766. *
  767. * oActualNumberOfStyleObjects:
  768. * On return, points to the actual number of unique ATSUStyle
  769. * objects obtained from the flattened data. The actual number is
  770. * the number of entries added to the oStyleArray array. You can
  771. * pass NULL if you do no want to obtain this value.
  772. *
  773. * Result:
  774. * On success, noErr is returned. See MacErrors.h for possible error
  775. * codes.
  776. *
  777. * Availability:
  778. * Mac OS X: in version 10.2 and later in ApplicationServices.framework [32-bit only] but deprecated in 10.6
  779. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  780. * Non-Carbon CFM: not available
  781. }
  782. function ATSUUnflattenStyleRunsFromStream( iStreamFormat: ATSUFlattenedDataStreamFormat; iUnflattenOptions: ATSUUnFlattenStyleRunOptions; iStreamBufferSize: ByteCount; iStreamBuffer: {const} UnivPtr; iNumberOfRunInfo: ItemCount; iNumberOfStyleObjects: ItemCount; oRunInfoArray: {variable-size-array} ATSUStyleRunInfoPtr; oStyleArray: {variable-size-array} ATSUStylePtr; oActualNumberOfRunInfo: ItemCountPtr; oActualNumberOfStyleObjects: ItemCountPtr ): OSStatus; external name '_ATSUUnflattenStyleRunsFromStream';
  783. (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  784. { Functions listed beyond this point are either deprecated or not recommended }
  785. {
  786. * ATSUCopyToHandle() *** DEPRECATED ***
  787. *
  788. * Deprecated:
  789. * Use CoreFoundation flattening API instead.
  790. *
  791. * Discussion:
  792. * This function is no longer recommended. Please use
  793. * ATSUFlattenStyleRunsToStream instead.
  794. *
  795. * Availability:
  796. * Mac OS X: in version 10.0 and later in ApplicationServices.framework [32-bit only] but deprecated in 10.1
  797. * CarbonLib: in CarbonLib 1.0 and later
  798. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  799. }
  800. function ATSUCopyToHandle( iStyle: ATSUStyle; oStyleHandle: Handle ): OSStatus; external name '_ATSUCopyToHandle';
  801. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 *)
  802. {
  803. * ATSUPasteFromHandle() *** DEPRECATED ***
  804. *
  805. * Deprecated:
  806. * Use CoreFoundation flattening API instead.
  807. *
  808. * Discussion:
  809. * This function is no longer recommended. Please use
  810. * ATSUUnflattenStyleRunsFromStream instead.
  811. *
  812. * Availability:
  813. * Mac OS X: in version 10.0 and later in ApplicationServices.framework [32-bit only] but deprecated in 10.1
  814. * CarbonLib: in CarbonLib 1.0 and later
  815. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  816. }
  817. function ATSUPasteFromHandle( iStyle: ATSUStyle; iStyleHandle: Handle ): OSStatus; external name '_ATSUPasteFromHandle';
  818. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 *)
  819. {$endc} {not TARGET_CPU_64}
  820. {$endc} {TARGET_OS_MAC}
  821. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  822. end.
  823. {$endc} {not MACOSALLINCLUDE}