home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / WorldScript.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  9.4 KB  |  362 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1994-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __WORLDSCRIPT__
  18. #define __WORLDSCRIPT__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __TRAPS__
  24. #include <Traps.h>
  25. #endif
  26. #ifndef __QUICKDRAWTEXT__
  27. #include <QuickdrawText.h>
  28. #endif
  29.  
  30.  
  31.  
  32. #if PRAGMA_ONCE
  33. #pragma once
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43.  
  44. #if PRAGMA_STRUCT_ALIGN
  45.     #pragma options align=mac68k
  46. #elif PRAGMA_STRUCT_PACKPUSH
  47.     #pragma pack(push, 2)
  48. #elif PRAGMA_STRUCT_PACK
  49.     #pragma pack(2)
  50. #endif
  51.  
  52. typedef UInt16                             WSIOffset;
  53. typedef UInt8                             WSIByteCount;
  54. typedef UInt8                             WSIByteIndex;
  55. /* offset from start of sub-table to row in state table */
  56. typedef UInt16                             WSIStateOffset;
  57. typedef UInt32                             WSITableOffset;
  58. typedef UInt16                             WSISubtableOffset;
  59. typedef UInt16                             WSIGlyphcode;
  60. typedef UInt32                             WSITableIdentifiers;
  61.  
  62. enum {
  63.     kScriptSettingsTag            = FOUR_CHAR_CODE('info'),
  64.     kMetamorphosisTag            = FOUR_CHAR_CODE('mort'),
  65.     kGlyphExpansionTag            = FOUR_CHAR_CODE('g2g#'),
  66.     kPropertiesTag                = FOUR_CHAR_CODE('prop'),
  67.     kJustificationTag            = FOUR_CHAR_CODE('kash'),
  68.     kCharToGlyphTag                = FOUR_CHAR_CODE('cmap'),
  69.     kGlyphToCharTag                = FOUR_CHAR_CODE('pamc'),
  70.     kFindScriptRunTag            = FOUR_CHAR_CODE('fstb')
  71. };
  72.  
  73.  
  74.  
  75. /****             L O O K U P    T A B L E    T Y P E S        ****/
  76.  
  77. enum {
  78.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  79.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  80.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  81.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  82.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  83. };
  84.  
  85. typedef unsigned short                     WSILookupTableFormat;
  86. typedef unsigned short                     WSILookupValue;
  87. /* An offset from the beginning of the lookup table */
  88. typedef unsigned short                     WSILookupOffset;
  89. /*    FORMAT SPECIFIC DEFINITIONS */
  90. /*
  91.         lookupSimpleArray:
  92.         
  93.         This is a simple array which maps all glyphs in the font
  94.         to lookup values.
  95.     */
  96.  
  97. struct WSILookupArrayHeader {
  98.     WSILookupValue                     lookupValues[1];            /* The array of values indexed by glyph code */
  99. };
  100. typedef struct WSILookupArrayHeader        WSILookupArrayHeader;
  101. /*
  102.         lookupTrimmedArray:
  103.         
  104.         This is a single trimmed array which maps a single range
  105.         of glyhs in the font to lookup values.
  106.     */
  107.  
  108. struct WSILookupTrimmedArrayHeader {
  109.     WSIGlyphcode                     firstGlyph;
  110.     WSIGlyphcode                     limitGlyph;
  111.     WSILookupValue                     valueArray[1];
  112. };
  113. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  114. /* The format specific part of the subtable header */
  115.  
  116. union WSILookupFormatSpecificHeader {
  117.     WSILookupArrayHeader             simpleArray;                /* rename lookupArray as simpleArray <9> */
  118.     WSILookupTrimmedArrayHeader     trimmedArray;
  119. };
  120. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  121. /* The overall subtable header */
  122.  
  123. struct WSILookupTableHeader {
  124.     WSILookupTableFormat             format;                        /* table format */
  125.     WSILookupFormatSpecificHeader     fsHeader;                    /* format specific header */
  126. };
  127. typedef struct WSILookupTableHeader        WSILookupTableHeader;
  128.  
  129. /****        G L Y P H    E X P A N S I O N    ****/
  130.  
  131. enum {
  132.                                                                 /* fixed 1.0 */
  133.     kCurrentGlyphExpansionVersion = 0x00010000
  134. };
  135.  
  136.  
  137. typedef unsigned short                     GlyphExpansionFormats;
  138.  
  139. enum {
  140.     GlyphExpansionLookupFormat    = 1,
  141.     GlyphExpansionContextualFormat = 2
  142. };
  143.  
  144.  
  145. struct ExpandedGlyphCluster {
  146.     WSIByteCount                     numGlyphs;
  147.     WSIByteIndex                     bestGlyph;
  148.     WSIGlyphcode                     glyphs[1];
  149. };
  150. typedef struct ExpandedGlyphCluster        ExpandedGlyphCluster;
  151.  
  152. struct ExpandedGlyphOffset {
  153.     WSIGlyphcode                     glyph;
  154.     WSIOffset                         offset;                        /* offset to ExpandedGlyphCluster */
  155. };
  156. typedef struct ExpandedGlyphOffset        ExpandedGlyphOffset;
  157.  
  158. struct GlyphExpansionStateTable {
  159.     WSISubtableOffset                 stateTableOffset;
  160.     WSISubtableOffset                 classTableOffset;
  161.     WSISubtableOffset                 actionTableOffset;            /* state, class and actions tables follow here... */
  162. };
  163. typedef struct GlyphExpansionStateTable    GlyphExpansionStateTable;
  164.  
  165. struct GlyphExpansionTable {
  166.     Fixed                             version;
  167.     short                             format;
  168.     short                             expansionNumer;
  169.     short                             expansionDenom;                /* num/denom ratio for expansion <2> */
  170.  
  171.     union {
  172.         GlyphExpansionStateTable         stateTable;
  173.         WSILookupTableHeader             lookup;                    /* expanded glyph clusters follow here... */
  174.     }                                 table;
  175. };
  176. typedef struct GlyphExpansionTable        GlyphExpansionTable;
  177.  
  178. /* Glyph-to-Character constants and types  */
  179.  
  180. enum {
  181.     kCurrentGlyphToCharVersion    = 0x00010100
  182. };
  183.  
  184.  
  185. typedef unsigned short                     GlyphToCharLookupFormats;
  186.  
  187. enum {
  188.     kGlyphToCharLookup8Format    = 1,
  189.     kGlyphToCharLookup16Format    = 2,
  190.     kGlyphToCharLookup32Format    = 3
  191. };
  192.  
  193. typedef UInt8                             GlyphToCharFontIndex;
  194. typedef UInt8                             QDGlyphcode;
  195.  
  196. struct GlyphToCharActionTable {
  197.     WSISubtableOffset                 fontNameOffset;                /* offset relative to this table */
  198.     WSILookupTableHeader             actions;                    /* only support lookupSimpleArray format for now */
  199. };
  200. typedef struct GlyphToCharActionTable    GlyphToCharActionTable;
  201.  
  202. struct GlyphToCharActionHeader {
  203.     short                             numTables;                    /* 0..n */
  204.     WSISubtableOffset                 offsets[1];                    /* offsets from start of action table header */
  205. };
  206. typedef struct GlyphToCharActionHeader    GlyphToCharActionHeader;
  207.  
  208. struct GlyphToCharHeader {
  209.     Fixed                             version;
  210.  
  211.     WSISubtableOffset                 actionOffset;                /* offset to GlyphToCharActionHeader */
  212.  
  213.     short                             format;                        /* size of font mask */
  214.     WSILookupTableHeader             mappingTable;
  215. };
  216. typedef struct GlyphToCharHeader        GlyphToCharHeader;
  217.  
  218. /* JUSTIFICATION TYPES
  219.     WorldScript supports justification of text using insertion. The justification
  220.     table specifies a insertion string to insert between 2 specified glyphs.
  221.     Each combination of inter-glyph boundary can be assigned a justification priority,
  222.     the higher the priority the more justification strings inserted at that position.
  223.     
  224.     The priorities for each inter-glyph boundary are specified by the justification table's
  225.     state table.
  226.     
  227.     Special handling is done for scripts which use spaces to justify, because the width of 
  228.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  229.     per inserting string is specified in the justification table.
  230.  
  231. */
  232.  
  233. enum {
  234.                                                                 /* 1.0 not supported */
  235.     kCurrentJustificationVersion = 0x0200
  236. };
  237.  
  238.  
  239. enum {
  240.     kJustificationStateTableFormat = 1
  241. };
  242.  
  243.  
  244. enum {
  245.                                                                 /* WSI's internal limitation <12> */
  246.     kMaxJustificationStringLength = 13
  247. };
  248.  
  249.  
  250. typedef UInt8                             WSIJustificationPriority;
  251.  
  252. enum {
  253.     WSIJustificationSetMarkMask    = 0x80
  254. };
  255.  
  256.  
  257. struct WSIJustificationStateEntry {
  258.     WSIJustificationPriority         markPriority;                /* non-zero priorities means insertion */
  259.     WSIJustificationPriority         priority;
  260.     WSIStateOffset                     newState;
  261. };
  262. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  263.  
  264. typedef unsigned short                     WSIJustificationClasses;
  265.  
  266. enum {
  267.     wsiJustEndOfLineClass        = 0,
  268.     wsiJustEndOfRunClass        = 1,
  269.     wsiJustDeletedGlyphClass    = 2,
  270.     wsiJustUserDefinedClass        = 3
  271. };
  272.  
  273. typedef unsigned short                     WSIJustificationStates;
  274.  
  275. enum {
  276.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  277.     wsiStartOfRunState            = 1,
  278.     wsiUserDefinedState            = 2
  279. };
  280.  
  281. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  282. typedef UInt8                             WSIJustificationClassOffset;
  283.  
  284. struct WSIJustificationStateTable {
  285.     short                             maxPriorities;
  286.     unsigned short                     rowWidth;                    /* width of a state table row in bytes */
  287.     short                             classTableOffset;
  288.     short                             stateTableOffset;
  289. };
  290. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  291. /*
  292.             Last two fields of above structure - someday?
  293.             WSIJustificationClassOffset    classes[up to 64 classes supported];
  294.             WSIJustificationStateEntry    states[up to your heart's desire];
  295.         */
  296.  
  297. struct WSIJustificationHeader {
  298.     short                             version;
  299.     short                             format;
  300.  
  301.     Point                             scaling;                    /* numer/denom scaling of priority weights <7> */
  302.  
  303.     unsigned short                     spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  304.     unsigned short                     justStringOffset;            /* offset to justification string */
  305.  
  306.  
  307.     WSIJustificationStateTable         stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  308. };
  309. typedef struct WSIJustificationHeader    WSIJustificationHeader;
  310.  
  311. /* Line Layout's Property table version <11> */
  312.  
  313. enum {
  314.                                                                 /* v1.0 */
  315.     currentPropsTableVersion    = 0x00010000
  316. };
  317.  
  318.  
  319. enum {
  320.                                                                 /* version is octal 0100 or hex 0x40 (#64) */
  321.     kCharToGlyphCurrentVersion    = 0x40
  322. };
  323.  
  324. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  325.  
  326. enum {
  327.     kScriptsDefaultJustWeight    = -1
  328. };
  329.  
  330.  
  331. /* feature selectors used in FindScriptRun and itl5 configuration tables <9> */
  332.  
  333. typedef UInt16                             WSIFeatureType;
  334. typedef UInt16                             WSIFeatureSelector;
  335.  
  336. struct WSIFeature {
  337.     WSIFeatureType                     featureType;
  338.     WSIFeatureSelector                 featureSelector;
  339. };
  340. typedef struct WSIFeature                WSIFeature;
  341.  
  342. #if PRAGMA_STRUCT_ALIGN
  343.     #pragma options align=reset
  344. #elif PRAGMA_STRUCT_PACKPUSH
  345.     #pragma pack(pop)
  346. #elif PRAGMA_STRUCT_PACK
  347.     #pragma pack()
  348. #endif
  349.  
  350. #ifdef PRAGMA_IMPORT_OFF
  351. #pragma import off
  352. #elif PRAGMA_IMPORT
  353. #pragma import reset
  354. #endif
  355.  
  356. #ifdef __cplusplus
  357. }
  358. #endif
  359.  
  360. #endif /* __WORLDSCRIPT__ */
  361.  
  362.