ATSUnicodeFlattening.pas 38 KB

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