WorldScript.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. {
  2. File: WorldScript.p
  3. Contains: WorldScript I Interfaces.
  4. Version: Technology: System 7.5
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1994-2002 by Apple Computer, Inc., all rights reserved.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit WorldScript;
  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,QuickdrawText;
  92. {$ALIGN MAC68K}
  93. type
  94. WSIOffset = UInt16;
  95. WSIByteCount = UInt8;
  96. WSIByteIndex = UInt8;
  97. { offset from start of sub-table to row in state table }
  98. WSIStateOffset = UInt16;
  99. WSITableOffset = UInt32;
  100. WSISubtableOffset = UInt16;
  101. WSIGlyphcode = UInt16;
  102. WSITableIdentifiers = UInt32;
  103. const
  104. kScriptSettingsTag = $696E666F (* 'info' *);
  105. kMetamorphosisTag = $6D6F7274 (* 'mort' *);
  106. kGlyphExpansionTag = $67326723 (* 'g2g#' *);
  107. kPropertiesTag = $70726F70 (* 'prop' *);
  108. kJustificationTag = $6B617368 (* 'kash' *);
  109. kCharToGlyphTag = $636D6170 (* 'cmap' *);
  110. kGlyphToCharTag = $70616D63 (* 'pamc' *);
  111. kFindScriptRunTag = $66737462 (* 'fstb' *);
  112. { *** L O O K U P T A B L E T Y P E S *** }
  113. WSILookupSimpleArray = 0; { a simple array indexed by glyph code }
  114. WSILookupSegmentSingle = 2; { segment mapping to single value }
  115. WSILookupSegmentArray = 4; { segment mapping to lookup array }
  116. WSILookupSingleTable = 6; { sorted list of glyph, value pairs }
  117. WSILookupTrimmedArray = 8; { a simple trimmed array indexed by glyph code }
  118. type
  119. WSILookupTableFormat = UInt16;
  120. WSILookupValue = UInt16;
  121. { An offset from the beginning of the lookup table }
  122. WSILookupOffset = UInt16;
  123. { FORMAT SPECIFIC DEFINITIONS }
  124. {
  125. lookupSimpleArray:
  126. This is a simple array which maps all glyphs in the font
  127. to lookup values.
  128. }
  129. WSILookupArrayHeaderPtr = ^WSILookupArrayHeader;
  130. WSILookupArrayHeader = record
  131. lookupValues: array [0..0] of WSILookupValue; { The array of values indexed by glyph code }
  132. end;
  133. {
  134. lookupTrimmedArray:
  135. This is a single trimmed array which maps a single range
  136. of glyhs in the font to lookup values.
  137. }
  138. WSILookupTrimmedArrayHeaderPtr = ^WSILookupTrimmedArrayHeader;
  139. WSILookupTrimmedArrayHeader = record
  140. firstGlyph: WSIGlyphcode;
  141. limitGlyph: WSIGlyphcode;
  142. valueArray: array [0..0] of WSILookupValue;
  143. end;
  144. { The format specific part of the subtable header }
  145. WSILookupFormatSpecificHeaderPtr = ^WSILookupFormatSpecificHeader;
  146. WSILookupFormatSpecificHeader = record
  147. case SInt16 of
  148. 0: (
  149. simpleArray: WSILookupArrayHeader; { rename lookupArray as simpleArray <9> }
  150. );
  151. 1: (
  152. trimmedArray: WSILookupTrimmedArrayHeader;
  153. );
  154. end;
  155. { The overall subtable header }
  156. WSILookupTableHeaderPtr = ^WSILookupTableHeader;
  157. WSILookupTableHeader = record
  158. format: WSILookupTableFormat; { table format }
  159. fsHeader: WSILookupFormatSpecificHeader; { format specific header }
  160. end;
  161. { *** G L Y P H E X P A N S I O N *** }
  162. const
  163. { fixed 1.0 }
  164. kCurrentGlyphExpansionVersion = $00010000;
  165. type
  166. GlyphExpansionFormats = UInt16;
  167. const
  168. GlyphExpansionLookupFormat = 1;
  169. GlyphExpansionContextualFormat = 2;
  170. type
  171. ExpandedGlyphClusterPtr = ^ExpandedGlyphCluster;
  172. ExpandedGlyphCluster = packed record
  173. numGlyphs: WSIByteCount;
  174. bestGlyph: WSIByteIndex;
  175. glyphs: array [0..0] of WSIGlyphcode;
  176. end;
  177. ExpandedGlyphOffsetPtr = ^ExpandedGlyphOffset;
  178. ExpandedGlyphOffset = record
  179. glyph: WSIGlyphcode;
  180. offset: WSIOffset; { offset to ExpandedGlyphCluster }
  181. end;
  182. GlyphExpansionStateTablePtr = ^GlyphExpansionStateTable;
  183. GlyphExpansionStateTable = record
  184. stateTableOffset: WSISubtableOffset;
  185. classTableOffset: WSISubtableOffset;
  186. actionTableOffset: WSISubtableOffset; { state, class and actions tables follow here... }
  187. end;
  188. GlyphExpansionTablePtr = ^GlyphExpansionTable;
  189. GlyphExpansionTable = record
  190. version: Fixed;
  191. format: SInt16;
  192. expansionNumer: SInt16;
  193. expansionDenom: SInt16; { num/denom ratio for expansion <2> }
  194. case SInt16 of
  195. 0: (
  196. stateTable: GlyphExpansionStateTable;
  197. );
  198. 1: (
  199. lookup: WSILookupTableHeader; { expanded glyph clusters follow here... }
  200. );
  201. end;
  202. { Glyph-to-Character constants and types }
  203. const
  204. kCurrentGlyphToCharVersion = $00010100;
  205. type
  206. GlyphToCharLookupFormats = UInt16;
  207. const
  208. kGlyphToCharLookup8Format = 1;
  209. kGlyphToCharLookup16Format = 2;
  210. kGlyphToCharLookup32Format = 3;
  211. type
  212. GlyphToCharFontIndex = UInt8;
  213. QDGlyphcode = UInt8;
  214. GlyphToCharActionTablePtr = ^GlyphToCharActionTable;
  215. GlyphToCharActionTable = record
  216. fontNameOffset: WSISubtableOffset; { offset relative to this table }
  217. actions: WSILookupTableHeader; { only support lookupSimpleArray format for now }
  218. end;
  219. GlyphToCharActionHeaderPtr = ^GlyphToCharActionHeader;
  220. GlyphToCharActionHeader = record
  221. numTables: SInt16; { 0..n }
  222. offsets: array [0..0] of WSISubtableOffset; { offsets from start of action table header }
  223. end;
  224. GlyphToCharHeaderPtr = ^GlyphToCharHeader;
  225. GlyphToCharHeader = record
  226. version: Fixed;
  227. actionOffset: WSISubtableOffset; { offset to GlyphToCharActionHeader }
  228. format: SInt16; { size of font mask }
  229. mappingTable: WSILookupTableHeader;
  230. end;
  231. { JUSTIFICATION TYPES
  232. WorldScript supports justification of text using insertion. The justification
  233. table specifies a insertion string to insert between 2 specified glyphs.
  234. Each combination of inter-glyph boundary can be assigned a justification priority,
  235. the higher the priority the more justification strings inserted at that position.
  236. The priorities for each inter-glyph boundary are specified by the justification table's
  237. state table.
  238. Special handling is done for scripts which use spaces to justify, because the width of
  239. a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  240. per inserting string is specified in the justification table.
  241. }
  242. const
  243. { 1.0 not supported }
  244. kCurrentJustificationVersion = $0200;
  245. kJustificationStateTableFormat = 1;
  246. { WSI's internal limitation <12> }
  247. kMaxJustificationStringLength = 13;
  248. type
  249. WSIJustificationPriority = UInt8;
  250. const
  251. WSIJustificationSetMarkMask = $80;
  252. type
  253. WSIJustificationStateEntryPtr = ^WSIJustificationStateEntry;
  254. WSIJustificationStateEntry = packed record
  255. markPriority: WSIJustificationPriority; { non-zero priorities means insertion }
  256. priority: WSIJustificationPriority;
  257. newState: WSIStateOffset;
  258. end;
  259. WSIJustificationClasses = UInt16;
  260. const
  261. wsiJustEndOfLineClass = 0;
  262. wsiJustEndOfRunClass = 1;
  263. wsiJustDeletedGlyphClass = 2;
  264. wsiJustUserDefinedClass = 3;
  265. type
  266. WSIJustificationStates = UInt16;
  267. const
  268. wsiStartOfLineState = 0; { pre-defined states }
  269. wsiStartOfRunState = 1;
  270. wsiUserDefinedState = 2;
  271. { pre-multiplied: class# * sizeof(WSIJustificationStateEntry) }
  272. type
  273. WSIJustificationClassOffset = UInt8;
  274. WSIJustificationStateTablePtr = ^WSIJustificationStateTable;
  275. WSIJustificationStateTable = record
  276. maxPriorities: SInt16;
  277. rowWidth: UInt16; { width of a state table row in bytes }
  278. classTableOffset: SInt16;
  279. stateTableOffset: SInt16;
  280. end;
  281. {
  282. Last two fields of above structure - someday?
  283. WSIJustificationClassOffset classes[up to 64 classes supported];
  284. WSIJustificationStateEntry states[up to your heart's desire];
  285. }
  286. WSIJustificationHeaderPtr = ^WSIJustificationHeader;
  287. WSIJustificationHeader = record
  288. version: SInt16;
  289. format: SInt16;
  290. scaling: Point; { numer/denom scaling of priority weights <7> }
  291. spacesPerInsertion: UInt16; { # of $20 chars in justification insertion string <12> }
  292. justStringOffset: UInt16; { offset to justification string }
  293. stateTable: WSIJustificationStateTable; { long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows }
  294. end;
  295. { Line Layout's Property table version <11> }
  296. const
  297. { v1.0 }
  298. currentPropsTableVersion = $00010000;
  299. { version is octal 0100 or hex 0x40 (#64) }
  300. kCharToGlyphCurrentVersion = $40;
  301. { pass as priorityWeight to JustifyWSILayout to use script's current just setting }
  302. kScriptsDefaultJustWeight = -1;
  303. { feature selectors used in FindScriptRun and itl5 configuration tables <9> }
  304. type
  305. WSIFeatureType = UInt16;
  306. WSIFeatureSelector = UInt16;
  307. WSIFeaturePtr = ^WSIFeature;
  308. WSIFeature = record
  309. featureType: WSIFeatureType;
  310. featureSelector: WSIFeatureSelector;
  311. end;
  312. {$ALIGN MAC68K}
  313. end.