WorldScript.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:12k
源码类别:

多媒体编程

开发平台:

Visual C++

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