Leaked source code of windows server 2003
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.

1865 lines
77 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation.
  3. */
  4. #ifndef __usp10__
  5. #define __usp10__
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif
  9. #include <windows.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. ///// Uniscribe build number
  14. #define USPBUILD 0231
  15. ///// USP - Unicode Complex Script processor
  16. //
  17. // Copyright (c) 1996-9, Microsoft Corporation. All rights reserved.
  18. ///// SCRIPT
  19. //
  20. // The SCRIPT enum is an opaque type used internally to identify
  21. // which shaping engine functions are used to process a given run.
  22. //
  23. //
  24. #define SCRIPT_UNDEFINED 0
  25. //
  26. //p SCRIPT_UNDEFINED: This is the only public script ordinal. May be
  27. // forced into the eScript field of a SCRIPT_ANALYSIS to disable shaping.
  28. // SCRIPT_UNDEFINED is supported by all fonts - ScriptShape will display
  29. // whatever glyph is defined in the font CMAP table, or, if none, the
  30. // missing glyph.
  31. ///// USP Status Codes
  32. //
  33. #define USP_E_SCRIPT_NOT_IN_FONT \
  34. MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200) // Script doesn't exist in font
  35. ///// SCRIPT_CACHE
  36. //
  37. // Many script APIs take a combination of HDC and SCRIPT_CACHE parameter.
  38. //
  39. // A SCRIPT_CACHE is an opaque pointer to a Uniscribe font metric cache
  40. // structure.
  41. typedef void *SCRIPT_CACHE;
  42. // The client must allocate and retain one SCRIPT_CACHE variable for each
  43. // character style used. It must be initialised by the client to NULL.
  44. //
  45. // APIs are passed an HDC and the address of a SCRIPT_CACHE variable.
  46. // Uniscribe will first attempt to access font data via the SCRIPT_CACHE
  47. // and will only inspect the HDC if the required data is not already
  48. // cached.
  49. //
  50. // The HDC may be passed as NULL. If data required by Uniscribe is
  51. // already cached, the HDC won't be accessed and operation continues
  52. // normally.
  53. //
  54. // If the HDC is passed as NULL, and Uniscribe needs to access it for
  55. // any reason, Uniscribe will return E_PENDING.
  56. //
  57. // E_PENDING is returned quickly, allowing the client to avoid time
  58. // consuming SelectObject calls. The following example applies to all
  59. // APIs that take a SCRIPT_CACHE and an optional HDC.
  60. //
  61. //c hr = ScriptShape(NULL, &sc, ..);
  62. //c if (hr == E_PENDING) {
  63. //c ... select font into hdc ...
  64. //c hr = ScriptShape(hdc, &sc, ...);
  65. //c }
  66. ///// ScriptFreeCache
  67. //
  68. // The client may free a SCRIPT_CACHE at any time. Uniscribe maintains
  69. // reference counts in it's font and shaper caches, and frees font data
  70. // only when all sizes of the font are free, and shaper data only when
  71. // all fonts it supports are freed.
  72. //
  73. // The client should free the SCRIPT_CACHE for a style when it discards
  74. // that style.
  75. //
  76. // ScriptFreeCache always sets it's parameter to NULL to help avoid
  77. // mis-referencing.
  78. HRESULT WINAPI ScriptFreeCache(
  79. SCRIPT_CACHE *psc); //InOut Cache handle
  80. ///// SCRIPT_CONTROL
  81. //
  82. // The SCRIPT_CONTROL structure provides itemization control flags to the
  83. // ScriptItemize function.
  84. //
  85. //
  86. typedef struct tag_SCRIPT_CONTROL {
  87. DWORD uDefaultLanguage :16; // For NADS, also default for context
  88. DWORD fContextDigits :1; // Means use previous script instead of uDefaultLanguage
  89. // The following flags provide legacy support for GetCharacterPlacement features
  90. DWORD fInvertPreBoundDir :1; // Reading order of virtual item immediately prior to string
  91. DWORD fInvertPostBoundDir :1; // Reading order of virtual item immediately following string
  92. DWORD fLinkStringBefore :1; // Equivalent to presence of ZWJ before string
  93. DWORD fLinkStringAfter :1; // Equivalent to presence of ZWJ after string
  94. DWORD fNeutralOverride :1; // Causes all neutrals to be strong in the current embedding direction
  95. DWORD fNumericOverride :1; // Causes all numerals to be strong in the current embedding direction
  96. DWORD fLegacyBidiClass :1; // Causes plus and minus to be reated as neutrals, slash as a common separator
  97. DWORD fReserved :8;
  98. } SCRIPT_CONTROL;
  99. //
  100. //
  101. //p uDefaultLanguage: Language to use when Unicode values are ambiguous.
  102. // Used by numeric processing to select digit shape when
  103. // fDigitSubstitute (see SCRIPT_STATE) is in force.
  104. //
  105. //p fContextDigits: Specifies that national digits are chosen according to
  106. // the nearest previous strong text, rather than using
  107. // uDefaultLanguage.
  108. //
  109. //p fInvertPreBoundDir: By default text at the start of the string is
  110. // laid out as if it follows strong text of the same direction
  111. // as the base embedding level. Set fInvertPreBoundDir to change
  112. // the initial context to the opposite of the base embedding
  113. // level. This flag is for GetCharacterPlacement legacy support.
  114. //
  115. //p fInvertPostBoundDir: By default text at the end of the string is
  116. // laid out as if it preceeds strong text of the same direction
  117. // as the base embedding level. Set fInvertPostBoundDir to change
  118. // the final context to the opposite of the base embedding
  119. // level. This flag is for GetCharacterPlacement legacy support.
  120. //
  121. //p fLinkStringBefore: Causes the first character of the string to be
  122. // shaped as if were joined to a previous character.
  123. //
  124. //p fLinkStringAfter: Causes the last character of the string to be
  125. // shaped as if were joined to a following character.
  126. //
  127. //p fNeutralOverride: Causes all neutral characters in the string to be
  128. // treated as if they were strong characters of their enclosing
  129. // embedding level. This effectively locks neutrals in place,
  130. // reordering occuring only between neutrals.
  131. //
  132. //p fNumericOverride: Causes all numeric characters in the string to be
  133. // treated as if they were strong characters of their enclosing
  134. // embedding level. This effectively locks numerics in place,
  135. // reordering occuring only between numerics.
  136. //
  137. //p fReserved: Reserved. Always initialise to 0.
  138. ///// SCRIPT_STATE
  139. //
  140. // The SCRIPT_STATE structure is used both to initialise the unicode
  141. // algorithm state as an input parameter to ScriptItemize, and is also
  142. // a component of each item analysis returned by ScriptItemize.
  143. //
  144. //
  145. typedef struct tag_SCRIPT_STATE {
  146. WORD uBidiLevel :5; // Unicode Bidi algorithm embedding level (0-16)
  147. WORD fOverrideDirection :1; // Set when in LRO/RLO embedding
  148. WORD fInhibitSymSwap :1; // Set by U+206A (ISS), cleared by U+206B (ASS)
  149. WORD fCharShape :1; // Set by U+206D (AAFS), cleared by U+206C (IAFS)
  150. WORD fDigitSubstitute :1; // Set by U+206E (NADS), cleared by U+206F (NODS)
  151. WORD fInhibitLigate :1; // Equiv !GCP_Ligate, no Unicode control chars yet
  152. WORD fDisplayZWG :1; // Equiv GCP_DisplayZWG, no Unicode control characters yet
  153. WORD fArabicNumContext :1; // For EN->AN Unicode rule
  154. WORD fGcpClusters :1; // For Generating Backward Compatible GCP Clusters (legacy Apps)
  155. WORD fReserved :1;
  156. WORD fEngineReserved :2; // For use by shaping engine
  157. } SCRIPT_STATE;
  158. //
  159. //
  160. //p uBidiLevel: The embedding level associated with all characters in this
  161. // run according to the Unicode bidi algorithm. When passed to
  162. // ScriptItemize, should be initialised to 0 for an LTR base
  163. // embedding level, or 1 for RTL.
  164. //
  165. //p fOverrideDirection: TRUE if this level is an override level (LRO/RLO).
  166. // In an override level, characters are layed out purely
  167. // left to right, or purely right to left. No reordering of digits
  168. // or strong characters of opposing direction takes place.
  169. // Note that this initial value is reset by LRE, RLE, LRO or
  170. // RLO codes in the string.
  171. //
  172. //p fInhibitSymSwap: TRUE if the shaping engine is to bypass mirroring of
  173. // Unicode Mirrored glyphs such as brackets. Set by Unicode
  174. // character ISS, cleared by ASS.
  175. //
  176. //p fCharShape: TRUE if character codes in the Arabic Presentation Forms
  177. // areas of Unicode should be shaped. (Not implemented).
  178. //
  179. //p fDigitSubstitute: TRUE if character codes U+0030 through U+0039
  180. // (European digits) are to be substituted by national digits.
  181. // Set by Unicode NADS, Cleared by NODS.
  182. //
  183. //p fInhibitLigate: TRUE if ligatures are not to be used in the shaping
  184. // of Arabic or Hebrew characters.
  185. //
  186. //p fDisplayZWG: TRUE if control characters are to be shaped as
  187. // representational glyphs. (Normally, control characters are
  188. // shaped to the blank glyph and given a width of zero).
  189. //
  190. //p fArabicNumContext: TRUE indicates prior strong characters were Arabic
  191. // for the purposes of rule P0 on page 3-19 of 'The Unicode
  192. // Standard, version 2.0'. Should normally be set TRUE before
  193. // itemizing an RTL paragraph in an Arabic language, FALSE
  194. // otherwise.
  195. //
  196. //p fGcpClusters: For GetCharaterPlacement legacy support only.
  197. // Initialise to TRUE to request ScriptShape to generate
  198. // the LogClust array the same way as GetCharacterPlacement
  199. // does in Arabic and Hebrew Windows95. Affects only Arabic
  200. // and Hebrew items.
  201. //
  202. //p fReserved: Reserved. Always initialise to 0.
  203. //
  204. //p fEngineReserved: Reserved. Always initialise to 0.
  205. ///// SCRIPT_ANALYSIS
  206. //
  207. // Each analysed item is described by a SCRIPT_ANALYSIS structure.
  208. // It also includes a copy of the Unicode algorithm state (SCRIPT_STATE).
  209. //
  210. //
  211. typedef struct tag_SCRIPT_ANALYSIS {
  212. WORD eScript :10; // Shaping engine
  213. WORD fRTL :1; // Rendering direction
  214. WORD fLayoutRTL :1; // Set for GCP classes ARABIC/HEBREW and LOCALNUMBER
  215. WORD fLinkBefore :1; // Implies there was a ZWJ before this item
  216. WORD fLinkAfter :1; // Implies there is a ZWJ following this item.
  217. WORD fLogicalOrder :1; // Set by client as input to ScriptShape/Place
  218. WORD fNoGlyphIndex :1; // Generated by ScriptShape/Place - this item does not use glyph indices
  219. SCRIPT_STATE s;
  220. } SCRIPT_ANALYSIS;
  221. //
  222. //
  223. //p eScript: Opaque value identifying which engine Uniscribe will use to
  224. // Shape, Place and TextOut this item. The value of eScript is
  225. // undefined, and will change in future releases, but attributes
  226. // of eScript may be obtained by calling ScriptGetProperties.
  227. //
  228. //p fRTL: Rendering direction. Normally identical to the parity of the
  229. // Unicode embedding level, but may differ if overridden by
  230. // GetCharacterPlacement legacy support.
  231. //
  232. //p fLayoutRTL: Logical direction - whether conceptually part of a
  233. // left-to-right sequenece or a right-to-left sequence. Although
  234. // this is usually the same as fRTL, for a number in a
  235. // right-to-left run, fRTL is False (because digits are always
  236. // displayed LTR), but fLayoutRTL is True (because the number is
  237. // read as part of the right-to-left sequence).
  238. //
  239. //p fLinkBefore: If set, the shaping engine will shape the first character
  240. // of this item as if it were joining with a previous character.
  241. // Set by ScriptItemize, may be overriden before calling ScriptShape.
  242. //
  243. //p fLinkAfter: If set, the shaping engine will shape the last character
  244. // of this item as if it were joining with a subsequient character.
  245. // Set by ScriptItemize, may be overriden before calling ScriptShape.
  246. //
  247. //p fLogicalOrder: If set, the shaping engine will generate all glyph
  248. // related arrays in logical order. By default glyph related
  249. // arrays are in visual order, the first array entry corresponding
  250. // to the leftmost glyph.
  251. // Set to FALSE by ScriptItemize, may be overriden before calling
  252. // ScriptShape.
  253. //
  254. //p fNoGlyphIndex: May be set TRUE on input to ScriptShape to disable use
  255. // of glyphs for this item. Additionally, ScriptShape will set it
  256. // TRUE for hdcs containing symbolic, unrecognised and device fonts.
  257. // Disabling glyphing disables complex script shaping. When set,
  258. // shaping and placing for this item is implemented directly by
  259. // calls to GetTextExtentExPoint and ExtTextOut.
  260. ///// SCRIPT_ITEM
  261. //
  262. // The SCRIPT_ITEM structure includes a SCRIPT_ANALYSIS with the string
  263. // ofset of the first character of the item.
  264. //
  265. //
  266. typedef struct tag_SCRIPT_ITEM {
  267. int iCharPos; // Logical offset to first character in this item
  268. SCRIPT_ANALYSIS a;
  269. } SCRIPT_ITEM;
  270. //
  271. //
  272. //p iCharPos: Offset from beginning of itemised string to first character
  273. // of this item, counted in Unicode codepoints (i.e. words).
  274. //
  275. //p a: Script analysis structure containing analysis specific to this
  276. // item, to be passed to ScriptShape, ScriptPlace etc.
  277. ///// ScriptItemize - break text into items
  278. //
  279. // Breaks a run of unicode into individually shapeable items.
  280. // Items are delimited by
  281. //
  282. // o Change of shaping engine
  283. // o Change of direction
  284. //
  285. // The client may create multiple runs from each item returned by
  286. // ScriptItemize, but should not combine multiple items into a single run.
  287. //
  288. // Later the client will call ScriptShape for each run (when measuring or
  289. // rendering), and must pass the SCRIPT_ANALYSIS that ScriptItemize
  290. // returned.
  291. HRESULT WINAPI ScriptItemize(
  292. const WCHAR *pwcInChars, // In Unicode string to be itemized
  293. int cInChars, // In Codepoint count to itemize
  294. int cMaxItems, // In Max length of itemization array
  295. const SCRIPT_CONTROL *psControl, // In Analysis control (optional)
  296. const SCRIPT_STATE *psState, // In Initial bidi algorithm state (optional)
  297. SCRIPT_ITEM *pItems, // Out Array to receive itemization
  298. int *pcItems); // Out Count of items processed (optional)
  299. /////
  300. //
  301. //
  302. // Returns E_INVALIDARG if pwcInChars == NULL or cInChars == 0
  303. // or pItems == NULL or cMaxItems < 2.
  304. //
  305. // Returns E_OUTOFMEMORY if the output buffer length (cMaxItems) is
  306. // insufficient. Note that in this case, as in all error cases, no
  307. // items have been fully processed so no part of the output array
  308. // contains defined values.
  309. //
  310. // If psControl and psState are NULL on entry, ScriptItemize
  311. // breaks the unicode string purely by character code. If they are all
  312. // non-null, it performs a full Unicode bidi analysis.
  313. //
  314. // ScriptItemize always adds a terminal item to the item analysis array
  315. // (pItems) such that the length of an item at pItem is always available as:
  316. //
  317. //c pItem[1].iCharPos - pItem[0].iCharPos
  318. //
  319. // For this reason, it is invalid to call ScriptItemize with a buffer
  320. // of less than two SCRIPT_ANALYSIS items.
  321. //
  322. // To perform a correct Unicode Bidi analysis, the SCRIPT_STATE should
  323. // be initialised according to the paragraph reading order at paragraph
  324. // start, and ScriptItemize should be passed the whole paragraph.
  325. //
  326. // fRTL and fNumeric together provide the same classification as
  327. // the lpClass output from GetCharacterPlacement.
  328. //
  329. // European digits U+0030 through U+0039 may be rendered as national
  330. // digits as follows:
  331. //
  332. //t fDigitSubstitute | FContextDigits | Digit shapes displayed for Unicode U+0030 through U+0039
  333. //t ---------------- | -------------- | ------------------------------------
  334. //t False | Any | Western (European / American) digits
  335. //t True | False | As specified in SCRIPT_CONTROL.uDefaultLanguage
  336. //t True | True | As prior strong text, defaulting to SCRIPT_CONTROL.uDefaultLanguage
  337. //
  338. //
  339. // For fContextDigits, any Western digits (U+0030 - U+0039) encountered
  340. // before the first strongly directed character are substituted by the
  341. // traditional digits of the SCRIPT_CONTROL.uDefaultLanguage when that
  342. // language is written in the same direction as SCRIPT_STATE.uBidiLevel.
  343. //
  344. // Thus, in a right-to-left string, if SCRIPT_CONTROL.uDefaultLanguage is
  345. // 1 (LANG_ARABIC), then leading Western digits will be substituted by
  346. // traditional Arabic digits.
  347. //
  348. // However, also in a right-to-left string, if SCRIPT_CONTROL.uDefaultLanguage
  349. // is 0x1e (LANG_THAI), then no substitution occurs on leading Western
  350. // digits because the Thai language is written left-to-right.
  351. //
  352. // Following strongly directed characters, digits are substituted
  353. // by the traditional digits associated with the closest prior strongly
  354. // directed character.
  355. //
  356. // The left-to-right mark (LRM) and right-to-left mark (RLM) are strong
  357. // characters whose language depends on the SCRIPT_CONTROL.uDefaultLangauge.
  358. //
  359. // If SCRIPT_CONTROL.uDefaultLangauge is a left-to-right langauge, then
  360. // LRM causes subsequent Western digits to be substituted by the
  361. // traditional digits associated with that language, while Western
  362. // digits following RLM are not substituted.
  363. //
  364. // Conversly, if SCRIPT_CONTROL.uDefaultLangauge is a right-to-left
  365. // langauge, then Western digits following LRM are not substituted, while
  366. // Western digits following RLM are substituted by the traditional digits
  367. // associated with that language.
  368. //
  369. //
  370. //
  371. // Effect of Unicode control characters on SCRIPT_STATE:
  372. //
  373. //t SCRIPT_STATE flag | Set by | Cleared by
  374. //t ----------------- | ------ ----------
  375. //t fDigitSubstitute | NADS | NODS
  376. //t fInhibitSymSwap | ISS | ASS
  377. //t fCharShape | AAFS | IAFS
  378. //
  379. // SCRIPT_STATE.fArabicNumContext controls the Unicode EN->AN rule.
  380. // It should normally be initialised to TRUE
  381. // before itemizing an RTL paragraph in an Arabic language, FALSE
  382. // otherwise.
  383. ///// ScriptLayout
  384. //
  385. // The ScriptLayout function converts an array of run embedding levels to
  386. // a map of visual to logical position, and/or logical to visual position.
  387. //
  388. // pbLevel must contain the embedding levels for all runs on the line,
  389. // ordered logically.
  390. //
  391. // On output, piVisualToLogical[0] is the logical index of the run to
  392. // display at the far left. Subsequent entries should be displayed
  393. // progressing from left to right.
  394. //
  395. // piLogicalToVisual[0] is the relative visual position where the first
  396. // logical run should be displayed - the leftmost display position being zero.
  397. //
  398. // The caller may request either piLogicalToVisual or piVisualToLogical
  399. // or both.
  400. //
  401. // Note: No other input is required since the embedding levels give all
  402. // necessary information for layout.
  403. HRESULT WINAPI ScriptLayout(
  404. int cRuns, // In Number of runs to process
  405. const BYTE *pbLevel, // In Array of run embedding levels
  406. int *piVisualToLogical, // Out List of run indices in visual order
  407. int *piLogicalToVisual); // Out List of visual run positions
  408. ///// SCRIPT_JUSTIFY
  409. //
  410. // The script justification enumeration provides the client with the
  411. // glyph characteristic information it needs to implement justification.
  412. typedef enum tag_SCRIPT_JUSTIFY {
  413. SCRIPT_JUSTIFY_NONE = 0, // Justification can't be applied at this glyph
  414. SCRIPT_JUSTIFY_ARABIC_BLANK = 1, // This glyph represents a blank in an Arabic run
  415. SCRIPT_JUSTIFY_CHARACTER = 2, // Inter-character justification point follows this glyph
  416. SCRIPT_JUSTIFY_RESERVED1 = 3, // Reserved #1
  417. SCRIPT_JUSTIFY_BLANK = 4, // This glyph represents a blank outside an Arabic run
  418. SCRIPT_JUSTIFY_RESERVED2 = 5, // Reserved #2
  419. SCRIPT_JUSTIFY_RESERVED3 = 6, // Reserved #3
  420. SCRIPT_JUSTIFY_ARABIC_NORMAL = 7, // Normal Middle-Of-Word glyph that connects to the right (begin)
  421. SCRIPT_JUSTIFY_ARABIC_KASHIDA = 8, // Kashida(U+640) in middle of word
  422. SCRIPT_JUSTIFY_ARABIC_ALEF = 9, // Final form of Alef-like (U+627, U+625, U+623, U+632)
  423. SCRIPT_JUSTIFY_ARABIC_HA = 10, // Final form of Ha (U+647)
  424. SCRIPT_JUSTIFY_ARABIC_RA = 11, // Final form of Ra (U+631)
  425. SCRIPT_JUSTIFY_ARABIC_BA = 12, // Final form of Ba (U+628)
  426. SCRIPT_JUSTIFY_ARABIC_BARA = 13, // Ligature of alike (U+628,U+631)
  427. SCRIPT_JUSTIFY_ARABIC_SEEN = 14, // Highest priority: Initial shape of Seen(U+633) (end)
  428. SCRIPT_JUSTIFY_RESERVED4 = 15, // Reserved #4
  429. } SCRIPT_JUSTIFY;
  430. ///// SCRIPT_VISATTR
  431. //
  432. // The visual (glyph) attribute buffer generated by ScriptShape
  433. // identifies clusters and justification points:
  434. typedef struct tag_SCRIPT_VISATTR {
  435. WORD uJustification :4; // Justification class
  436. WORD fClusterStart :1; // First glyph of representation of cluster
  437. WORD fDiacritic :1; // Diacritic
  438. WORD fZeroWidth :1; // Blank, ZWJ, ZWNJ etc, with no width
  439. WORD fReserved :1; // General reserved
  440. WORD fShapeReserved :8; // Reserved for use by shaping engines
  441. } SCRIPT_VISATTR;
  442. //
  443. //
  444. //p uJustification: Justification class for this glyph. See SCRIPT_JUSTIFY.
  445. //
  446. //p fClusterStart: Set for the logically first glyph in every cluster,
  447. // even for clusters containing just one glyph.
  448. //
  449. //p fDiacritic: Set for glyphs that combine with base characters.
  450. //
  451. //p fZeroWidth: Set by the shaping engine for some, but not all, zero
  452. // width characters.
  453. ///// ScriptShape
  454. //
  455. // The ScriptShape function takes a Unicode run and generates glyphs and
  456. // visual attributes.
  457. //
  458. // The number of glyphs generated varies according to the script and the
  459. // font. Only for simple scripts and fonts does each Unicode code point
  460. // generates a single glyph.
  461. //
  462. // There is no limit on the number of glyphs generated by a codepoint.
  463. // For example, a sophisticated complex script font might choose to
  464. // constuct characters from components, and so generate many times as
  465. // many glyphs as characters.
  466. //
  467. // There are also special cases like invalid character representations,
  468. // where extra glyphs are added to represent the invalid sequence.
  469. //
  470. // A reasonable guess might be to provide a glyph buffer 1.5 times the
  471. // length of the character buffer, plus a 16 glyph fixed addition for
  472. // rare cases like invalid sequenece representation.
  473. //
  474. // If ScriptShape returns E_OUTOFMEMORY it will be necessary to recall
  475. // it, possibly more than once, until a large enough buffer is found.
  476. HRESULT WINAPI ScriptShape(
  477. HDC hdc, // In Optional (see under caching)
  478. SCRIPT_CACHE *psc, // InOut Cache handle
  479. const WCHAR *pwcChars, // In Logical unicode run
  480. int cChars, // In Length of unicode run
  481. int cMaxGlyphs, // In Max glyphs to generate
  482. SCRIPT_ANALYSIS *psa, // InOut Result of ScriptItemize (may have fNoGlyphIndex set)
  483. WORD *pwOutGlyphs, // Out Output glyph buffer
  484. WORD *pwLogClust, // Out Logical clusters
  485. SCRIPT_VISATTR *psva, // Out Visual glyph attributes
  486. int *pcGlyphs); // Out Count of glyphs generated
  487. /////
  488. //
  489. // Returns E_OUTOFMEMORY if the output buffer length (cMaxGlyphs) is
  490. // insufficient. Note that in this case, as in all error cases, the
  491. // content of the output array is undefined.
  492. //
  493. // Clusters are sequenced uniformly within the run, as are glyphs within
  494. // the cluster - the fRTL item flag (from ScriptItemize) identifies
  495. // whether left to right, or right to left.
  496. //
  497. // ScriptShape may set the fNoGlyphIndex flag in psa if the font or
  498. // OS cannot support glyph indices.
  499. //
  500. // If fLogicalOrder is requested in psa, glyphs will be always be
  501. // generated in the same order as the original Unicode characters.
  502. //
  503. // If fLogicalOrder is not set, right to left items are generated in
  504. // reverse order, so ScriptTextOut does not need to reverse them before
  505. // calling ExtTextOut.
  506. ///// ScriptPlace
  507. //
  508. // The ScriptPlace function takes the output of a ScriptShape call and
  509. // generates glyph advance width and 2D offset information.
  510. //
  511. // The composite ABC width for the whole item identifies how much the
  512. // glyphs overhang to the left of the start position and to the right of
  513. // the length implied by the sum of the advance widths.
  514. //
  515. // The total advance width of the line is exactly abcA + abcB + abcC.
  516. //
  517. // abcA and abcC are maintained internally by Uniscribe as proportions
  518. // of the cell height represented in 8 bits and are thus roughly +/- 1%.
  519. // The total width returned (as the sum of piAdvance, and as the sum of
  520. // abcA+abcB+abcC) is accurate to the resolution of the TrueType shaping
  521. // engine.
  522. //
  523. // All glyph related arrays are in visual order unless the fLogicalOrder
  524. // flag is set in psa.
  525. #ifndef LSDEFS_DEFINED
  526. typedef struct tagGOFFSET {
  527. LONG du;
  528. LONG dv;
  529. } GOFFSET;
  530. #endif
  531. HRESULT WINAPI ScriptPlace(
  532. HDC hdc, // In Optional (see under caching)
  533. SCRIPT_CACHE *psc, // InOut Cache handle
  534. const WORD *pwGlyphs, // In Glyph buffer from prior ScriptShape call
  535. int cGlyphs, // In Number of glyphs
  536. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  537. SCRIPT_ANALYSIS *psa, // InOut Result of ScriptItemize (may have fNoGlyphIndex set)
  538. int *piAdvance, // Out Advance wdiths
  539. GOFFSET *pGoffset, // Out x,y offset for combining glyph
  540. ABC *pABC); // Out Composite ABC for the whole run (Optional)
  541. ///// ScriptTextOut
  542. //
  543. // The ScriptTextOut function takes the output of both ScriptShape and
  544. // ScriptPlace calls and calls the operating system ExtTextOut function
  545. // appropriately.
  546. //
  547. // All arrays are in visual order unless the fLogicalOrder flag is set in
  548. // psa.
  549. HRESULT WINAPI ScriptTextOut(
  550. const HDC hdc, // In OS handle to device context (required)
  551. SCRIPT_CACHE *psc, // InOut Cache handle
  552. int x, // In x,y position for first glyph
  553. int y, // In
  554. UINT fuOptions, // In ExtTextOut options
  555. const RECT *lprc, // In optional clipping/opaquing rectangle
  556. const SCRIPT_ANALYSIS *psa, // In Result of ScriptItemize
  557. const WCHAR *pwcReserved,// In Reserved (requires NULL)
  558. int iReserved, // In Reserved (requires 0)
  559. const WORD *pwGlyphs, // In Glyph buffer from prior ScriptShape call
  560. int cGlyphs, // In Number of glyphs
  561. const int *piAdvance, // In Advance widths from ScriptPlace
  562. const int *piJustify, // In Justified advance widths (optional)
  563. const GOFFSET *pGoffset); // In x,y offset for combining glyph
  564. /////
  565. //
  566. // The caller should normally use SetTextAlign(hdc, TA_RIGHT) before
  567. // calling ScriptTextOut with an RTL item inlogical order.
  568. //
  569. // The piJustify array provides requested cell widths for each glyph.
  570. // When the piJustify width of a glyph differs from the unjustified
  571. // width (in PiAdvance), space is added to or removed from the glyph
  572. // cell at it's trailing edge. The glyph is always aligned with the
  573. // leading edge of it's cell. (This rule applies even in visual order.)
  574. //
  575. // When a glyph cell is extended the extra space is uaually made up by
  576. // the addition of white space, however for Arabic scripts, the extra
  577. // space is made up by one or more kashida glyphs, unless the extra space
  578. // is insufficient for the shortest kashida glyph in the font. (The
  579. // width of the shortest kashida is available by calling
  580. // ScriptGetFontProperties.)
  581. //
  582. // piJustify should only be passed if re-justification of the string is
  583. // required. Normally pass NULL to this parameter.
  584. //
  585. // fuOptions may contain ETO_CLIPPED or ETO_OPAQUE (or neither or both).
  586. //
  587. // Do not use ScriptTextOut to write to a metafile unless you are sure
  588. // that the metafile will eventually be played back without any font
  589. // substitution. ScriptTextOut record glyph numbers in the metafile.
  590. // Since glyph numbers vary considerably from one font to another
  591. // such a metafile is unlikely to play back correctly when differant
  592. // fonts are substituted.
  593. //
  594. // For example when a metafile is played back at a different scale
  595. // CreateFont requests recorded in the metafile may resolve to bitmap
  596. // instead of truetype fonts, or if the metafile is played back on
  597. // a different machine requested fonts may not be installed.//
  598. //
  599. // To write complex scripts in a metafile in a font independant manner,
  600. // use ExtTextOut to write the logical characters directly, so that
  601. // glyph generation and placement does not occur until the text is
  602. // played back.
  603. ///// ScriptJustify
  604. //
  605. // ScriptJustify provides a simple minded implementation of multilingual
  606. // justification.
  607. //
  608. // Sophisticated text formatters may prefer to generate their own delta
  609. // dx array by combining their own features with the information returned
  610. // by ScriptShape in the SCRIPT_VISATTR array.
  611. //
  612. // ScriptJustify establishes how much adjustment to make at each glyph
  613. // position on the line. It interprets the SCRIPT_VISATTR array generated
  614. // by a call to ScriptShape, and gives top priority to kashida, then uses
  615. // inter word spacing if there's no kashida points, then uses
  616. // intercharacter spacing if there are no inter-word points.
  617. //
  618. // The justified advance widths generated in ScriptJustify should be
  619. // passed to ScriptTextOut in the piJustify paramter.
  620. //
  621. // ScriptJustify creates a justify array containing updated advance
  622. // widths for each glyph. Where a glyphs advance width is increased, it
  623. // is expected that the extra width will be rendered to the right of the
  624. // glyph, with as white space or, for Arabic text, as kashida.
  625. /////
  626. HRESULT WINAPI ScriptJustify(
  627. const SCRIPT_VISATTR *psva, // In Collected visual attributes for entire line
  628. const int *piAdvance, // In Advance widths from ScriptPlace
  629. int cGlyphs, // In Size of all arrays
  630. int iDx, // In Desired width change, either increase or descrease
  631. int iMinKashida, // In Minimum length of continuous kashida glyph to generate
  632. int *piJustify); // Out Updated advance widths to pass to ScriptTextOut
  633. ///// SCRIPT_LOGATTR
  634. //
  635. // The SCRIPT_LOGATTR structure describes attributes of logical
  636. // characters useful when editing and formatting text.
  637. //
  638. //
  639. typedef struct tag_SCRIPT_LOGATTR {
  640. BYTE fSoftBreak :1; // Potential linebreak point
  641. BYTE fWhiteSpace :1; // A unicode whitespace character, except NBSP, ZWNBSP
  642. BYTE fCharStop :1; // Valid cursor position (for left/right arrow)
  643. BYTE fWordStop :1; // Valid cursor position (for ctrl + left/right arrow)
  644. BYTE fInvalid :1; // Invalid character sequence
  645. BYTE fReserved :3;
  646. } SCRIPT_LOGATTR;
  647. //
  648. //
  649. //p fSoftBreak: It would be valid to break the line in front of this
  650. // character. This flag is set on the first character of
  651. // South-East Asian words.
  652. //
  653. //p fWhiteSpace: This character is one of the many Unicode character
  654. // that are classified as breakable whitespace.
  655. //
  656. //p fCharStop: Valid cursor position. Set on most characters, but not
  657. // on codepoints inside Indian and South East Asian character
  658. // clusters. May be used to implement left and right arrow
  659. // operation in editors.
  660. //
  661. //p fWordStop: Valid position following word advance/retire commonly
  662. // implemented at ctrl/left-arrow and ctrl/right-arrow.
  663. // May be used to implement ctrl+left and ctrl+right arrow
  664. // operation in editors.
  665. //
  666. //p fInvalid: Marks characters which form an invalid or undisplayable
  667. // combination. Scripts which can set this flag have the flag
  668. // fInvalidLogAttr set in their SCRIPT_PROPERTIES.
  669. ///// ScriptBreak
  670. //
  671. // The ScriptBreak function returns cursor movement and formatting break
  672. // positions for an item as an array of SCRIPT_LOGATTRs. To support
  673. // mixed formatting within a single word correctly, ScriptBreak should
  674. // be passed whole items as returned by ScriptItemize.
  675. //
  676. // ScriptBreak does not require an hdc and does not execute glyph shaping.
  677. //
  678. // The fCharStop flag marks cluster boundaries for those scripts where
  679. // it is conventional to restrict from moving inside clusters. The same
  680. // boundaries could also be inferred by inspecting the pLogCLust array
  681. // returned by ScriptShape, however ScriptBreak is considerably faster in
  682. // implementation and does not require an hdc to be prepared.
  683. //
  684. // The fWordStop, fSoftBreak and fWhiteSpace flags are only available
  685. // through ScriptBreak.
  686. //
  687. // Most shaping engines that identify invalid sequences do so by setting
  688. // the fInvalid flag in ScriptBreak. The fInvalidLogAttr flag in
  689. // ScriptProperties identifies which scripts do this.
  690. HRESULT WINAPI ScriptBreak(
  691. const WCHAR *pwcChars, // In Logical unicode item
  692. int cChars, // In Length of unicode item
  693. const SCRIPT_ANALYSIS *psa, // In Result of earlier ScriptItemize call
  694. SCRIPT_LOGATTR *psla); // Out Logical character attributes
  695. ///// ScriptCPtoX
  696. //
  697. // The ScriptCPtoX function returns the x offset from the left end
  698. // (!fLogical) or leading edge (fLogical) of a run to either the leading
  699. // or the trailing edge of a logical character cluster.
  700. //
  701. // iCP is the offset of any logical character in the cluster.
  702. //
  703. // For scripts where the caret may conventionally be placed into the
  704. // middle of clusters (e.g. Arabic, Hebrew), the returned X may be
  705. // an interpolated position for any codepoint in the line.
  706. //
  707. // For scripts where the caret is conventionally snapped to the boundaries
  708. // of clusters, (e.g. Thai, Indian), the resulting X position will be
  709. // snapped to the requested edge of the cluster containing CP.
  710. HRESULT WINAPI ScriptCPtoX(
  711. int iCP, // In Logical character position in run
  712. BOOL fTrailing, // In Which edge (default - leading)
  713. int cChars, // In Count of logical codepoints in run
  714. int cGlyphs, // In Count of glyphs in run
  715. const WORD *pwLogClust, // In Logical clusters
  716. const SCRIPT_VISATTR *psva, // In Visual glyph attributes array
  717. const int *piAdvance, // In Advance widths
  718. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  719. int *piX); // Out Resulting X position
  720. ///// ScriptXtoCP
  721. //
  722. // The ScriptXtoCP function converts an x offset from the left end
  723. // (!fLogical) or leading edge (fLogical) of a run to a logical
  724. // character position and a flag that indicates whether the X position
  725. // fell in the leading or the trailing half of the character.
  726. //
  727. // For scripts where the cursor may conventionally be placed into the
  728. // middle of clusters (e.g. Arabic, Hebrew), the returned CP may be
  729. // for any codepoint in the line, and fTrailing will be either zero
  730. // or one.
  731. //
  732. // For scripts where the cursor is conventionally snapped to the
  733. // boundaries of a cluster, the returned CP is always the position of
  734. // the logically first codepoint in a cluster, and fTrailing is either
  735. // zero, or the number of codepoints in the cluster.
  736. //
  737. // Thus the appropriate cursor position for a mouse hit is always the
  738. // returned CP plus the value of fTrailing.
  739. //
  740. // If the X positition passed is not in the item at all, the resulting
  741. // position will be the trailing edge of character -1 (for X positions
  742. // before the item), or the leading edge of character 'cChars' (for
  743. // X positions following the item).
  744. HRESULT WINAPI ScriptXtoCP(
  745. int iX, // In X offset from left of run
  746. int cChars, // In Count of logical codepoints in run
  747. int cGlyphs, // In Count of glyphs in run
  748. const WORD *pwLogClust, // In Logical clusters
  749. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  750. const int *piAdvance, // In Advance widths
  751. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  752. int *piCP, // Out Resulting character position
  753. int *piTrailing); // Out Leading or trailing half flag
  754. ///// Relationship between caret positions, justifications points and clusters
  755. //
  756. //
  757. //t Job | Uniscribe support
  758. //t -------------------------------- | --------------------------------------------------------
  759. //t Caret move by character cluster | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
  760. //t Line breaking between characters | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
  761. //t Caret move by word | LOGATTR.fWordStop
  762. //t Line breaking between words | LOGATTR.fWordStop
  763. //t Justification | VISATTR.uJustification
  764. //
  765. //
  766. //
  767. ///// Character clusters
  768. //
  769. // Character clusters are glyph sequences that cannot be split between
  770. // lines.
  771. //
  772. // Some languages (e.g. Thai, Indic) restrict caret placement to points
  773. // betwen clusters. This applies both to keyboard initiated caret
  774. // movement (e.g. cursor keys) and pointing and clicking with the mouse
  775. // (hit testing).
  776. //
  777. // Uniscribe provides cluster information in both the visual and logical
  778. // attributes. If you've called ScriptShape you'll find the cluster
  779. // information represented both by sequences of the same value in the
  780. // pwLogClust array, and by the fClusterStart flag in the psva
  781. // SCRIPT_VISATTR array.
  782. //
  783. // ScriptBreak also returns the fCharStop flag in the SCRIPT_LOGATTR
  784. // array to identify cluster positions.
  785. //
  786. //
  787. //
  788. ///// Word break points
  789. //
  790. // Valid positions for moving the caret when moving in whole words are
  791. // marked by the fWordStop flag returned by ScriptBreak.
  792. //
  793. // Valid positions for breaking lines between words are marked by the
  794. // fSoftBreak flag returned by ScriptBreak.
  795. //
  796. //
  797. //
  798. ///// Justification
  799. //
  800. // Justification space or kashida should be inserted where identified by
  801. // the uJustificaion field of the SCRIPT_VISATTR.
  802. //
  803. // When performing inter-character justification, insert extra space
  804. // only after glyphs marked with uJustify == SCRIPT_JUSTIFY_CHARACTER.
  805. //
  806. //
  807. //
  808. ///// Script specific processing
  809. //
  810. // Uniscribe provides information about special processing for each
  811. // script in the SCRIPT_PROPERTIES array.
  812. //
  813. // Use the following code during initialisation to get a pointer to
  814. // the SCRIPT_PROPERTIES array:
  815. //
  816. //c const SCRIPT_PROPERTIES **g_ppScriptProperties; // Array of pointers to properties
  817. //c int iMaxScript;
  818. //c HRESULT hr;
  819. //
  820. //c hr = ScriptGetProperties(&g_ppScriptProperties, &g_iMaxScript);
  821. //
  822. // Then inspect the properties of the script of an item 'iItem' as follows:
  823. //
  824. //c hr = ScriptItemize( ... , pItems, ... );
  825. //c ...
  826. //c if (g_ppScriptProperties[pItems[iItem].a.eScript]->fNeedsCaretInfo) {
  827. //c // Use ScriptBreak to restrict the caret from entering clusters (for example).
  828. //c }
  829. //
  830. //
  831. // SCRIPT_PROPERTIES.fNeedsCaretInfo
  832. //
  833. // Caret placement should be restricted to cluster
  834. // edges for scripts such as Thai and Indian. The fNeedsCaretInfo flag
  835. // in SCRIPT_PROPERTIES identifies such languages.
  836. //
  837. // Note that ScriptXtoCP and ScriptCPtoX automatically apply caret
  838. // placement restictions.
  839. //
  840. //
  841. // SCRIPT_PROPERTIES.fNeedsWordBreaking
  842. //
  843. // For most scripts, word break placement may be
  844. // identified by scanning for characters marked as fWhiteSpace in
  845. // SCRIPT_LOGATTR, or for glyphs marked as uJustify ==
  846. // SCRIPT_JUSTIFY_BLANK or SCRIPT_JUSTIFY_ARABIC_BLANK in SCRIPT_VISATTR.
  847. //
  848. // For languages such as Thai, it is also necessary to call ScriptBreak,
  849. // and include character positions marked as fWordStop in SCRIPT_LOGATTR.
  850. // Such scripts are marked as fNeedsWordbreaking in SCRIPT_PROPERTIES.
  851. //
  852. //
  853. // SCRIPT_PROPERTIES.fNeedsCharacterJustify
  854. //
  855. // Languages such as Thai also require inter-character spacing when
  856. // justifying (where uJustify == SCRIPT_JUSTIFY_CHARACTER in the
  857. // SCRIPT_VISATTR). Such languages are marked as fNeedsCharacterJustify
  858. // in SCRIPT_PROPERTIES.
  859. //
  860. //
  861. // SCRIPT_PROPERTIES.fAmbiguousCharSet
  862. //
  863. // Many Uniscribe scripts do not correspond directly to 8 bit character
  864. // sets. For example Unicode characters in the range U+100 through U+024F
  865. // represent extended latin shapes used for many languages, including
  866. // those supported by EASTEUROPE_CHARSET, TURKISH_CHARSET and
  867. // VIETNAMESE_CHARSET. However many of these characters are supported by
  868. // more han one of thsese charsets.
  869. // fAmbiguousCharset is set for any script token which could contain
  870. // characters from a number of these charsets. In these cases the bCharSet
  871. // field may contain ANSI_CHARSET or DEFAULT_CHARSET. The Uniscribe client
  872. // will generally need to apply futher processing to determine which charset
  873. // to use when requesting a font suitable for this run. For example it
  874. // determine that the run consists of multiple languages and split it up
  875. // to use a different font for each language.
  876. ///// Notes on ScriptXtoCP and ScriptCPtoX
  877. //
  878. // Both functions work only within runs and require the results of a
  879. // previous ScriptShape call.
  880. //
  881. // The client must establish which run a given cursor offset or x
  882. // position is within before passing it to ScriptCPtoX or ScriptXtoCP.
  883. //
  884. // Cluster information in the logical cluster array is used to share
  885. // the width of a cluster of glyphs equally among the logical characters
  886. // they represent.
  887. //
  888. // For example, the lam alif glyph is divided into four areas: the
  889. // leading half of the lam, the trailing half of the lam, the leading
  890. // half of the alif and the trailing half of the alif.
  891. //
  892. // ScriptXtoCP Understands the caret position conventions of each script.
  893. // For Indian and Thai, caret positions are snapped to cluster boundaries,
  894. // for Arabic and Hebrew, caret positions are interpolated within clusters.
  895. //
  896. //
  897. ///// Translating mouse hit 'x' offset to caret position
  898. //
  899. // Conventionally, caret position 'cp' may be selected by clicking either
  900. // on the trailing half of character 'cp-1' or on the leading half of
  901. // character 'cp'. This may easily be implemented as follows:
  902. //
  903. //c int iCharPos;
  904. //c int iCaretPos
  905. //c int fTrailing;
  906. //
  907. //c ScriptXtoCP(iMouseX, ..., &iCharPos, &fTrailing);
  908. //c iCaretPos = iCharPos + fTrailing;
  909. //
  910. // For scripts that snap the caret to cluster boundaries, ScriptXtoCP
  911. // returns ftrailing set to either 0, or the width of the cluster in
  912. // codepoints. Thus the above code correctly returns only valid
  913. // caret positions.
  914. //
  915. //
  916. ///// Displaying the caret in bidi strings
  917. //
  918. // In unidirectional text, the leading edge of a character is at the same
  919. // place as the trailing edge of the previous character, so there is no
  920. // ambiguity in placing the caret between characters.
  921. //
  922. // In bidirectional text, the caret position between runs of opposing
  923. // direction may be ambiguous.
  924. //
  925. // For example in the left to right paragraph 'helloMAALAS', the last
  926. // letter of 'hello' immediately preceeds the first letter of 'salaam'.
  927. // The best position to display the caret depends on whether it is
  928. // considered to follow the 'o' of 'hello', or to preceed the 's' of
  929. // 'salaam'.
  930. //
  931. ///// Commonly used caret positioning conventions
  932. //
  933. //t Situation | Visual caret placement
  934. //t --------- | -------------------------------------------
  935. //t Typing | Trailing edge of last character typed
  936. //t Pasting | Trailing edge of last character pasted
  937. //t Caret advancing | Trailing edge of last character passed over
  938. //t Caret retiring | Leading edge of last character passed over
  939. //t Home | Leading edge of line
  940. //t End | Trailing edge of line
  941. //
  942. // The caret may be positioned as follows:
  943. //
  944. //c if (advancing) {
  945. //c ScriptCPtoX(iCharPos-1, TRUE, ..., &iCaretX);
  946. //c } else {
  947. //c ScriptCPtoX(iCharPos, FALSE, ..., &iCaretX);
  948. //c }
  949. //
  950. // Or, more simply, given an fAdvancing BOOL restricted to TRUE or FALSE:
  951. //
  952. //c ScriptCPtoX(iCharPos-fAdvancing, fAdvancing, ..., &iCaretX);
  953. //
  954. // ScriptCPtoX handles out of range positions logically: it returns the
  955. // leading edge of the run for iCharPos <0, and the trailing edge of the
  956. // run for iCharPos >=length.
  957. ///// ScriptGetLogicalWidths
  958. //
  959. // Converts visual withs in piAdvance into logical widths,
  960. // one per original character, in logical order.
  961. //
  962. // Ligature glyphs widths are divided evenly amongst the characters
  963. // they represent.
  964. HRESULT WINAPI ScriptGetLogicalWidths(
  965. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  966. int cChars, // In Count of logical codepoints in run
  967. int cGlyphs, // In Count of glyphs in run
  968. const int *piGlyphWidth, // In Advance widths
  969. const WORD *pwLogClust, // In Logical clusters
  970. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  971. int *piDx); // Out Logical widths
  972. /////
  973. // ScriptGetLogicalWidths is useful for recording widths in a
  974. // font independant manner. By passing the recorded logical widths
  975. // to ScriptApplyLogicalWidths, a block of text can be replayed in the
  976. // same boundaries with acceptable loss of quality even when the original
  977. // font is not available.
  978. ///// ScriptApplyLogicalWidth
  979. //
  980. // Accepts an array of advance widths in logical order, corresponding
  981. // one to one with codepoints, and generates an array of glyph widths
  982. // suitable for passing to the piJustify parameter of ScriptTextOut.
  983. //
  984. // ScriptApplyLogicalWidth may be used to reapply logical widths
  985. // obtained with ScriptGetLogicalWidths. It may be useful in situations
  986. // such as metafiling, where it is necessary to record and reapply
  987. // advance width information in a font independant manner.
  988. HRESULT WINAPI ScriptApplyLogicalWidth(
  989. const int *piDx, // In Logical dx array to apply
  990. int cChars, // In Count of logical codepoints in run
  991. int cGlyphs, // In Glyph count
  992. const WORD *pwLogClust, // In Logical clusters
  993. const SCRIPT_VISATTR *psva, // In Visual attributes from ScriptShape/Place
  994. const int *piAdvance, // In Glyph advance widths from ScriptPlace
  995. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  996. ABC *pABC, // InOut Updated item ABC width (optional)
  997. int *piJustify); // Out Resulting glyph advance widths for ScriptTextOut
  998. /////
  999. //p piDx: Pointer to an array of dx widths in logical order, one per codepoint.
  1000. //
  1001. //p cChars: Count of the logical codepoints in the run.
  1002. //
  1003. //p cGlyphs: Glyph count.
  1004. //
  1005. //p pwLogClust: Pointer to an array of logical clusters from ScriptShape
  1006. //
  1007. //p psva: Pointer to an array of visual attributes from ScriptShape and
  1008. // updated by ScriptPlace.
  1009. //
  1010. //p piAdvance: Pointer to an array of glyph advance widths from ScriptPlace.
  1011. //
  1012. //p psa: Pointer to a SCRIPT_ANALYSIS structure from ScriptItemize and
  1013. // updated by ScriptShape and SriptPlace..
  1014. //
  1015. //p pABC: Pointer to the run overall ABC width (optional). If present,
  1016. // when the function is called, it should contain the run ABC width
  1017. // returned by ScriptPlace; when the function returns, the ABC width
  1018. // has been updated to match the new widths.
  1019. //
  1020. //p piJustify:Pointer to an array of the resulting glyph advance widths.
  1021. // This is suitable for passing to the piJustify parameter of ScriptTextOut.
  1022. ///// ScriptGetCMap
  1023. //
  1024. // ScriptGetCMap may be used to determine which characters in a run
  1025. // are supported by the selected font.
  1026. //
  1027. // It returns glyph indices of Unicode characters according to Truetype
  1028. // Cmap table, or standard Cmap implemented for old style fonts. The
  1029. // glyph indices are returned in the same order as the input string.
  1030. //
  1031. // The caller may scan the returned glyph buffer looking for the default
  1032. // glyph to determine which characters are not available. (The default
  1033. // glyph index for the selected font should be determined by calling
  1034. // ScriptGetFontProperties).
  1035. //
  1036. // The return value indicates the presence of any missing glyphs.
  1037. #define SGCM_RTL 0x00000001 // Return mirrored glyph for mirrorable Unicode codepoints
  1038. HRESULT WINAPI ScriptGetCMap(
  1039. HDC hdc, // In Optional (see notes on caching)
  1040. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1041. const WCHAR *pwcInChars, // In Unicode codepoint(s) to look up
  1042. int cChars, // In Number of characters
  1043. DWORD dwFlags, // In Flags such as SGCM_RTL
  1044. WORD *pwOutGlyphs); // Out Array of glyphs, one per input character
  1045. /////
  1046. // returns S_OK - All unicode codepoints were present in the font
  1047. // S_FALSE - Some of the Unicode codepoints were mapped to the default glyph
  1048. // E_HANDLE - font or system does not support glyph indices
  1049. ///// ScriptGetGlyphABCWidth
  1050. //
  1051. // Returns ABC width of a given glyph.
  1052. // May be useful for drawing glyph charts. Should not be used for
  1053. // run of the mill complex script text formatting.
  1054. HRESULT WINAPI ScriptGetGlyphABCWidth(
  1055. HDC hdc, // In Optional (see notes on caching)
  1056. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1057. WORD wGlyph, // In Glyph
  1058. ABC *pABC); // Out ABC width
  1059. /////
  1060. // returns S_OK - Glyph width returned
  1061. // E_HANDLE - font or system does not support glyph indices
  1062. ///// SCRIPT_PROPERTIES
  1063. //
  1064. typedef struct {
  1065. DWORD langid :16; // Primary and sublanguage associated with script
  1066. DWORD fNumeric :1;
  1067. DWORD fComplex :1; // Script requires special shaping or layout
  1068. DWORD fNeedsWordBreaking :1; // Requires ScriptBreak for word breaking information
  1069. DWORD fNeedsCaretInfo :1; // Requires caret restriction to cluster boundaries
  1070. DWORD bCharSet :8; // Charset to use when creating font
  1071. DWORD fControl :1; // Contains only control characters
  1072. DWORD fPrivateUseArea :1; // This item is from the Unicode range U+E000 through U+F8FF
  1073. DWORD fNeedsCharacterJustify :1; // Requires inter-character justification
  1074. DWORD fInvalidGlyph :1; // Invalid combinations generate glyph wgInvalid in the glyph buffer
  1075. DWORD fInvalidLogAttr :1; // Invalid combinations are marked by fInvalid in the logical attributes
  1076. DWORD fCDM :1; // Contains Combining Diacritical Marks
  1077. DWORD fAmbiguousCharSet :1; // Script does not correspond 1:1 with a charset
  1078. DWORD fClusterSizeVaries :1; // Measured cluster width depends on adjacent clusters
  1079. DWORD fRejectInvalid :1; // Invalid combinations should be rejected
  1080. } SCRIPT_PROPERTIES;
  1081. //
  1082. //p langid: Language associated with this script. When a script is used for many languages,
  1083. // langid id represents a default language. For example, Western script is represented
  1084. // by LANG_ENGLISH although it is also used for French, German, Spanish etc.
  1085. //
  1086. //p fNumeric: Script contains numerics and characters used in conjunction with numerics
  1087. // by the rules of the Unicode bidirectional algorithm. For example
  1088. // dollar sign and period are classified as numeric when adjacent to or in between
  1089. // digits.
  1090. //
  1091. //p fComplex: Indicates a script that requires complex script handling. If fComplex is false
  1092. // the script contains no combining characters and requires no contextual shaping or reordering.
  1093. //
  1094. //p fNeedsWordBreaking: A script, such as Thai, which requires algorithmic wordbreaking.
  1095. // Use ScriptBreak to obtain a wordbreak points using the standard system wordbreaker.
  1096. //
  1097. //p fNeedsCaretInfo: A script, such as Thai and Indian, where the caret may not be placed
  1098. // inside a cluster. To determine valid caret positions inspect the fCharStop flag in the
  1099. // logical attributes returned by ScriptBreak, or compare adjacent values in the pwLogClust
  1100. // array returned by ScriptShape.
  1101. //
  1102. //p bCharSet: Nominal charset associated with script. May be used in a logfont when creating
  1103. // a font suitable for displaying this script. Note that for new scripts where there
  1104. // is no charset defined, bCharSet may be innapropriate and DEFAULT_CHARSET should
  1105. // be used instead - see the description of fAmbiguousCharSet below.
  1106. //
  1107. //p fControl: contains control characters.
  1108. //
  1109. //p fPrivateUseArea: The Unicode range U+E000 through U+F8FF.
  1110. //
  1111. //p fNeedsCharacterJustify: A script, such as Thai, where justification is conventionally
  1112. // achieved by increasing the space between all letters, not just between words.
  1113. //
  1114. //p fInvalidGlyph: A script for which ScriptShape generates an invalid glyph
  1115. // to represent invalid sequences. The glyph index of the invalid glyph for
  1116. // a particular font may be obtained by calling ScriptGetFontProperties.
  1117. //
  1118. //p fInvalidLogAttr: A script for which ScriptBreak sets the fInvalid flag
  1119. // in the logical attributes to mark invalid sequences.
  1120. //
  1121. //p fCDM: Implies that an item analysed by ScriptItemize included combining
  1122. // diacritical marks (U+0300 through U+36F).
  1123. //
  1124. //p fAmbiguousCharSet: No single legacy charset supports this script.
  1125. // For example the extended Latin Extended-A Unicode range includes
  1126. // characters from the EASTUROPE_CHARSET, the TURKISH_CHARSET and the
  1127. // BALTIC_CHARSET. It also contains characters that are not available
  1128. // in any legacy charset. Use DEFAULT_CHARSET when creating fonts to
  1129. // display parts of this run.
  1130. //
  1131. //p fClusterSizeVaries: A script, such as Arabic, where contextual shaping
  1132. // may cause a string to increase in size when removing characters.
  1133. //
  1134. //p fRejectInvalid: A script, such as Thai, where invalid sequences conventionally
  1135. // cause an editor such as notepad to beep, and ignore keypresses.
  1136. ///// ScriptGetProperties
  1137. //
  1138. // ScriptGetProperties returns the address of a table that maps a
  1139. // script in a SCRIPT_ANALYSIS uScript field to properties including
  1140. // the primary language associated with that script, whether it's
  1141. // numeric and whether it's complex.
  1142. HRESULT WINAPI ScriptGetProperties(
  1143. const SCRIPT_PROPERTIES ***ppSp, // Out Receives pointer to table of pointers to properties indexed by script
  1144. int *piNumScripts); // Out Receives number of scripts (valid values are 0 through NumScripts-1)
  1145. ///// SCRIPT_FONTPROPERTIES
  1146. //
  1147. typedef struct {
  1148. int cBytes; // Structure length
  1149. WORD wgBlank; // Blank glyph
  1150. WORD wgDefault; // Glyph used for Unicode values not present in the font
  1151. WORD wgInvalid; // Glyph used for invalid character combinations (especially in Thai)
  1152. WORD wgKashida; // Shortest continuous kashida glyph in the font, -1 if doesn't exist
  1153. int iKashidaWidth; // Widths of shortest continuous kashida glyph in the font
  1154. } SCRIPT_FONTPROPERTIES;
  1155. ///// ScriptGetFontProperties
  1156. //
  1157. // Returns information from the font cache
  1158. HRESULT WINAPI ScriptGetFontProperties(
  1159. HDC hdc, // In Optional (see notes on caching)
  1160. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1161. SCRIPT_FONTPROPERTIES *sfp); // Out Receives properties for this font
  1162. ///// ScriptCacheGetHeight
  1163. //
  1164. //
  1165. HRESULT WINAPI ScriptCacheGetHeight(
  1166. HDC hdc, // In Optional (see notes on caching)
  1167. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1168. long *tmHeight); // Out Receives font height in pixels
  1169. ///// ScriptStringAnalyse
  1170. //
  1171. //
  1172. #define SSA_PASSWORD 0x00000001 // Input string contains a single character to be duplicated iLength times
  1173. #define SSA_TAB 0x00000002 // Expand tabs
  1174. #define SSA_CLIP 0x00000004 // Clip string at iReqWidth
  1175. #define SSA_FIT 0x00000008 // Justify string to iReqWidth
  1176. #define SSA_DZWG 0x00000010 // Provide representation glyphs for control characters
  1177. #define SSA_FALLBACK 0x00000020 // Use fallback fonts
  1178. #define SSA_BREAK 0x00000040 // Return break flags (character and word stops)
  1179. #define SSA_GLYPHS 0x00000080 // Generate glyphs, positions and attributes
  1180. #define SSA_RTL 0x00000100 // Base embedding level 1
  1181. #define SSA_GCP 0x00000200 // Return missing glyphs and LogCLust with GetCharacterPlacement conventions
  1182. #define SSA_HOTKEY 0x00000400 // Replace '&' with underline on subsequent codepoint
  1183. #define SSA_METAFILE 0x00000800 // Write items with ExtTextOutW Unicode calls, not glyphs
  1184. #define SSA_LINK 0x00001000 // Apply FE font linking/association to non-complex text
  1185. #define SSA_HIDEHOTKEY 0x00002000 // Remove first '&' from displayed string
  1186. #define SSA_HOTKEYONLY 0x00002400 // Display underline only.
  1187. #define SSA_LPKANSIFALLBACK 0x08000000 // Internal - enable FallBack for all LPK Ansi calls Except BiDi hDC calls
  1188. #define SSA_PIDX 0x10000000 // Internal
  1189. #define SSA_LAYOUTRTL 0x20000000 // Internal - Used when DC is mirrored
  1190. #define SSA_DONTGLYPH 0x40000000 // Internal - Used only by GDI during metafiling - Use ExtTextOutA for positioning
  1191. #define SSA_NOKASHIDA 0x80000000 // Internal - Used by GCP to justify the non Arabic glyphs only.
  1192. ///// SCRIPT_TABDEF
  1193. //
  1194. // Defines tabstop positions for ScriptStringAnalyse (ignored unless SSA_TAB passed)
  1195. //
  1196. typedef struct tag_SCRIPT_TABDEF {
  1197. int cTabStops; // Number of entries in pTabStops array
  1198. int iScale; // Scale factor for pTabStops (see below)
  1199. int *pTabStops; // Pointer to array of one or more tab stops
  1200. int iTabOrigin; // Initial offset for tab stops (logical units)
  1201. } SCRIPT_TABDEF;
  1202. //
  1203. //
  1204. //p cTabStops: Number of entries in the pTabStops array. If zero, tabstops
  1205. // are every 8 average character widths. If one, all tabstops are
  1206. // the length of the first entry in pTabStops. If more than one,
  1207. // the first cTabStops are as specified in the pTabStops array,
  1208. // subsequent tabstops are every 8 average characters from the last
  1209. // tabstop in the array.
  1210. //
  1211. //p iScale: Scale factor for iTabOrigin and pTabStops entries. Values are
  1212. // converted to device coordinates by multiplying by iScale then
  1213. // dividing by 4. If values are already in device units, set iScale to
  1214. // 4. If values are in dialog units, set iScale to the average char
  1215. // width of the dialog font. If values are multiples of the average
  1216. // character width for the selected font, set iScale to 0.
  1217. //
  1218. //p pTabStops: Array of cTabStops entries. Each entry specifies a
  1219. // tabstop position. Positive values give nearedge alignment,
  1220. // negative values give faredge alignment.
  1221. //
  1222. //p iTabOrigin: Tabs are considered to start iTabOrigin before the
  1223. // beginning of the string. Helps with multiple tabbed
  1224. // outputs on the same line.
  1225. ///// ScriptStringAnalyse
  1226. //
  1227. // cString - Input string must contain at least one character
  1228. //
  1229. // hdc - required if SSA_GLYPH requested. Optional for SSA_BREAK.
  1230. // If present the current font in the hdc is inspected and if a symbolic
  1231. // font the character string is treated as a single neutral SCRIPT_UNDEFINED item.
  1232. //
  1233. // Note that the uBidiLevel field in the initial SCRIPT_STATE value
  1234. // is ignored - the uBidiLevel used is derived from the SSA_RTL
  1235. // flag in combination with the layout of the hdc.
  1236. typedef void* SCRIPT_STRING_ANALYSIS;
  1237. HRESULT WINAPI ScriptStringAnalyse(
  1238. HDC hdc, //In Device context (required)
  1239. const void *pString, //In String in 8 or 16 bit characters
  1240. int cString, //In Length in characters (Must be at least 1)
  1241. int cGlyphs, //In Required glyph buffer size (default cString*1.5 + 16)
  1242. int iCharset, //In Charset if an ANSI string, -1 for a Unicode string
  1243. DWORD dwFlags, //In Analysis required
  1244. int iReqWidth, //In Required width for fit and/or clip
  1245. SCRIPT_CONTROL *psControl, //In Analysis control (optional)
  1246. SCRIPT_STATE *psState, //In Analysis initial state (optional)
  1247. const int *piDx, //In Requested logical dx array
  1248. SCRIPT_TABDEF *pTabdef, //In Tab positions (optional)
  1249. const BYTE *pbInClass, //In Legacy GetCharacterPlacement character classifications (deprecated)
  1250. SCRIPT_STRING_ANALYSIS *pssa); //Out Analysis of string
  1251. ///// ScriptStringFree - free a string analysis
  1252. //
  1253. //
  1254. HRESULT WINAPI ScriptStringFree(
  1255. SCRIPT_STRING_ANALYSIS *pssa); //InOut Address of pointer to analysis
  1256. ///// ScriptStringSize
  1257. //
  1258. // returns a pointer to the size (width and height) of an analysed string
  1259. //
  1260. // Note that the SIZE pointer remains valid only until the
  1261. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1262. const SIZE* WINAPI ScriptString_pSize(
  1263. SCRIPT_STRING_ANALYSIS ssa);
  1264. ///// ScriptString_pcOutChars
  1265. //
  1266. // returns pointer to length of string after clipping (requires SSA_CLIP set)
  1267. //
  1268. // Note that the int pointer remains valid only until the
  1269. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1270. const int* WINAPI ScriptString_pcOutChars(
  1271. SCRIPT_STRING_ANALYSIS ssa);
  1272. ///// ScriptString_pLogAttr
  1273. //
  1274. // returns pointer to logical attributes buffer in a SCRIPT_STRING_ANALYSIS
  1275. //
  1276. // Note that the buffer pointer remains valid only until the
  1277. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1278. //
  1279. // The logical attribute array contains *ScriptString_pcOutChars(ssa)
  1280. // entries.
  1281. const SCRIPT_LOGATTR* WINAPI ScriptString_pLogAttr(
  1282. SCRIPT_STRING_ANALYSIS ssa);
  1283. ///// ScriptStringGetOrder
  1284. //
  1285. // Creates an array mapping original character position to glyph position.
  1286. //
  1287. // Treats clusters as they were in legacy systems - Unless a cluster
  1288. // contains more glyphs than codepoints, each glyph is referenced at
  1289. // least once from the puOrder array.
  1290. //
  1291. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1292. //
  1293. // The puOrder parameter should address a buffer containing room for
  1294. // at least *ScriptString_pcOutChars(ssa) ints.
  1295. HRESULT WINAPI ScriptStringGetOrder(
  1296. SCRIPT_STRING_ANALYSIS ssa,
  1297. UINT *puOrder);
  1298. ///// ScriptStringCPtoX
  1299. //
  1300. // Return x coordinate for leading or trailing edge of character icp.
  1301. HRESULT WINAPI ScriptStringCPtoX(
  1302. SCRIPT_STRING_ANALYSIS ssa, //In String analysis
  1303. int icp, //In Caret character position
  1304. BOOL fTrailing, //In Which edge of icp
  1305. int *pX); //Out Corresponding x offset
  1306. ///// ScriptStringXtoCP
  1307. //
  1308. //
  1309. HRESULT WINAPI ScriptStringXtoCP(
  1310. SCRIPT_STRING_ANALYSIS ssa, // In
  1311. int iX, // In
  1312. int *piCh, // Out
  1313. int *piTrailing); // Out
  1314. ///// ScriptStringGetLogicalWidths
  1315. //
  1316. // Converts visual withs in psa->piAdvance into logical widths,
  1317. // one per original character, in logical order.
  1318. //
  1319. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1320. //
  1321. // The piDx parameter should address a buffer containing room for
  1322. // at least *ScriptString_pcOutChars(ssa) ints.
  1323. HRESULT WINAPI ScriptStringGetLogicalWidths(
  1324. SCRIPT_STRING_ANALYSIS ssa,
  1325. int *piDx);
  1326. ///// ScriptStringValidate
  1327. //
  1328. // Scans the string analysis for invalid glyphs.
  1329. //
  1330. // Only glyphs generated by scripts that can generate invalid glyphs
  1331. // are scanned.
  1332. //
  1333. // returns S_OK - no invalid glyphs are present
  1334. // S_FALSE - one or more invalid glyphs are present
  1335. HRESULT WINAPI ScriptStringValidate(
  1336. SCRIPT_STRING_ANALYSIS ssa);
  1337. ///// ScriptStringOut
  1338. //
  1339. // Displays the string generated by a prior ScriptStringAnalyze call,
  1340. // then optionally adds highlighting corresponding to a logical selection.
  1341. //
  1342. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1343. HRESULT WINAPI ScriptStringOut(
  1344. SCRIPT_STRING_ANALYSIS ssa, //In Analysis with glyphs
  1345. int iX, //In
  1346. int iY, //In
  1347. UINT uOptions, //In ExtTextOut options
  1348. const RECT *prc, //In Clipping rectangle (iff ETO_CLIPPED)
  1349. int iMinSel, //In Logical selection. Set iMinSel>=iMaxSel for no selection
  1350. int iMaxSel, //In
  1351. BOOL fDisabled); //In If disabled, only the background is highlighted.
  1352. /////
  1353. // uOptions may nclude only ETO_CLIPPED or ETO_OPAQUE.
  1354. ///// ScriptIsComplex
  1355. //
  1356. // Determines whether a Unicode string requires complex script processing
  1357. //
  1358. // The dwFlags parameter may include the following requests
  1359. //
  1360. #define SIC_COMPLEX 1 // Treat complex script letters as complex
  1361. #define SIC_ASCIIDIGIT 2 // Treat digits U+0030 through U+0039 as complex
  1362. #define SIC_NEUTRAL 4 // Treat neutrals as complex
  1363. //
  1364. // SIC_COMPLEX: Should normally set. Causes complex script letters to
  1365. // be treated as complex.
  1366. //
  1367. // SIC_ASCIIDIGIT: Set this flag if the string would be displayed with
  1368. // digit substitution enabled. If you are following the users NLS
  1369. // settings using the ScriptRecordDigitSubstitution API, you can pass
  1370. // scriptDigitSubstitute.DigitSubstitute != SCRIPT_DIGITSUBSTITUTE_NONE.
  1371. //
  1372. // SIC_NEUTRAL: Set this flag if you may be displaying the string with
  1373. // right-to-left reading order. When this flag is set, neutral characters
  1374. // are considered as complex.
  1375. //
  1376. //
  1377. // Returns S_OK if string requires complex script processing,
  1378. // S_FALSE if string contains only characters laid out side by
  1379. // side from left to right.
  1380. HRESULT WINAPI ScriptIsComplex(
  1381. const WCHAR *pwcInChars, //In String to be tested
  1382. int cInChars, //In Length in characters
  1383. DWORD dwFlags); //In Flags (see above)
  1384. ///// ScriptRecordDigitSubstitution
  1385. //
  1386. // Reads NLS native digit and digit substitution settings and records
  1387. // them in the SCRIPT_DIGITSUBSTITUTE structure.
  1388. //
  1389. //
  1390. typedef struct tag_SCRIPT_DIGITSUBSTITUTE {
  1391. DWORD NationalDigitLanguage :16; // Language for native substitution
  1392. DWORD TraditionalDigitLanguage :16; // Language for traditional substitution
  1393. DWORD DigitSubstitute :8; // Substitution type
  1394. DWORD dwReserved; // Reserved
  1395. } SCRIPT_DIGITSUBSTITUTE;
  1396. //
  1397. //
  1398. //p NationalDigitLanguage: Standard digits for the selected locale as
  1399. // defined by the countries/regions standard setting authority.
  1400. //
  1401. //p TraditionalDigitLangauge: Digits originally used with the locales
  1402. // script.
  1403. //
  1404. //p DigitSubstitute: Selects between None, Context, National and
  1405. // Traditional. See ScriptApplyDigitSubstitution below for
  1406. // constant definitions.
  1407. //
  1408. // Although most complex scripts have their own associated digits, many
  1409. // countries/regions using those scripts use western (so called
  1410. // 'Arabic') digits as their standard. NationalDigitLanguage reflects the
  1411. // digits used as standard, and is set from
  1412. // the NLS data for the locale.
  1413. // On Windows 2000 the national digit langauge can be
  1414. // adjusted to any digit script with the control panel/regional
  1415. // options/numbers/Standard digits listbox.
  1416. //
  1417. // The TraditionalDigitLanguage for a locale is derived directly from the
  1418. // script used by that locale.
  1419. HRESULT WINAPI ScriptRecordDigitSubstitution(
  1420. LCID Locale, // In LOCALE_USER_DEFAULT or desired locale
  1421. SCRIPT_DIGITSUBSTITUTE *psds); // Out Digit substitution settings
  1422. /////
  1423. //p Locale: NLS locale to be queried. Should usually be set to
  1424. // LOCALE_USER_DEFAULT. Alternatively may be passed as a locale
  1425. // combined with LOCALE_NOUSEROVERRIDE to obtain default settings
  1426. // for a given locale. Note that context digit substitution is
  1427. // supported only in ARABIC and FARSI locales. In other locales,
  1428. // context digit is mapped to no substitution.
  1429. //
  1430. //p psds: Pointer to SCRIPT_DIGITSUBSTITUTE. This structure may be passed
  1431. // later to ScriptApplyDigitSubstitution.
  1432. //
  1433. //p returns: E_INVALIDARG if Locale is invalid or not installed. E_POINTER
  1434. // if psds is NULL. Otherwise S_OK.
  1435. //
  1436. // For performance reasons, you should not call
  1437. // ScriptRecordDigitSubstitution frequently. In particular it would be a
  1438. // considerable overhead to call it every time you call ScriptItemize
  1439. // or ScriptStringAnalyse.
  1440. //
  1441. // Instead, you may choose to save the SCRIPT_DIGITSUBSTITUTE
  1442. // structure, and update it only when you receive a
  1443. // WM_SETTINGCHANGE message or when a RegNotifyChangeKeyValue
  1444. // call in a dedicated thread indicates a change in the registry
  1445. // under HKCU\Control Panel\\International.
  1446. //
  1447. // The normal way to call this function is simply
  1448. //
  1449. //c SCRIPT_DIGITSUBSTITUTE sds;
  1450. //c ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds);
  1451. //
  1452. // Then every time you itemize, you'd use the results like this:
  1453. //
  1454. //c SCRIPT_CONTROL sc = {0};
  1455. //c SCRIPT_STATE ss = {0};
  1456. //
  1457. //c ScriptApplyDigitSubstitution(&sds, &sc, &ss);
  1458. //
  1459. //
  1460. ///// ScriptApplyDigitSubstitution
  1461. //
  1462. // Aplies the digit substitution settings recorded in a
  1463. // SCRIPT_DIGIT_SUBSTITUTE structure to the SCRIPT_CONTROL and
  1464. // SCRIPT_STATE structures.
  1465. //
  1466. // The DigitSubstitute field of the SCRIPT_DIGITSUBSTITUTE structure
  1467. // is normally set by ScriptRecordDigitSubstitution, however it may
  1468. // be replaced by any one of the following values:
  1469. //
  1470. //
  1471. #define SCRIPT_DIGITSUBSTITUTE_CONTEXT 0 // Substitute to match preceeding letters
  1472. #define SCRIPT_DIGITSUBSTITUTE_NONE 1 // No substitution
  1473. #define SCRIPT_DIGITSUBSTITUTE_NATIONAL 2 // Substitute with official national digits
  1474. #define SCRIPT_DIGITSUBSTITUTE_TRADITIONAL 3 // Substitute with traditional digits of the locale
  1475. //
  1476. //
  1477. //p SCRIPT_DIGITSUBSTITUTE_CONTEXT: Digits U+0030 - U+0039 will be
  1478. // substituted according to the language of prior letters. Before
  1479. // any letters, digits will be substituted according to the
  1480. // TraditionalDigitLangauge field of the SCRIPT_DIGIT_SUBSTITUTE
  1481. // structure. This field is normally set to the primary language of
  1482. // the Locale passed to ScriptRecordDigitSubstitution.
  1483. //
  1484. //p SCRIPT_DIGITSUBSTITUTE_NONE: Digits will not be substituted. Unicode
  1485. // values U+0030 to U+0039 will be displayed with Arabic (i.e.
  1486. // Western) numerals.
  1487. //
  1488. //p SCRIPT_DIGITSUBSTITUTE_NATIONAL: Digits U+0030 - U+0039 will be
  1489. // substituted according to the NationalDigitLangauge field of
  1490. // the SCRIPT_DIGIT_SUBSTITUTE structure. This field is normally
  1491. // set to the national digits returned for the NLS LCTYPE
  1492. // LOCALE_SNATIVEDIGITS by ScriptRecordDigitSubstitution.
  1493. //
  1494. //p SCRIPT_DIGITSUBSTITUTE_TRADITIONAL: Digits U+0030 - U+0039 will be
  1495. // substituted according to the TraditionalDigitLangauge field of
  1496. // the SCRIPT_DIGIT_SUBSTITUTE structure. This field is normally
  1497. // set to the primary language of the Locale passed to
  1498. // ScriptRecordDigitSubstitution.
  1499. HRESULT WINAPI ScriptApplyDigitSubstitution(
  1500. const SCRIPT_DIGITSUBSTITUTE *psds, // In Digit substitution settings
  1501. SCRIPT_CONTROL *psc, // Out Script control structure
  1502. SCRIPT_STATE *pss); // Out Script state structure
  1503. /////
  1504. //p psds: Pointer to SCRIPT_DIGITSUBSTITUTE structure recorded earlier.
  1505. // If NULL, ScriptApplyDigitSubstitution calls
  1506. // ScriptRecordDigitSubstitution with LOCALE_USER_DEFAULT.
  1507. //
  1508. //p psc: SCRIPT_CONTROL structure. The fContextDigits and uDefaultLanguage
  1509. // fields will be updated.
  1510. //
  1511. //p pss: SCRIPT_CONTROL structure. The fDigitSubstitute field will be
  1512. // updated.
  1513. //
  1514. //p returns: E_INVALIDARG if the DigitSubstitute field of the
  1515. // SCRIPT_DIGITSUBSTITUTE structure is unrecognised, else S_OK;
  1516. #ifdef __cplusplus
  1517. }
  1518. #endif
  1519. #endif