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.

1924 lines
80 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  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 0400
  15. ///// USP - Unicode Complex Script processor
  16. //
  17. // Copyright (c) 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, // Middle-Of-Word 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 all output parameters are undefined.
  492. //
  493. //p psa: Pass the SCRIPT_ANALYSIS field of the SCRIPT_ITEM entry for this
  494. // item. (The SCRIPT_ITEM array is returned by ScriptItemize.)
  495. //
  496. // Clusters are sequenced uniformly within the run, as are glyphs within
  497. // the cluster - the fRTL item flag (from ScriptItemize) identifies
  498. // whether left to right, or right to left.
  499. //
  500. //p pwLogClust: has cChars elements - each entry in pwLogClust corresponds
  501. // to a character in the input string (pwcChars). The value in each
  502. // pwLogCLust entry is the offset of the first glyph in the cluster
  503. // that contains this character.
  504. //
  505. // Example: In the following example, there are four clusters:
  506. // 1st cluster: one character represented by one glyph
  507. // 2nd cluster: one character represented by 3 glyphs
  508. // 3rd cluster: three characters represented by one glyph
  509. // 4th cluster: 2 characters represented by three glyphs
  510. //
  511. // Glyph array: (c<n>g<m> means cluster n glyph m)
  512. //c 0 1 2 3 4 5 6 7
  513. //c -------------------------------------------------
  514. //c | c1g1 | c2g1 c2g2 c2g3 | c3g1 | c4g1 c4g2 c4g3 |
  515. //c -------------------------------------------------
  516. //
  517. // Character array: (c<n>u<m> means cluster n Unicode codepoint m)
  518. //c 0 1 2 3 4 5 6
  519. //c --------------------------------------------
  520. //c | c1u1 | c2u1 | c3u1 c3u2 c3u3 | c4u1 c4u2 |
  521. //c --------------------------------------------
  522. //
  523. // LogClust: (one entry per character gives 1st glyph in cluster
  524. //c --------------------------------------------
  525. //c | 0 | 1 | 4 4 4 | 5 5 |
  526. //c --------------------------------------------
  527. //
  528. // Note that for an RTL run (SCRIPT_ANALYSIS.a.fRTL == TRUE) and when
  529. // fLogicalOrder == FALSE (the default), glyphs are generated in visual
  530. // order - the reverse of the codepoint order, and the values in the
  531. // LogClust array will be descending.
  532. //
  533. //
  534. //p psva: has one visual attribute per glyph and so has maxGlyphs entries.
  535. //
  536. //
  537. // ScriptShape may set the fNoGlyphIndex flag in psa if the font or
  538. // OS cannot support glyph indices.
  539. //
  540. // If fLogicalOrder is requested in psa, glyphs will be always be
  541. // generated in the same order as the original Unicode characters.
  542. //
  543. // If fLogicalOrder is not set, right to left items are generated in
  544. // reverse order, so ScriptTextOut does not need to reverse them before
  545. // calling ExtTextOut.
  546. ///// ScriptPlace
  547. //
  548. // The ScriptPlace function takes the output of a ScriptShape call and
  549. // generates glyph advance width and 2D offset information.
  550. //
  551. // The composite ABC width for the whole item identifies how much the
  552. // glyphs overhang to the left of the start position and to the right of
  553. // the length implied by the sum of the advance widths.
  554. //
  555. // The total advance width of the line is exactly abcA + abcB + abcC.
  556. //
  557. // abcA and abcC are maintained internally by Uniscribe as proportions
  558. // of the cell height represented in 8 bits and are thus roughly +/- 1%.
  559. // The total width returned (as the sum of piAdvance, and as the sum of
  560. // abcA+abcB+abcC) is accurate to the resolution of the TrueType shaping
  561. // engine.
  562. //
  563. // All glyph related arrays are in visual order unless the fLogicalOrder
  564. // flag is set in psa.
  565. #ifndef LSDEFS_DEFINED
  566. typedef struct tagGOFFSET {
  567. LONG du;
  568. LONG dv;
  569. } GOFFSET;
  570. #endif
  571. HRESULT WINAPI ScriptPlace(
  572. HDC hdc, // In Optional (see under caching)
  573. SCRIPT_CACHE *psc, // InOut Cache handle
  574. const WORD *pwGlyphs, // In Glyph buffer from prior ScriptShape call
  575. int cGlyphs, // In Number of glyphs
  576. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  577. SCRIPT_ANALYSIS *psa, // InOut Result of ScriptItemize (may have fNoGlyphIndex set)
  578. int *piAdvance, // Out Advance wdiths
  579. GOFFSET *pGoffset, // Out x,y offset for combining glyph
  580. ABC *pABC); // Out Composite ABC for the whole run (Optional)
  581. ///// ScriptTextOut
  582. //
  583. // The ScriptTextOut function takes the output of both ScriptShape and
  584. // ScriptPlace calls and calls the operating system ExtTextOut function
  585. // appropriately. If the last parameter is not null, GDI's ExtTextOutW calls
  586. // are routed to this function.
  587. //
  588. // All arrays are in visual order unless the fLogicalOrder flag is set in
  589. // psa.
  590. HRESULT WINAPI ScriptTextOut(
  591. const HDC hdc, // In OS handle to device context (required)
  592. SCRIPT_CACHE *psc, // InOut Cache handle
  593. int x, // In x,y position for first glyph
  594. int y, // In
  595. UINT fuOptions, // In ExtTextOut options
  596. const RECT *lprc, // In optional clipping/opaquing rectangle
  597. const SCRIPT_ANALYSIS *psa, // In Result of ScriptItemize
  598. const WCHAR *pwcReserved, // In Reserved (requires NULL)
  599. int iReserved, // In Reserved (requires 0)
  600. const WORD *pwGlyphs, // In Glyph buffer from prior ScriptShape call
  601. int cGlyphs, // In Number of glyphs
  602. const int *piAdvance, // In Advance widths from ScriptPlace
  603. const int *piJustify, // In Justified advance widths (optional)
  604. const GOFFSET *pGoffset); // In x,y offset for combining glyph
  605. /////
  606. //
  607. // The caller should normally use SetTextAlign(hdc, TA_RIGHT) before
  608. // calling ScriptTextOut with an RTL item inlogical order.
  609. //
  610. // The piJustify array provides requested cell widths for each glyph.
  611. // When the piJustify width of a glyph differs from the unjustified
  612. // width (in PiAdvance), space is added to or removed from the glyph
  613. // cell at it's trailing edge. The glyph is always aligned with the
  614. // leading edge of it's cell. (This rule applies even in visual order.)
  615. //
  616. // When a glyph cell is extended the extra space is uaually made up by
  617. // the addition of white space, however for Arabic scripts, the extra
  618. // space is made up by one or more kashida glyphs, unless the extra space
  619. // is insufficient for the shortest kashida glyph in the font. (The
  620. // width of the shortest kashida is available by calling
  621. // ScriptGetFontProperties.)
  622. //
  623. // piJustify should only be passed if re-justification of the string is
  624. // required. Normally pass NULL to this parameter.
  625. //
  626. // fuOptions may contain ETO_CLIPPED or ETO_OPAQUE (or neither or both).
  627. //
  628. // Do not use ScriptTextOut to write to a metafile unless you are sure
  629. // that the metafile will eventually be played back without any font
  630. // substitution. ScriptTextOut record glyph numbers in the metafile.
  631. // Since glyph numbers vary considerably from one font to another
  632. // such a metafile is unlikely to play back correctly when differant
  633. // fonts are substituted.
  634. //
  635. // For example when a metafile is played back at a different scale
  636. // CreateFont requests recorded in the metafile may resolve to bitmap
  637. // instead of truetype fonts, or if the metafile is played back on
  638. // a different machine requested fonts may not be installed.//
  639. //
  640. // To write complex scripts in a metafile in a font independant manner,
  641. // use ExtTextOut to write the logical characters directly, so that
  642. // glyph generation and placement does not occur until the text is
  643. // played back.
  644. ///// ScriptJustify
  645. //
  646. // ScriptJustify provides a simple minded implementation of multilingual
  647. // justification.
  648. //
  649. // Sophisticated text formatters may prefer to generate their own delta
  650. // dx array by combining their own features with the information returned
  651. // by ScriptShape in the SCRIPT_VISATTR array.
  652. //
  653. // ScriptJustify establishes how much adjustment to make at each glyph
  654. // position on the line. It interprets the SCRIPT_VISATTR array generated
  655. // by a call to ScriptShape, and gives top priority to kashida, then uses
  656. // inter word spacing if there's no kashida points, then uses
  657. // intercharacter spacing if there are no inter-word points.
  658. //
  659. // The justified advance widths generated in ScriptJustify should be
  660. // passed to ScriptTextOut in the piJustify paramter.
  661. //
  662. // ScriptJustify creates a justify array containing updated advance
  663. // widths for each glyph. Where a glyphs advance width is increased, it
  664. // is expected that the extra width will be rendered to the right of the
  665. // glyph, with as white space or, for Arabic text, as kashida.
  666. /////
  667. HRESULT WINAPI ScriptJustify(
  668. const SCRIPT_VISATTR *psva, // In Collected visual attributes for entire line
  669. const int *piAdvance, // In Advance widths from ScriptPlace
  670. int cGlyphs, // In Size of all arrays
  671. int iDx, // In Desired width change, either increase or descrease
  672. int iMinKashida, // In Minimum length of continuous kashida glyph to generate
  673. int *piJustify); // Out Updated advance widths to pass to ScriptTextOut
  674. ///// SCRIPT_LOGATTR
  675. //
  676. // The SCRIPT_LOGATTR structure describes attributes of logical
  677. // characters useful when editing and formatting text.
  678. //
  679. // Note that for wordbreaking and linebreaking, if the first character of
  680. // the run passed in is not whitespace, the client needs to check whether
  681. // the last character of the previous run is whitespace to determine if
  682. // the first character of this run is the start of a word.
  683. //
  684. //
  685. typedef struct tag_SCRIPT_LOGATTR {
  686. BYTE fSoftBreak :1; // Potential linebreak point
  687. BYTE fWhiteSpace :1; // A unicode whitespace character, except NBSP, ZWNBSP
  688. BYTE fCharStop :1; // Valid cursor position (for left/right arrow)
  689. BYTE fWordStop :1; // Valid cursor position (for ctrl + left/right arrow)
  690. BYTE fInvalid :1; // Invalid character sequence
  691. BYTE fReserved :3;
  692. } SCRIPT_LOGATTR;
  693. //
  694. //
  695. //p fSoftBreak: It would be valid to break the line in front of this
  696. // character. This flag is set on the first character of
  697. // South-East Asian words. Note that when linebreaking the
  698. // client would usually also treat any nonblank following a blank
  699. // as a softbreak position, by inspecting the fWhiteSPace flag
  700. // below.
  701. //
  702. //p fWhiteSpace: This character is one of the many Unicode character
  703. // that are classified as breakable whitespace.
  704. //
  705. //p fCharStop: Valid cursor position. Set on most characters, but not
  706. // on codepoints inside Indian and South East Asian character
  707. // clusters. May be used to implement left and right arrow
  708. // operation in editors.
  709. //
  710. //p fWordStop: Valid position following word advance/retire commonly
  711. // implemented at ctrl/left-arrow and ctrl/right-arrow.
  712. // May be used to implement ctrl+left and ctrl+right arrow
  713. // operation in editors. As with fSoftBreak clients should
  714. // normally also inspect the fWhiteSpace flag and treat the
  715. // first character after a run of whitespace as the start of a
  716. // word.
  717. //
  718. //p fInvalid: Marks characters which form an invalid or undisplayable
  719. // combination. Scripts which can set this flag have the flag
  720. // fInvalidLogAttr set in their SCRIPT_PROPERTIES.
  721. ///// ScriptBreak
  722. //
  723. // The ScriptBreak function returns cursor movement and formatting break
  724. // positions for an item as an array of SCRIPT_LOGATTRs. To support
  725. // mixed formatting within a single word correctly, ScriptBreak should
  726. // be passed whole items as returned by ScriptItemize.
  727. //
  728. // ScriptBreak does not require an hdc and does not execute glyph shaping.
  729. //
  730. // The fCharStop flag marks cluster boundaries for those scripts where
  731. // it is conventional to restrict from moving inside clusters. The same
  732. // boundaries could also be inferred by inspecting the pLogCLust array
  733. // returned by ScriptShape, however ScriptBreak is considerably faster in
  734. // implementation and does not require an hdc to be prepared.
  735. //
  736. // The fWordStop, fSoftBreak and fWhiteSpace flags are only available
  737. // through ScriptBreak.
  738. //
  739. // Most shaping engines that identify invalid sequences do so by setting
  740. // the fInvalid flag in ScriptBreak. The fInvalidLogAttr flag in
  741. // ScriptProperties identifies which scripts do this.
  742. HRESULT WINAPI ScriptBreak(
  743. const WCHAR *pwcChars, // In Logical unicode item
  744. int cChars, // In Length of unicode item
  745. const SCRIPT_ANALYSIS *psa, // In Result of earlier ScriptItemize call
  746. SCRIPT_LOGATTR *psla); // Out Logical character attributes
  747. ///// ScriptCPtoX
  748. //
  749. // The ScriptCPtoX function returns the x offset from the left end
  750. // (!fLogical) or leading edge (fLogical) of a run to either the leading
  751. // or the trailing edge of a logical character cluster.
  752. //
  753. // iCP is the offset of any logical character in the cluster.
  754. //
  755. // For scripts where the caret may conventionally be placed into the
  756. // middle of clusters (e.g. Arabic, Hebrew), the returned X may be
  757. // an interpolated position for any codepoint in the line.
  758. //
  759. // For scripts where the caret is conventionally snapped to the boundaries
  760. // of clusters, (e.g. Thai, Indian), the resulting X position will be
  761. // snapped to the requested edge of the cluster containing CP.
  762. HRESULT WINAPI ScriptCPtoX(
  763. int iCP, // In Logical character position in run
  764. BOOL fTrailing, // In Which edge (default - leading)
  765. int cChars, // In Count of logical codepoints in run
  766. int cGlyphs, // In Count of glyphs in run
  767. const WORD *pwLogClust, // In Logical clusters
  768. const SCRIPT_VISATTR *psva, // In Visual glyph attributes array
  769. const int *piAdvance, // In Advance widths
  770. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  771. int *piX); // Out Resulting X position
  772. ///// ScriptXtoCP
  773. //
  774. // The ScriptXtoCP function converts an x offset from the left end
  775. // (!fLogical) or leading edge (fLogical) of a run to a logical
  776. // character position and a flag that indicates whether the X position
  777. // fell in the leading or the trailing half of the character.
  778. //
  779. // For scripts where the cursor may conventionally be placed into the
  780. // middle of clusters (e.g. Arabic, Hebrew), the returned CP may be
  781. // for any codepoint in the line, and fTrailing will be either zero
  782. // or one.
  783. //
  784. // For scripts where the cursor is conventionally snapped to the
  785. // boundaries of a cluster, the returned CP is always the position of
  786. // the logically first codepoint in a cluster, and fTrailing is either
  787. // zero, or the number of codepoints in the cluster.
  788. //
  789. // Thus the appropriate cursor position for a mouse hit is always the
  790. // returned CP plus the value of fTrailing.
  791. //
  792. // If the X positition passed is not in the item at all, the resulting
  793. // position will be the trailing edge of character -1 (for X positions
  794. // before the item), or the leading edge of character 'cChars' (for
  795. // X positions following the item).
  796. HRESULT WINAPI ScriptXtoCP(
  797. int iX, // In X offset from left of run
  798. int cChars, // In Count of logical codepoints in run
  799. int cGlyphs, // In Count of glyphs in run
  800. const WORD *pwLogClust, // In Logical clusters
  801. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  802. const int *piAdvance, // In Advance widths
  803. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  804. int *piCP, // Out Resulting character position
  805. int *piTrailing); // Out Leading or trailing half flag
  806. ///// Relationship between caret positions, justifications points and clusters
  807. //
  808. //
  809. //t Job | Uniscribe support
  810. //t -------------------------------- | --------------------------------------------------------
  811. //t Caret move by character cluster | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
  812. //t Line breaking between characters | LogClust or VISATTR.fClusterStart or LOGATTR.fCharStop
  813. //t Caret move by word | LOGATTR.fWordStop
  814. //t Line breaking between words | LOGATTR.fWordStop
  815. //t Justification | VISATTR.uJustification
  816. //
  817. //
  818. //
  819. ///// Character clusters
  820. //
  821. // Character clusters are glyph sequences that cannot be split between
  822. // lines.
  823. //
  824. // Some languages (e.g. Thai, Indic) restrict caret placement to points
  825. // betwen clusters. This applies both to keyboard initiated caret
  826. // movement (e.g. cursor keys) and pointing and clicking with the mouse
  827. // (hit testing).
  828. //
  829. // Uniscribe provides cluster information in both the visual and logical
  830. // attributes. If you've called ScriptShape you'll find the cluster
  831. // information represented both by sequences of the same value in the
  832. // pwLogClust array, and by the fClusterStart flag in the psva
  833. // SCRIPT_VISATTR array.
  834. //
  835. // ScriptBreak also returns the fCharStop flag in the SCRIPT_LOGATTR
  836. // array to identify cluster positions.
  837. //
  838. //
  839. //
  840. ///// Word break points
  841. //
  842. // Valid positions for moving the caret when moving in whole words are
  843. // marked by the fWordStop flag returned by ScriptBreak.
  844. //
  845. // Valid positions for breaking lines between words are marked by the
  846. // fSoftBreak flag returned by ScriptBreak.
  847. //
  848. //
  849. //
  850. ///// Justification
  851. //
  852. // Justification space or kashida should be inserted where identified by
  853. // the uJustificaion field of the SCRIPT_VISATTR.
  854. //
  855. // When performing inter-character justification, insert extra space
  856. // only after glyphs marked with uJustify == SCRIPT_JUSTIFY_CHARACTER.
  857. //
  858. //
  859. //
  860. ///// Script specific processing
  861. //
  862. // Uniscribe provides information about special processing for each
  863. // script in the SCRIPT_PROPERTIES array.
  864. //
  865. // Use the following code during initialisation to get a pointer to
  866. // the SCRIPT_PROPERTIES array:
  867. //
  868. //c const SCRIPT_PROPERTIES **g_ppScriptProperties; // Array of pointers to properties
  869. //c int iMaxScript;
  870. //c HRESULT hr;
  871. //
  872. //c hr = ScriptGetProperties(&g_ppScriptProperties, &g_iMaxScript);
  873. //
  874. // Then inspect the properties of the script of an item 'iItem' as follows:
  875. //
  876. //c hr = ScriptItemize( ... , pItems, ... );
  877. //c ...
  878. //c if (g_ppScriptProperties[pItems[iItem].a.eScript]->fNeedsCaretInfo) {
  879. //c // Use ScriptBreak to restrict the caret from entering clusters (for example).
  880. //c }
  881. //
  882. //
  883. // SCRIPT_PROPERTIES.fNeedsCaretInfo
  884. //
  885. // Caret placement should be restricted to cluster
  886. // edges for scripts such as Thai and Indian. The fNeedsCaretInfo flag
  887. // in SCRIPT_PROPERTIES identifies such languages.
  888. //
  889. // Note that ScriptXtoCP and ScriptCPtoX automatically apply caret
  890. // placement restictions.
  891. //
  892. //
  893. // SCRIPT_PROPERTIES.fNeedsWordBreaking
  894. //
  895. // For most scripts, word break placement may be
  896. // identified by scanning for characters marked as fWhiteSpace in
  897. // SCRIPT_LOGATTR, or for glyphs marked as uJustify ==
  898. // SCRIPT_JUSTIFY_BLANK or SCRIPT_JUSTIFY_ARABIC_BLANK in SCRIPT_VISATTR.
  899. //
  900. // For languages such as Thai, it is also necessary to call ScriptBreak,
  901. // and include character positions marked as fWordStop in SCRIPT_LOGATTR.
  902. // Such scripts are marked as fNeedsWordbreaking in SCRIPT_PROPERTIES.
  903. //
  904. //
  905. // SCRIPT_PROPERTIES.fNeedsCharacterJustify
  906. //
  907. // Languages such as Thai also require inter-character spacing when
  908. // justifying (where uJustify == SCRIPT_JUSTIFY_CHARACTER in the
  909. // SCRIPT_VISATTR). Such languages are marked as fNeedsCharacterJustify
  910. // in SCRIPT_PROPERTIES.
  911. //
  912. //
  913. // SCRIPT_PROPERTIES.fAmbiguousCharSet
  914. //
  915. // Many Uniscribe scripts do not correspond directly to 8 bit character
  916. // sets. For example Unicode characters in the range U+100 through U+024F
  917. // represent extended latin shapes used for many languages, including
  918. // those supported by EASTEUROPE_CHARSET, TURKISH_CHARSET and
  919. // VIETNAMESE_CHARSET. However many of these characters are supported by
  920. // more han one of thsese charsets.
  921. // fAmbiguousCharset is set for any script token which could contain
  922. // characters from a number of these charsets. In these cases the bCharSet
  923. // field may contain ANSI_CHARSET or DEFAULT_CHARSET. The Uniscribe client
  924. // will generally need to apply futher processing to determine which charset
  925. // to use when requesting a font suitable for this run. For example it
  926. // determine that the run consists of multiple languages and split it up
  927. // to use a different font for each language.
  928. ///// Notes on ScriptXtoCP and ScriptCPtoX
  929. //
  930. // Both functions work only within runs and require the results of a
  931. // previous ScriptShape call.
  932. //
  933. // The client must establish which run a given cursor offset or x
  934. // position is within before passing it to ScriptCPtoX or ScriptXtoCP.
  935. //
  936. // Cluster information in the logical cluster array is used to share
  937. // the width of a cluster of glyphs equally among the logical characters
  938. // they represent.
  939. //
  940. // For example, the lam alif glyph is divided into four areas: the
  941. // leading half of the lam, the trailing half of the lam, the leading
  942. // half of the alif and the trailing half of the alif.
  943. //
  944. // ScriptXtoCP Understands the caret position conventions of each script.
  945. // For Indian and Thai, caret positions are snapped to cluster boundaries,
  946. // for Arabic and Hebrew, caret positions are interpolated within clusters.
  947. //
  948. //
  949. ///// Translating mouse hit 'x' offset to caret position
  950. //
  951. // Conventionally, caret position 'cp' may be selected by clicking either
  952. // on the trailing half of character 'cp-1' or on the leading half of
  953. // character 'cp'. This may easily be implemented as follows:
  954. //
  955. //c int iCharPos;
  956. //c int iCaretPos
  957. //c int fTrailing;
  958. //
  959. //c ScriptXtoCP(iMouseX, ..., &iCharPos, &fTrailing);
  960. //c iCaretPos = iCharPos + fTrailing;
  961. //
  962. // For scripts that snap the caret to cluster boundaries, ScriptXtoCP
  963. // returns ftrailing set to either 0, or the width of the cluster in
  964. // codepoints. Thus the above code correctly returns only valid
  965. // caret positions.
  966. //
  967. //
  968. ///// Displaying the caret in bidi strings
  969. //
  970. // In unidirectional text, the leading edge of a character is at the same
  971. // place as the trailing edge of the previous character, so there is no
  972. // ambiguity in placing the caret between characters.
  973. //
  974. // In bidirectional text, the caret position between runs of opposing
  975. // direction may be ambiguous.
  976. //
  977. // For example in the left to right paragraph 'helloMAALAS', the last
  978. // letter of 'hello' immediately preceeds the first letter of 'salaam'.
  979. // The best position to display the caret depends on whether it is
  980. // considered to follow the 'o' of 'hello', or to preceed the 's' of
  981. // 'salaam'.
  982. //
  983. ///// Commonly used caret positioning conventions
  984. //
  985. //t Situation | Visual caret placement
  986. //t --------- | -------------------------------------------
  987. //t Typing | Trailing edge of last character typed
  988. //t Pasting | Trailing edge of last character pasted
  989. //t Caret advancing | Trailing edge of last character passed over
  990. //t Caret retiring | Leading edge of last character passed over
  991. //t Home | Leading edge of line
  992. //t End | Trailing edge of line
  993. //
  994. // The caret may be positioned as follows:
  995. //
  996. //c if (advancing) {
  997. //c ScriptCPtoX(iCharPos-1, TRUE, ..., &iCaretX);
  998. //c } else {
  999. //c ScriptCPtoX(iCharPos, FALSE, ..., &iCaretX);
  1000. //c }
  1001. //
  1002. // Or, more simply, given an fAdvancing BOOL restricted to TRUE or FALSE:
  1003. //
  1004. //c ScriptCPtoX(iCharPos-fAdvancing, fAdvancing, ..., &iCaretX);
  1005. //
  1006. // ScriptCPtoX handles out of range positions logically: it returns the
  1007. // leading edge of the run for iCharPos <0, and the trailing edge of the
  1008. // run for iCharPos >=length.
  1009. ///// ScriptGetLogicalWidths
  1010. //
  1011. // Converts visual withs in piAdvance into logical widths,
  1012. // one per original character, in logical order.
  1013. //
  1014. // Ligature glyphs widths are divided evenly amongst the characters
  1015. // they represent.
  1016. HRESULT WINAPI ScriptGetLogicalWidths(
  1017. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  1018. int cChars, // In Count of logical codepoints in run
  1019. int cGlyphs, // In Count of glyphs in run
  1020. const int *piGlyphWidth, // In Advance widths
  1021. const WORD *pwLogClust, // In Logical clusters
  1022. const SCRIPT_VISATTR *psva, // In Visual glyph attributes
  1023. int *piDx); // Out Logical widths
  1024. /////
  1025. // ScriptGetLogicalWidths is useful for recording widths in a
  1026. // font independant manner. By passing the recorded logical widths
  1027. // to ScriptApplyLogicalWidths, a block of text can be replayed in the
  1028. // same boundaries with acceptable loss of quality even when the original
  1029. // font is not available.
  1030. ///// ScriptApplyLogicalWidth
  1031. //
  1032. // Accepts an array of advance widths in logical order, corresponding
  1033. // one to one with codepoints, and generates an array of glyph widths
  1034. // suitable for passing to the piJustify parameter of ScriptTextOut.
  1035. //
  1036. // ScriptApplyLogicalWidth may be used to reapply logical widths
  1037. // obtained with ScriptGetLogicalWidths. It may be useful in situations
  1038. // such as metafiling, where it is necessary to record and reapply
  1039. // advance width information in a font independant manner.
  1040. HRESULT WINAPI ScriptApplyLogicalWidth(
  1041. const int *piDx, // In Logical dx array to apply
  1042. int cChars, // In Count of logical codepoints in run
  1043. int cGlyphs, // In Glyph count
  1044. const WORD *pwLogClust, // In Logical clusters
  1045. const SCRIPT_VISATTR *psva, // In Visual attributes from ScriptShape/Place
  1046. const int *piAdvance, // In Glyph advance widths from ScriptPlace
  1047. const SCRIPT_ANALYSIS *psa, // In Script analysis from item attributes
  1048. ABC *pABC, // InOut Updated item ABC width (optional)
  1049. int *piJustify); // Out Resulting glyph advance widths for ScriptTextOut
  1050. /////
  1051. //p piDx: Pointer to an array of dx widths in logical order, one per codepoint.
  1052. //
  1053. //p cChars: Count of the logical codepoints in the run.
  1054. //
  1055. //p cGlyphs: Glyph count.
  1056. //
  1057. //p pwLogClust: Pointer to an array of logical clusters from ScriptShape
  1058. //
  1059. //p psva: Pointer to an array of visual attributes from ScriptShape and
  1060. // updated by ScriptPlace.
  1061. //
  1062. //p piAdvance: Pointer to an array of glyph advance widths from ScriptPlace.
  1063. //
  1064. //p psa: Pointer to a SCRIPT_ANALYSIS structure from ScriptItemize and
  1065. // updated by ScriptShape and SriptPlace..
  1066. //
  1067. //p pABC: Pointer to the run overall ABC width (optional). If present,
  1068. // when the function is called, it should contain the run ABC width
  1069. // returned by ScriptPlace; when the function returns, the ABC width
  1070. // has been updated to match the new widths.
  1071. //
  1072. //p piJustify:Pointer to an array of the resulting glyph advance widths.
  1073. // This is suitable for passing to the piJustify parameter of ScriptTextOut.
  1074. ///// ScriptGetCMap
  1075. //
  1076. // ScriptGetCMap may be used to determine which characters in a run
  1077. // are supported by the selected font.
  1078. //
  1079. // It returns glyph indices of Unicode characters according to Truetype
  1080. // Cmap table, or standard Cmap implemented for old style fonts. The
  1081. // glyph indices are returned in the same order as the input string.
  1082. //
  1083. // The caller may scan the returned glyph buffer looking for the default
  1084. // glyph to determine which characters are not available. (The default
  1085. // glyph index for the selected font should be determined by calling
  1086. // ScriptGetFontProperties).
  1087. //
  1088. // The return value indicates the presence of any missing glyphs.
  1089. #define SGCM_RTL 0x00000001 // Return mirrored glyph for mirrorable Unicode codepoints
  1090. HRESULT WINAPI ScriptGetCMap(
  1091. HDC hdc, // In Optional (see notes on caching)
  1092. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1093. const WCHAR *pwcInChars, // In Unicode codepoint(s) to look up
  1094. int cChars, // In Number of characters
  1095. DWORD dwFlags, // In Flags such as SGCM_RTL
  1096. WORD *pwOutGlyphs); // Out Array of glyphs, one per input character
  1097. /////
  1098. // returns S_OK - All unicode codepoints were present in the font
  1099. // S_FALSE - Some of the Unicode codepoints were mapped to the default glyph
  1100. // E_HANDLE - font or system does not support glyph indices
  1101. ///// ScriptGetGlyphABCWidth
  1102. //
  1103. // Returns ABC width of a given glyph.
  1104. // May be useful for drawing glyph charts. Should not be used for
  1105. // run of the mill complex script text formatting.
  1106. HRESULT WINAPI ScriptGetGlyphABCWidth(
  1107. HDC hdc, // In Optional (see notes on caching)
  1108. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1109. WORD wGlyph, // In Glyph
  1110. ABC *pABC); // Out ABC width
  1111. /////
  1112. // returns S_OK - Glyph width returned
  1113. // E_HANDLE - font or system does not support glyph indices
  1114. ///// SCRIPT_PROPERTIES
  1115. //
  1116. typedef struct {
  1117. DWORD langid :16; // Primary and sublanguage associated with script
  1118. DWORD fNumeric :1;
  1119. DWORD fComplex :1; // Script requires special shaping or layout
  1120. DWORD fNeedsWordBreaking :1; // Requires ScriptBreak for word breaking information
  1121. DWORD fNeedsCaretInfo :1; // Requires caret restriction to cluster boundaries
  1122. DWORD bCharSet :8; // Charset to use when creating font
  1123. DWORD fControl :1; // Contains only control characters
  1124. DWORD fPrivateUseArea :1; // This item is from the Unicode range U+E000 through U+F8FF
  1125. DWORD fNeedsCharacterJustify :1; // Requires inter-character justification
  1126. DWORD fInvalidGlyph :1; // Invalid combinations generate glyph wgInvalid in the glyph buffer
  1127. DWORD fInvalidLogAttr :1; // Invalid combinations are marked by fInvalid in the logical attributes
  1128. DWORD fCDM :1; // Contains Combining Diacritical Marks
  1129. DWORD fAmbiguousCharSet :1; // Script does not correspond 1:1 with a charset
  1130. DWORD fClusterSizeVaries :1; // Measured cluster width depends on adjacent clusters
  1131. DWORD fRejectInvalid :1; // Invalid combinations should be rejected
  1132. } SCRIPT_PROPERTIES;
  1133. //
  1134. //p langid: Language associated with this script. When a script is used for many languages,
  1135. // langid id represents a default language. For example, Western script is represented
  1136. // by LANG_ENGLISH although it is also used for French, German, Spanish etc.
  1137. //
  1138. //p fNumeric: Script contains numerics and characters used in conjunction with numerics
  1139. // by the rules of the Unicode bidirectional algorithm. For example
  1140. // dollar sign and period are classified as numeric when adjacent to or in between
  1141. // digits.
  1142. //
  1143. //p fComplex: Indicates a script that requires complex script handling. If fComplex is false
  1144. // the script contains no combining characters and requires no contextual shaping or reordering.
  1145. //
  1146. //p fNeedsWordBreaking: A script, such as Thai, which requires algorithmic wordbreaking.
  1147. // Use ScriptBreak to obtain a wordbreak points using the standard system wordbreaker.
  1148. //
  1149. //p fNeedsCaretInfo: A script, such as Thai and Indian, where the caret may not be placed
  1150. // inside a cluster. To determine valid caret positions inspect the fCharStop flag in the
  1151. // logical attributes returned by ScriptBreak, or compare adjacent values in the pwLogClust
  1152. // array returned by ScriptShape.
  1153. //
  1154. //p bCharSet: Nominal charset associated with script. May be used in a logfont when creating
  1155. // a font suitable for displaying this script. Note that for new scripts where there
  1156. // is no charset defined, bCharSet may be innapropriate and DEFAULT_CHARSET should
  1157. // be used instead - see the description of fAmbiguousCharSet below.
  1158. //
  1159. //p fControl: contains control characters.
  1160. //
  1161. //p fPrivateUseArea: The Unicode range U+E000 through U+F8FF.
  1162. //
  1163. //p fNeedsCharacterJustify: A script, such as Thai, where justification is conventionally
  1164. // achieved by increasing the space between all letters, not just between words.
  1165. //
  1166. //p fInvalidGlyph: A script for which ScriptShape generates an invalid glyph
  1167. // to represent invalid sequences. The glyph index of the invalid glyph for
  1168. // a particular font may be obtained by calling ScriptGetFontProperties.
  1169. //
  1170. //p fInvalidLogAttr: A script for which ScriptBreak sets the fInvalid flag
  1171. // in the logical attributes to mark invalid sequences.
  1172. //
  1173. //p fCDM: Implies that an item analysed by ScriptItemize included combining
  1174. // diacritical marks (U+0300 through U+36F).
  1175. //
  1176. //p fAmbiguousCharSet: No single legacy charset supports this script.
  1177. // For example the extended Latin Extended-A Unicode range includes
  1178. // characters from the EASTUROPE_CHARSET, the TURKISH_CHARSET and the
  1179. // BALTIC_CHARSET. It also contains characters that are not available
  1180. // in any legacy charset. Use DEFAULT_CHARSET when creating fonts to
  1181. // display parts of this run.
  1182. //
  1183. //p fClusterSizeVaries: A script, such as Arabic, where contextual shaping
  1184. // may cause a string to increase in size when removing characters.
  1185. //
  1186. //p fRejectInvalid: A script, such as Thai, where invalid sequences conventionally
  1187. // cause an editor such as notepad to beep, and ignore keypresses.
  1188. ///// ScriptGetProperties
  1189. //
  1190. // ScriptGetProperties returns the address of a table that maps a
  1191. // script in a SCRIPT_ANALYSIS uScript field to properties including
  1192. // the primary language associated with that script, whether it's
  1193. // numeric and whether it's complex.
  1194. HRESULT WINAPI ScriptGetProperties(
  1195. const SCRIPT_PROPERTIES ***ppSp, // Out Receives pointer to table of pointers to properties indexed by script
  1196. int *piNumScripts); // Out Receives number of scripts (valid values are 0 through NumScripts-1)
  1197. ///// SCRIPT_FONTPROPERTIES
  1198. //
  1199. typedef struct {
  1200. int cBytes; // Structure length
  1201. WORD wgBlank; // Blank glyph
  1202. WORD wgDefault; // Glyph used for Unicode values not present in the font
  1203. WORD wgInvalid; // Glyph used for invalid character combinations (especially in Thai)
  1204. WORD wgKashida; // Shortest continuous kashida glyph in the font, -1 if doesn't exist
  1205. int iKashidaWidth; // Widths of shortest continuous kashida glyph in the font
  1206. } SCRIPT_FONTPROPERTIES;
  1207. ///// ScriptGetFontProperties
  1208. //
  1209. // Returns information from the font cache
  1210. HRESULT WINAPI ScriptGetFontProperties(
  1211. HDC hdc, // In Optional (see notes on caching)
  1212. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1213. SCRIPT_FONTPROPERTIES *sfp); // Out Receives properties for this font
  1214. ///// ScriptCacheGetHeight
  1215. //
  1216. //
  1217. HRESULT WINAPI ScriptCacheGetHeight(
  1218. HDC hdc, // In Optional (see notes on caching)
  1219. SCRIPT_CACHE *psc, // InOut Address of Cache handle
  1220. long *tmHeight); // Out Receives font height in pixels
  1221. ///// ScriptStringAnalyse
  1222. //
  1223. //
  1224. #define SSA_PASSWORD 0x00000001 // Input string contains a single character to be duplicated iLength times
  1225. #define SSA_TAB 0x00000002 // Expand tabs
  1226. #define SSA_CLIP 0x00000004 // Clip string at iReqWidth
  1227. #define SSA_FIT 0x00000008 // Justify string to iReqWidth
  1228. #define SSA_DZWG 0x00000010 // Provide representation glyphs for control characters
  1229. #define SSA_FALLBACK 0x00000020 // Use fallback fonts
  1230. #define SSA_BREAK 0x00000040 // Return break flags (character and word stops)
  1231. #define SSA_GLYPHS 0x00000080 // Generate glyphs, positions and attributes
  1232. #define SSA_RTL 0x00000100 // Base embedding level 1
  1233. #define SSA_GCP 0x00000200 // Return missing glyphs and LogCLust with GetCharacterPlacement conventions
  1234. #define SSA_HOTKEY 0x00000400 // Replace '&' with underline on subsequent codepoint
  1235. #define SSA_METAFILE 0x00000800 // Write items with ExtTextOutW Unicode calls, not glyphs
  1236. #define SSA_LINK 0x00001000 // Apply FE font linking/association to non-complex text
  1237. #define SSA_HIDEHOTKEY 0x00002000 // Remove first '&' from displayed string
  1238. #define SSA_HOTKEYONLY 0x00002400 // Display underline only.
  1239. #define SSA_FULLMEASURE 0x04000000 // Internal - calculate full width and out the number of chars can fit in iReqWidth.
  1240. #define SSA_LPKANSIFALLBACK 0x08000000 // Internal - enable FallBack for all LPK Ansi calls Except BiDi hDC calls
  1241. #define SSA_PIDX 0x10000000 // Internal
  1242. #define SSA_LAYOUTRTL 0x20000000 // Internal - Used when DC is mirrored
  1243. #define SSA_DONTGLYPH 0x40000000 // Internal - Used only by GDI during metafiling - Use ExtTextOutA for positioning
  1244. #define SSA_NOKASHIDA 0x80000000 // Internal - Used by GCP to justify the non Arabic glyphs only.
  1245. //
  1246. //
  1247. //p SSA_HOTKEY: Note that SSA_HOTKEY and SSA_HIDEHOTKEY remove the
  1248. // hotkey '&' character from further processing, so functions
  1249. // such as ScriptString_pLogAttr return arrays based on a string
  1250. // which excludes the '&'.
  1251. ///// SCRIPT_TABDEF
  1252. //
  1253. // Defines tabstop positions for ScriptStringAnalyse (ignored unless SSA_TAB passed)
  1254. //
  1255. typedef struct tag_SCRIPT_TABDEF {
  1256. int cTabStops; // Number of entries in pTabStops array
  1257. int iScale; // Scale factor for pTabStops (see below)
  1258. int *pTabStops; // Pointer to array of one or more tab stops
  1259. int iTabOrigin; // Initial offset for tab stops (logical units)
  1260. } SCRIPT_TABDEF;
  1261. //
  1262. //
  1263. //p cTabStops: Number of entries in the pTabStops array. If zero, tabstops
  1264. // are every 8 average character widths. If one, all tabstops are
  1265. // the length of the first entry in pTabStops. If more than one,
  1266. // the first cTabStops are as specified in the pTabStops array,
  1267. // subsequent tabstops are every 8 average characters from the last
  1268. // tabstop in the array.
  1269. //
  1270. //p iScale: Scale factor for iTabOrigin and pTabStops entries. Values are
  1271. // converted to device coordinates by multiplying by iScale then
  1272. // dividing by 4. If values are already in device units, set iScale to
  1273. // 4. If values are in dialog units, set iScale to the average char
  1274. // width of the dialog font. If values are multiples of the average
  1275. // character width for the selected font, set iScale to 0.
  1276. //
  1277. //p pTabStops: Array of cTabStops entries. Each entry specifies a
  1278. // tabstop position. Positive values give nearedge alignment,
  1279. // negative values give faredge alignment.
  1280. //
  1281. //p iTabOrigin: Tabs are considered to start iTabOrigin before the
  1282. // beginning of the string. Helps with multiple tabbed
  1283. // outputs on the same line.
  1284. ///// ScriptStringAnalyse
  1285. //
  1286. // cString - Input string must contain at least one character
  1287. //
  1288. // hdc - required if SSA_GLYPH requested. Optional for SSA_BREAK.
  1289. // If present the current font in the hdc is inspected and if a symbolic
  1290. // font the character string is treated as a single neutral SCRIPT_UNDEFINED item.
  1291. //
  1292. // Note that the uBidiLevel field in the initial SCRIPT_STATE value
  1293. // is ignored - the uBidiLevel used is derived from the SSA_RTL
  1294. // flag in combination with the layout of the hdc.
  1295. typedef void* SCRIPT_STRING_ANALYSIS;
  1296. HRESULT WINAPI ScriptStringAnalyse(
  1297. HDC hdc, //In Device context (required)
  1298. const void *pString, //In String in 8 or 16 bit characters
  1299. int cString, //In Length in characters (Must be at least 1)
  1300. int cGlyphs, //In Required glyph buffer size (default cString*1.5 + 16)
  1301. int iCharset, //In Charset if an ANSI string, -1 for a Unicode string
  1302. DWORD dwFlags, //In Analysis required
  1303. int iReqWidth, //In Required width for fit and/or clip
  1304. SCRIPT_CONTROL *psControl, //In Analysis control (optional)
  1305. SCRIPT_STATE *psState, //In Analysis initial state (optional)
  1306. const int *piDx, //In Requested logical dx array
  1307. SCRIPT_TABDEF *pTabdef, //In Tab positions (optional)
  1308. const BYTE *pbInClass, //In Legacy GetCharacterPlacement character classifications (deprecated)
  1309. SCRIPT_STRING_ANALYSIS *pssa); //Out Analysis of string
  1310. ///// ScriptStringFree - free a string analysis
  1311. //
  1312. //
  1313. HRESULT WINAPI ScriptStringFree(
  1314. SCRIPT_STRING_ANALYSIS *pssa); //InOut Address of pointer to analysis
  1315. ///// ScriptStringSize
  1316. //
  1317. // returns a pointer to the size (width and height) of an analysed string
  1318. //
  1319. // Note that the SIZE pointer remains valid only until the
  1320. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1321. const SIZE* WINAPI ScriptString_pSize(
  1322. SCRIPT_STRING_ANALYSIS ssa);
  1323. ///// ScriptString_pcOutChars
  1324. //
  1325. // returns pointer to length of string after clipping (requires SSA_CLIP set)
  1326. //
  1327. // Note that the int pointer remains valid only until the
  1328. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1329. const int* WINAPI ScriptString_pcOutChars(
  1330. SCRIPT_STRING_ANALYSIS ssa);
  1331. ///// ScriptString_pLogAttr
  1332. //
  1333. // returns pointer to logical attributes buffer in a SCRIPT_STRING_ANALYSIS
  1334. //
  1335. // Note that the buffer pointer remains valid only until the
  1336. // SCRIPT_STRING_ANALYSIS is passed to ScriptStringFree.
  1337. //
  1338. // The logical attribute array contains *ScriptString_pcOutChars(ssa)
  1339. // entries.
  1340. const SCRIPT_LOGATTR* WINAPI ScriptString_pLogAttr(
  1341. SCRIPT_STRING_ANALYSIS ssa);
  1342. ///// ScriptStringGetOrder
  1343. //
  1344. // Creates an array mapping original character position to glyph position.
  1345. //
  1346. // Treats clusters as they were in legacy systems - Unless a cluster
  1347. // contains more glyphs than codepoints, each glyph is referenced at
  1348. // least once from the puOrder array.
  1349. //
  1350. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1351. //
  1352. // The puOrder parameter should address a buffer containing room for
  1353. // at least *ScriptString_pcOutChars(ssa) ints.
  1354. HRESULT WINAPI ScriptStringGetOrder(
  1355. SCRIPT_STRING_ANALYSIS ssa,
  1356. UINT *puOrder);
  1357. ///// ScriptStringCPtoX
  1358. //
  1359. // Return x coordinate for leading or trailing edge of character icp.
  1360. HRESULT WINAPI ScriptStringCPtoX(
  1361. SCRIPT_STRING_ANALYSIS ssa, //In String analysis
  1362. int icp, //In Caret character position
  1363. BOOL fTrailing, //In Which edge of icp
  1364. int *pX); //Out Corresponding x offset
  1365. ///// ScriptStringXtoCP
  1366. //
  1367. //
  1368. HRESULT WINAPI ScriptStringXtoCP(
  1369. SCRIPT_STRING_ANALYSIS ssa, // In
  1370. int iX, // In
  1371. int *piCh, // Out
  1372. int *piTrailing); // Out
  1373. ///// ScriptStringGetLogicalWidths
  1374. //
  1375. // Converts visual withs in psa->piAdvance into logical widths,
  1376. // one per original character, in logical order.
  1377. //
  1378. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1379. //
  1380. // The piDx parameter should address a buffer containing room for
  1381. // at least *ScriptString_pcOutChars(ssa) ints.
  1382. HRESULT WINAPI ScriptStringGetLogicalWidths(
  1383. SCRIPT_STRING_ANALYSIS ssa,
  1384. int *piDx);
  1385. ///// ScriptStringValidate
  1386. //
  1387. // Scans the string analysis for invalid glyphs.
  1388. //
  1389. // Only glyphs generated by scripts that can generate invalid glyphs
  1390. // are scanned.
  1391. //
  1392. // returns S_OK - no invalid glyphs are present
  1393. // S_FALSE - one or more invalid glyphs are present
  1394. HRESULT WINAPI ScriptStringValidate(
  1395. SCRIPT_STRING_ANALYSIS ssa);
  1396. ///// ScriptStringOut
  1397. //
  1398. // Displays the string generated by a prior ScriptStringAnalyze call,
  1399. // then optionally adds highlighting corresponding to a logical selection.
  1400. //
  1401. // Requires SSA_GLYPHS requested in original ScriptStringAnalyse call.
  1402. HRESULT WINAPI ScriptStringOut(
  1403. SCRIPT_STRING_ANALYSIS ssa, //In Analysis with glyphs
  1404. int iX, //In
  1405. int iY, //In
  1406. UINT uOptions, //In ExtTextOut options
  1407. const RECT *prc, //In Clipping rectangle (iff ETO_CLIPPED)
  1408. int iMinSel, //In Logical selection. Set iMinSel>=iMaxSel for no selection
  1409. int iMaxSel, //In
  1410. BOOL fDisabled); //In If disabled, only the background is highlighted.
  1411. /////
  1412. // uOptions may nclude only ETO_CLIPPED or ETO_OPAQUE.
  1413. ///// ScriptIsComplex
  1414. //
  1415. // Determines whether a Unicode string requires complex script processing
  1416. //
  1417. // The dwFlags parameter may include the following requests
  1418. //
  1419. #define SIC_COMPLEX 1 // Treat complex script letters as complex
  1420. #define SIC_ASCIIDIGIT 2 // Treat digits U+0030 through U+0039 as complex
  1421. #define SIC_NEUTRAL 4 // Treat neutrals as complex
  1422. //
  1423. // SIC_COMPLEX: Should normally set. Causes complex script letters to
  1424. // be treated as complex.
  1425. //
  1426. // SIC_ASCIIDIGIT: Set this flag if the string would be displayed with
  1427. // digit substitution enabled. If you are following the users NLS
  1428. // settings using the ScriptRecordDigitSubstitution API, you can pass
  1429. // scriptDigitSubstitute.DigitSubstitute != SCRIPT_DIGITSUBSTITUTE_NONE.
  1430. //
  1431. // SIC_NEUTRAL: Set this flag if you may be displaying the string with
  1432. // right-to-left reading order. When this flag is set, neutral characters
  1433. // are considered as complex.
  1434. //
  1435. //
  1436. // Returns S_OK if string requires complex script processing,
  1437. // S_FALSE if string contains only characters laid out side by
  1438. // side from left to right.
  1439. HRESULT WINAPI ScriptIsComplex(
  1440. const WCHAR *pwcInChars, //In String to be tested
  1441. int cInChars, //In Length in characters
  1442. DWORD dwFlags); //In Flags (see above)
  1443. ///// ScriptRecordDigitSubstitution
  1444. //
  1445. // Reads NLS native digit and digit substitution settings and records
  1446. // them in the SCRIPT_DIGITSUBSTITUTE structure.
  1447. //
  1448. //
  1449. typedef struct tag_SCRIPT_DIGITSUBSTITUTE {
  1450. DWORD NationalDigitLanguage :16; // Language for native substitution
  1451. DWORD TraditionalDigitLanguage :16; // Language for traditional substitution
  1452. DWORD DigitSubstitute :8; // Substitution type
  1453. DWORD dwReserved; // Reserved
  1454. } SCRIPT_DIGITSUBSTITUTE;
  1455. //
  1456. //
  1457. //p NationalDigitLanguage: Standard digits for the selected locale as
  1458. // defined by the countries standard setting authority.
  1459. //
  1460. //p TraditionalDigitLangauge: Digits originally used with the locales
  1461. // script.
  1462. //
  1463. //p DigitSubstitute: Selects between None, Context, National and
  1464. // Traditional. See ScriptApplyDigitSubstitution below for
  1465. // constant definitions.
  1466. //
  1467. // Although most complex scripts have their own associated digits, many
  1468. // countries using those scripts use western (so called
  1469. // 'Arabic') digits as their standard. NationalDigitLanguage reflects the
  1470. // digits used as standard, and is set from
  1471. // the NLS data for the locale.
  1472. // On Windows 2000 the national digit langauge can be
  1473. // adjusted to any digit script with the control panel/regional
  1474. // options/numbers/Standard digits listbox.
  1475. //
  1476. // The TraditionalDigitLanguage for a locale is derived directly from the
  1477. // script used by that locale.
  1478. HRESULT WINAPI ScriptRecordDigitSubstitution(
  1479. LCID Locale, // In LOCALE_USER_DEFAULT or desired locale
  1480. SCRIPT_DIGITSUBSTITUTE *psds); // Out Digit substitution settings
  1481. /////
  1482. //p Locale: NLS locale to be queried. Should usually be set to
  1483. // LOCALE_USER_DEFAULT. Alternatively may be passed as a locale
  1484. // combined with LOCALE_NOUSEROVERRIDE to obtain default settings
  1485. // for a given locale. Note that context digit substitution is
  1486. // supported only in ARABIC and FARSI locales. In other locales,
  1487. // context digit is mapped to no substitution.
  1488. //
  1489. //p psds: Pointer to SCRIPT_DIGITSUBSTITUTE. This structure may be passed
  1490. // later to ScriptApplyDigitSubstitution.
  1491. //
  1492. //p returns: E_INVALIDARG if Locale is invalid or not installed. E_POINTER
  1493. // if psds is NULL. Otherwise S_OK.
  1494. //
  1495. // For performance reasons, you should not call
  1496. // ScriptRecordDigitSubstitution frequently. In particular it would be a
  1497. // considerable overhead to call it every time you call ScriptItemize
  1498. // or ScriptStringAnalyse.
  1499. //
  1500. // Instead, you may choose to save the SCRIPT_DIGITSUBSTITUTE
  1501. // structure, and update it only when you receive a
  1502. // WM_SETTINGCHANGE message or when a RegNotifyChangeKeyValue
  1503. // call in a dedicated thread indicates a change in the registry
  1504. // under HKCU\Control Panel\\International.
  1505. //
  1506. // The normal way to call this function is simply
  1507. //
  1508. //c SCRIPT_DIGITSUBSTITUTE sds;
  1509. //c ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds);
  1510. //
  1511. // Then every time you itemize, you'd use the results like this:
  1512. //
  1513. //c SCRIPT_CONTROL sc = {0};
  1514. //c SCRIPT_STATE ss = {0};
  1515. //
  1516. //c ScriptApplyDigitSubstitution(&sds, &sc, &ss);
  1517. //
  1518. //
  1519. ///// ScriptApplyDigitSubstitution
  1520. //
  1521. // Aplies the digit substitution settings recorded in a
  1522. // SCRIPT_DIGIT_SUBSTITUTE structure to the SCRIPT_CONTROL and
  1523. // SCRIPT_STATE structures.
  1524. //
  1525. // The DigitSubstitute field of the SCRIPT_DIGITSUBSTITUTE structure
  1526. // is normally set by ScriptRecordDigitSubstitution, however it may
  1527. // be replaced by any one of the following values:
  1528. //
  1529. //
  1530. #define SCRIPT_DIGITSUBSTITUTE_CONTEXT 0 // Substitute to match preceeding letters
  1531. #define SCRIPT_DIGITSUBSTITUTE_NONE 1 // No substitution
  1532. #define SCRIPT_DIGITSUBSTITUTE_NATIONAL 2 // Substitute with official national digits
  1533. #define SCRIPT_DIGITSUBSTITUTE_TRADITIONAL 3 // Substitute with traditional digits of the locale
  1534. //
  1535. //
  1536. //p SCRIPT_DIGITSUBSTITUTE_CONTEXT: Digits U+0030 - U+0039 will be
  1537. // substituted according to the language of prior letters. Before
  1538. // any letters, digits will be substituted according to the
  1539. // TraditionalDigitLangauge field of the SCRIPT_DIGIT_SUBSTITUTE
  1540. // structure. This field is normally set to the primary language of
  1541. // the Locale passed to ScriptRecordDigitSubstitution.
  1542. //
  1543. //p SCRIPT_DIGITSUBSTITUTE_NONE: Digits will not be substituted. Unicode
  1544. // values U+0030 to U+0039 will be displayed with Arabic (i.e.
  1545. // Western) numerals.
  1546. //
  1547. //p SCRIPT_DIGITSUBSTITUTE_NATIONAL: Digits U+0030 - U+0039 will be
  1548. // substituted according to the NationalDigitLangauge field of
  1549. // the SCRIPT_DIGIT_SUBSTITUTE structure. This field is normally
  1550. // set to the national digits returned for the NLS LCTYPE
  1551. // LOCALE_SNATIVEDIGITS by ScriptRecordDigitSubstitution.
  1552. //
  1553. //p SCRIPT_DIGITSUBSTITUTE_TRADITIONAL: Digits U+0030 - U+0039 will be
  1554. // substituted according to the TraditionalDigitLangauge field of
  1555. // the SCRIPT_DIGIT_SUBSTITUTE structure. This field is normally
  1556. // set to the primary language of the Locale passed to
  1557. // ScriptRecordDigitSubstitution.
  1558. HRESULT WINAPI ScriptApplyDigitSubstitution(
  1559. const SCRIPT_DIGITSUBSTITUTE *psds, // In Digit substitution settings
  1560. SCRIPT_CONTROL *psc, // Out Script control structure
  1561. SCRIPT_STATE *pss); // Out Script state structure
  1562. /////
  1563. //p psds: Pointer to SCRIPT_DIGITSUBSTITUTE structure recorded earlier.
  1564. // If NULL, ScriptApplyDigitSubstitution calls
  1565. // ScriptRecordDigitSubstitution with LOCALE_USER_DEFAULT.
  1566. //
  1567. //p psc: SCRIPT_CONTROL structure. The fContextDigits and uDefaultLanguage
  1568. // fields will be updated.
  1569. //
  1570. //p pss: SCRIPT_CONTROL structure. The fDigitSubstitute field will be
  1571. // updated.
  1572. //
  1573. //p returns: E_INVALIDARG if the DigitSubstitute field of the
  1574. // SCRIPT_DIGITSUBSTITUTE structure is unrecognised, else S_OK;
  1575. #ifdef __cplusplus
  1576. }
  1577. #endif
  1578. #endif