Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

552 lines
27 KiB

  1. /*
  2. File: ATSUnicodeFlattening.h
  3. Contains: Public interfaces for Apple Type Services for Unicode Imaging
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2002 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __ATSUNICODEFLATTENING__
  11. #define __ATSUNICODEFLATTENING__
  12. #ifndef __ATSUNICODE__
  13. #include <ATSUnicode.h>
  14. #endif
  15. #if PRAGMA_ONCE
  16. #pragma once
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #if PRAGMA_IMPORT
  22. #pragma import on
  23. #endif
  24. #if PRAGMA_STRUCT_ALIGN
  25. #pragma options align=mac68k
  26. #elif PRAGMA_STRUCT_PACKPUSH
  27. #pragma pack(push, 2)
  28. #elif PRAGMA_STRUCT_PACK
  29. #pragma pack(2)
  30. #endif
  31. /* ---------------------------------------------------------------------------- */
  32. /* Constants */
  33. /* ---------------------------------------------------------------------------- */
  34. /*
  35. ATSUFlattenedDataStreamFormat is used to inform the APIs which flatten and
  36. unflatten style runs exactly what type of data that they should be generating
  37. or parsing.
  38. */
  39. typedef UInt32 ATSUFlattenedDataStreamFormat;
  40. enum {
  41. kATSUDataStreamUnicodeStyledText = FOUR_CHAR_CODE('ustl')
  42. };
  43. /*
  44. ATSUFlattenStyleRunOptions is a bitfield list of options that can be passed
  45. into the ATSUFlattenStyleRunsToStream API. Currently, there are no options.
  46. This is here for future expansion.
  47. */
  48. typedef UInt32 ATSUFlattenStyleRunOptions;
  49. enum {
  50. kATSUFlattenOptionNoOptionsMask = 0x00000000
  51. };
  52. /*
  53. ATSUUnFlattenStyleRunOptions is a bitfield list of options that can be passed
  54. into the ATSUUnFlattenStyleRunsToStream API. Currently, there are no options.
  55. This is here for future expansion.
  56. */
  57. typedef UInt32 ATSUUnFlattenStyleRunOptions;
  58. enum {
  59. kATSUUnFlattenOptionNoOptionsMask = 0x00000000
  60. };
  61. /* ---------------------------------------------------------------------------- */
  62. /* Data Types */
  63. /* ---------------------------------------------------------------------------- */
  64. /*
  65. ATSUStyleRunInfo is a structure that contrains an index into an array of
  66. unique ATSUStyle objects as well as the length of the run that the style run
  67. object covers. This structure is utilized by ATSUUnflattenStyleRunsFromStream()
  68. to return the style run info to the caller.
  69. */
  70. struct ATSUStyleRunInfo {
  71. UniCharCount runLength;
  72. ItemCount styleObjectIndex;
  73. };
  74. typedef struct ATSUStyleRunInfo ATSUStyleRunInfo;
  75. /* ---------------------------------------------------------------------------- */
  76. /* 'ustl' structure data structures and definitions */
  77. /* ---------------------------------------------------------------------------- */
  78. /*
  79. The 'ustl' data structure follows this format:
  80. 1. Main Data Structure Block Header
  81. 2. Flattened Text Layout Data
  82. 3. Flattened Style Run Data
  83. 4. Flattened Style Data
  84. Per the 'ustl' spec, these structures should maintain four-byte alignment.
  85. For things that are variable width (such as font names), padding bytes must
  86. be added to ensure that this alignment is always kept.
  87. */
  88. /*
  89. structure versioning - the version of the 'ustl' that the ATSUI parsing
  90. and generating functions will handle is version 2 or greater. Earlier
  91. versions were not completly specified and have been obsoleted.
  92. */
  93. enum {
  94. kATSFlatDataUstlVersion0 = 0,
  95. kATSFlatDataUstlVersion1 = 1,
  96. kATSFlatDataUstlVersion2 = 2,
  97. kATSFlatDataUstlCurrentVersion = kATSFlatDataUstlVersion2
  98. };
  99. /* ------------------ */
  100. /* Block 1 Structures */
  101. /* ------------------ */
  102. /*
  103. This is the main data structure block header. It describes the rest
  104. of the data and how it is structured.
  105. */
  106. struct ATSFlatDataMainHeaderBlock {
  107. /* the 'ustl' version number. This needs to be the first item in the*/
  108. /* data block do as not to confuse parsers of earlier (and possibly*/
  109. /* later) versions of the spec *|*/
  110. UInt32 version;
  111. /* the total size of the stream in bytes, including the four bytes in*/
  112. /* the version above*/
  113. ByteCount sizeOfDataBlock;
  114. /* offset from the beginning of the stream to the flattened text layout data.*/
  115. /* This can be set to 0 if there are no text layouts stored in the stream.*/
  116. ByteCount offsetToTextLayouts;
  117. /* offset from the beginning of the stream to the flattened style run data. */
  118. /* This can be set to 0 if there is no flattened style run data in the stream*/
  119. ByteCount offsetToStyleRuns;
  120. /* offset to the flattened style list data. This can be set to 0 if there*/
  121. /* is no flattened style list data*/
  122. ByteCount offsetToStyleList;
  123. };
  124. typedef struct ATSFlatDataMainHeaderBlock ATSFlatDataMainHeaderBlock;
  125. /* ------------------ */
  126. /* Block 2 Structures */
  127. /* ------------------ */
  128. /*
  129. The Block 2 Structures are not currently used by any of ATSUI's internal parsing
  130. or packing routines. They are, however, part of the 'ustl' standard and are put
  131. here for developer conveniance, as well as to properly define the standard.
  132. */
  133. /*
  134. This is the the main header for block 2. If there is a block 2, then there
  135. needs to be one of these. This structure is what the offsetToTextLayouts
  136. points to in block 1.
  137. */
  138. struct ATSFlatDataTextLayoutDataHeader {
  139. /* the total size of this particular flattened text layout, including any*/
  140. /* padding bytes and such. */
  141. ByteCount sizeOfLayoutData;
  142. /* the number of characters covered by this flattened text layout*/
  143. ByteCount textLayoutLength;
  144. /* the byte offset relative to the start of this structure to the flattened*/
  145. /* layout control data. This can be set to zero if there are no layout*/
  146. /* controls.*/
  147. ByteCount offsetToLayoutControls;
  148. /* the byte offset, relative to the start of this structure to the*/
  149. /* flattened line info. This can be set to zero if there is no line info */
  150. /* in this layout.*/
  151. ByteCount offsetToLineInfo;
  152. /* if the offsetToLayoutControls is non-zero, then following this block*/
  153. /* there will be a ATSFlattenedLayoutDataFlattenedLayoutControlsHeader*/
  154. /* followed by an array of ATSFlattenedLayoutDataFlattenedLayoutControls*/
  155. /* structures. If the offsetToLineInfo is non-zero, then following the*/
  156. /* flattened layout controls will be a ATSFlatDataLineInfoHeader*/
  157. /* structure.*/
  158. };
  159. typedef struct ATSFlatDataTextLayoutDataHeader ATSFlatDataTextLayoutDataHeader;
  160. /*
  161. This is the header for the flattened layout controls structure. This is
  162. the structure that a non-zero offsetToLayoutControls points to in the
  163. ATSFlatDataTextLayoutDataHeader
  164. */
  165. struct ATSFlatDataLayoutControlsDataHeader {
  166. /* the number of flattened layout controls. It is suggested that there be*/
  167. /* at least one layout control to output the line direction for the layout*/
  168. ItemCount numberOfLayoutControls;
  169. /* first of possibly many flattened layout controls. There should be one */
  170. /* of these for each layout control as determined by the*/
  171. /* numberOfLayoutControls above. Of course, if there are no layout controls,*/
  172. /* then this structure shouldn't even exist. Each attribute info structure*/
  173. /* in the array could be followed by additional padding bytes in order*/
  174. /* to maintain four-byte alignment. These padding bytes are not to be*/
  175. /* included in the fValueSize member of each structure. */
  176. ATSUAttributeInfo controlArray[1];
  177. };
  178. typedef struct ATSFlatDataLayoutControlsDataHeader ATSFlatDataLayoutControlsDataHeader;
  179. struct ATSFlatDataLineInfoData {
  180. /* the length of this particular line in UniChars*/
  181. UniCharCount lineLength;
  182. /* the number of line controls applied to this line. This can be set*/
  183. /* to zero if there are no special line controls applied to this line.*/
  184. ItemCount numberOfLineControls;
  185. /* the numberOfLineControls is non-zero, then following this structure*/
  186. /* must be an array of ATSUAttributeInfo structures. There must be one*/
  187. /* ATSUAttributeInfo structure for each numberOfLineControls above.*/
  188. };
  189. typedef struct ATSFlatDataLineInfoData ATSFlatDataLineInfoData;
  190. /*
  191. This structure is the main data header for the flattened line info data. This
  192. is what a non-zero offsetToLineInfo points to in the
  193. ATSFlatDataTextLayoutDataHeader structure above.
  194. */
  195. struct ATSFlatDataLineInfoHeader {
  196. /* the number of flattened line info structures that are stored in this*/
  197. /* block. This value should really be equal to the number of soft line*/
  198. /* breaks in the layout + 1. Of course if numberOfLines is zero, then*/
  199. /* this structure shouldn't even be used.*/
  200. ItemCount numberOfLines;
  201. /* the first in a array of ATSFlatDataLineInfoData structures. There*/
  202. /* needs to be a ATSFlatDataLineInfoData for each numberOfLines*/
  203. /* specified above.*/
  204. ATSFlatDataLineInfoData lineInfoArray[1];
  205. };
  206. typedef struct ATSFlatDataLineInfoHeader ATSFlatDataLineInfoHeader;
  207. /* ------------------ */
  208. /* Block 3 Structures */
  209. /* ------------------ */
  210. /*
  211. The block 3 structures are used by ATSUI style run flattening and parsing
  212. functions, ATSUFlattenStyleRunsToStream and ATSUUnflattenStyleRunsFromStream
  213. to represent flattened style run information. These structures go hand and
  214. hand with the block 4 structures.
  215. */
  216. /*
  217. This is the data header that appears before the style run data structures.
  218. This structure is what a non-zero offsetToStyleRuns in the
  219. ATSFlatDataMainHeaderBlock points to in block 1.
  220. */
  221. struct ATSFlatDataStyleRunDataHeader {
  222. /* the number of style run data structures stored in this block*/
  223. ItemCount numberOfStyleRuns;
  224. /* the first in an array of ATSUStyleRunInfo structures. There needs to*/
  225. /* be a ATSUStyleRunInfo structure for each numberOfStyleRuns specified*/
  226. /* above. This structure is defined in ATSUnicode.h*/
  227. ATSUStyleRunInfo styleRunArray[1];
  228. };
  229. typedef struct ATSFlatDataStyleRunDataHeader ATSFlatDataStyleRunDataHeader;
  230. /* ------------------ */
  231. /* Block 4 Structures */
  232. /* ------------------ */
  233. /*
  234. The block 4 structures store flattened ATSUStyle objects. This too, is
  235. currently used by the ATSUI style run flattening and parsing functions,
  236. ATSUFlattenStyleRunsToStream and ATSUUnflattenStyleRunsFromStream.
  237. */
  238. /*
  239. this structure forms the beginning of an individually flattened ATSUStyle
  240. object.
  241. */
  242. struct ATSFlatDataStyleListStyleDataHeader {
  243. /* the size of this flattened style object, including these four bytes and*/
  244. /* any padding bytes at the end of the structure. Basically, this can be*/
  245. /* used to determine where the next structure in the array begins.*/
  246. ByteCount sizeOfStyleInfo;
  247. /* the number of attributes set in this flattened style object. This should */
  248. /* be at least one for the font data, although it can be 0 if this is to be*/
  249. /* unspecfied.*/
  250. ItemCount numberOfSetAttributes;
  251. /* the number of font features set in the flattened style object. This can*/
  252. /* be set to 0 if there are no font features set in the style object. */
  253. ItemCount numberOfSetFeatures;
  254. /* the number of font variations set in the flattened style object. This*/
  255. /* can be set to 0 if there are no font variations set in the style object.*/
  256. ItemCount numberOfSetVariations;
  257. /* after this structure header, there is the following data in this block:*/
  258. /* 1. if the numberOfSetAttributes is non-zero, then there will be an*/
  259. /* array of ATSUAttributeInfo structures immediately following the*/
  260. /* above header data to store the style attributes. This is a variable*/
  261. /* structure array. There must be one ATSUAttributeInfo for*/
  262. /* for each numberOfSetAttributes. If numberOfSetAttributes is zero,*/
  263. /* then skip to the next data section 2.*/
  264. /* 2. if the numberOfSetFeatures is non-zero, then there will be an array*/
  265. /* of ATSFlatDataStyleListFeatureData structures immediately after*/
  266. /* the ATSUAttributeInfo array above (if any). There must be one*/
  267. /* ATSFlatDataStyleListFeatureData structure for each */
  268. /* numberOfSetFeatures set in the header above. If numberOfSetFeatures*/
  269. /* is zero, then skip to the next data section 3.*/
  270. /* 3. if the numberOfSetVariations is non-zero, then there will be an*/
  271. /* array of ATSFlatDataStyleListVariationData immediately after the*/
  272. /* ATSFlatDataStyleListFeatureData array above (if any). There must be*/
  273. /* one ATSFlatDataStyleListVariationData structure for each */
  274. /* numberOfSetVariations set in the header above.*/
  275. };
  276. typedef struct ATSFlatDataStyleListStyleDataHeader ATSFlatDataStyleListStyleDataHeader;
  277. /*
  278. this structure is the main header for this block. This structure is what a
  279. non-zero offsetToStyleList in the ATSFlatDataMainHeaderBlock points to in
  280. block 1.
  281. */
  282. struct ATSFlatDataStyleListHeader {
  283. /* the total number of flattened style objects stored in this block*/
  284. ItemCount numberOfStyles;
  285. /* the first in an array of flattned style entries. The data stored*/
  286. /* in them is variably sized, so a simply array access won't do for*/
  287. /* iterating through these. However, there must be one of these*/
  288. /* ATSFlatDataStyleListStyleDataHeader structures for each */
  289. /* numberOfStyles above.*/
  290. ATSFlatDataStyleListStyleDataHeader styleDataArray[1];
  291. };
  292. typedef struct ATSFlatDataStyleListHeader ATSFlatDataStyleListHeader;
  293. /*
  294. this structure stores flattened font feature data. An array of these comes
  295. after the array of font data attributes (if any) if the numberOfSetFeatures is
  296. non-zero. There must be one of these structures for each numberOfSetFeatures.
  297. */
  298. struct ATSFlatDataStyleListFeatureData {
  299. /* the font feature type*/
  300. ATSUFontFeatureType theFeatureType;
  301. /* the font feature selector*/
  302. ATSUFontFeatureSelector theFeatureSelector;
  303. };
  304. typedef struct ATSFlatDataStyleListFeatureData ATSFlatDataStyleListFeatureData;
  305. /*
  306. this structure stores the flattened font variation data. An array of these
  307. comes after the array of ATSFlatDataStyleListFeatureData structures (if any)
  308. if the numberOfSetVariations is non-zero. There must be one of these
  309. structures for each numberOfSetFeatures.
  310. */
  311. struct ATSFlatDataStyleListVariationData {
  312. /* the variation axis*/
  313. ATSUFontVariationAxis theVariationAxis;
  314. /* the variation value*/
  315. ATSUFontVariationValue theVariationValue;
  316. };
  317. typedef struct ATSFlatDataStyleListVariationData ATSFlatDataStyleListVariationData;
  318. /* ------------------------ */
  319. /* Flattened Font Data Info */
  320. /* ------------------------ */
  321. /*
  322. This is somewhat of an addendum to the 'ustl' structure above. These flattened
  323. data structures are stored in block 4 as a font attribute with the attribute
  324. tag of kATSUFontTag. They can store font data in a few different ways, such as
  325. by a FontSync reference or by simple raw font name data. Just as with the
  326. 'ustl' above, this structure must maintain four byte alignment.
  327. */
  328. /* these are the currenly supported font specifiers. */
  329. typedef UInt32 ATSFlatDataFontSpeciferType;
  330. enum {
  331. /* this specifier allows the storage of font data based on name data. This*/
  332. /* uses the stuctures below to store the actual data itself.*/
  333. kATSFlattenedFontSpecifierRawNameData = FOUR_CHAR_CODE('namd')
  334. };
  335. /*
  336. this is the main header for the font data. It dictates what type of data
  337. is stored. The actual data stored must match the type specified by the
  338. nameSpecType.
  339. */
  340. struct ATSFlatDataFontNameDataHeader {
  341. /* the type of data that is flattened in this structure*/
  342. ATSFlatDataFontSpeciferType nameSpecifierType;
  343. /* the size of the data that is flattened in this structre, not including */
  344. /* any padding bytes that may be necessary to achive the four byte */
  345. /* alignment of the data, unless they are specified as part of structure, */
  346. /* such as with the ATSFlatDataFontSpecRawNameData structure.*/
  347. ByteCount nameSpecifierSize;
  348. /* after this header comes the flattened font name data which matches*/
  349. /* the type specified by the nameSpecifierType above. For instance, if */
  350. /* the nameSpecType is kATSFlattenedFontNameSpecifierRawNameData, the*/
  351. /* structure that immediately follows this would be a*/
  352. /* ATSFlatDataFontNameRawNameDataHeader structure. */
  353. };
  354. typedef struct ATSFlatDataFontNameDataHeader ATSFlatDataFontNameDataHeader;
  355. /*
  356. the next two structures are only used when the nameSpecType is set to
  357. kATSFlattenedFontSpecifierRawNameData. They are setup to store multiple
  358. font name table entries for the purposes of reconstructing an ATSUFontID
  359. for (hopefully) the same font some time in the future.
  360. */
  361. /* this is the structure in which raw font name data is actually stored. */
  362. struct ATSFlatDataFontSpecRawNameData {
  363. /* the type of name being specified*/
  364. FontNameCode fontNameType;
  365. /* the platform type of the font name, whether it be Unicode, Mac, etc. */
  366. /* This should be specified if known. If not known, then specify*/
  367. /* kFontNoPlatform, but then all matching will be done based on the first*/
  368. /* font in the name table matching the other parameters.*/
  369. FontPlatformCode fontNamePlatform;
  370. /* the script code of the font's name based on the platform that was passed*/
  371. /* in above. If set to kFontNoScript, then the name will be matched based*/
  372. /* on the first font in the name table matching the other font name*/
  373. /* parameters.*/
  374. FontScriptCode fontNameScript;
  375. /* the language of the font name. If set to kFontNoLanguage, then the name */
  376. /* will be matched based on the first font in the name table matching the*/
  377. /* other font name parameters.*/
  378. FontLanguageCode fontNameLanguage;
  379. /* the length of the font name in bytes, not including any padding bytes*/
  380. /* added to maintain the four byte alignment*/
  381. ByteCount fontNameLength;
  382. /* after the name length comes the actual font name data itself, plus any*/
  383. /* padding bytes needed to maintain the four byte alignment.*/
  384. };
  385. typedef struct ATSFlatDataFontSpecRawNameData ATSFlatDataFontSpecRawNameData;
  386. /*
  387. this is a header structure that defines some things constant throughout
  388. the entire search for the font name, as well as the array of
  389. ATSFlatDataFontNameData structures. In order to gaurantee that the same font
  390. will be used, more than one name specifer should be stored. The standard ATSUI
  391. style run flattening and parsing functions, ATSUFlattenStyleRunsToStream and
  392. ATSUUnflattenStyleRunsFromStream. These will store both the font's full name
  393. (kFontFullName) as well as the font's manufacturer name (kFontManufacturerName)
  394. and match fonts based on both of
  395. these.
  396. */
  397. struct ATSFlatDataFontSpecRawNameDataHeader {
  398. /* the number of flattened font names. There must be at least one flattened */
  399. /* font name, otherwise the structure is malformed.*/
  400. ItemCount numberOfFlattenedNames;
  401. /* the first in an array of possibly many font name specifiers - depending*/
  402. /* on how specific the caller wants this. There must be one */
  403. /* ATSFlatDataFontNameData structure for each numberOfFlattenedNames*/
  404. /* above.*/
  405. ATSFlatDataFontSpecRawNameData nameDataArray[1];
  406. };
  407. typedef struct ATSFlatDataFontSpecRawNameDataHeader ATSFlatDataFontSpecRawNameDataHeader;
  408. /* ---------------------------------------------------------------------------- */
  409. /* Style Flattening and Parsing Functions */
  410. /* ---------------------------------------------------------------------------- */
  411. /*
  412. * ATSUFlattenStyleRunsToStream()
  413. *
  414. * Availability:
  415. * Non-Carbon CFM: not available
  416. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  417. * Mac OS X: in version 10.2 and later
  418. */
  419. EXTERN_API_C( OSStatus )
  420. ATSUFlattenStyleRunsToStream(
  421. ATSUFlattenedDataStreamFormat iStreamFormat,
  422. ATSUFlattenStyleRunOptions iFlattenOptions,
  423. ItemCount iNumberOfRunInfo,
  424. const ATSUStyleRunInfo iRunInfoArray[],
  425. ItemCount iNumberOfStyleObjects,
  426. const ATSUStyle iStyleArray[],
  427. ByteCount iStreamBufferSize,
  428. void * oStreamBuffer,
  429. ByteCount * oActualStreamBufferSize);
  430. /*
  431. * ATSUUnflattenStyleRunsFromStream()
  432. *
  433. * Availability:
  434. * Non-Carbon CFM: not available
  435. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  436. * Mac OS X: in version 10.2 and later
  437. */
  438. EXTERN_API_C( OSStatus )
  439. ATSUUnflattenStyleRunsFromStream(
  440. ATSUFlattenedDataStreamFormat iStreamFormat,
  441. ATSUUnFlattenStyleRunOptions iUnflattenOptions,
  442. ByteCount iStreamBufferSize,
  443. const void * iStreamBuffer,
  444. ItemCount iNumberOfRunInfo,
  445. ItemCount iNumberOfStyleObjects,
  446. ATSUStyleRunInfo oRunInfoArray[],
  447. ATSUStyle oStyleArray[],
  448. ItemCount * oActualNumberOfRunInfo,
  449. ItemCount * oActualNumberOfStyleObjects);
  450. #if PRAGMA_STRUCT_ALIGN
  451. #pragma options align=reset
  452. #elif PRAGMA_STRUCT_PACKPUSH
  453. #pragma pack(pop)
  454. #elif PRAGMA_STRUCT_PACK
  455. #pragma pack()
  456. #endif
  457. #ifdef PRAGMA_IMPORT_OFF
  458. #pragma import off
  459. #elif PRAGMA_IMPORT
  460. #pragma import reset
  461. #endif
  462. #ifdef __cplusplus
  463. }
  464. #endif
  465. #endif /* __ATSUNICODEFLATTENING__ */