1 // Copyright © 2015-2017 winapi-rs developers
2 // Licensed under the Apache License, Version 2.0
3 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
4 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
5 // All files in the project carrying such notice may not be copied, modified, or distributed
6 // except according to those terms.
7 //! Unicode Complex Script processor API declarations
8 use ctypes
::{c_int, c_long, c_void}
;
9 use shared
::minwindef
::{BOOL, BYTE, DWORD, UINT, ULONG, WORD}
;
10 use shared
::ntdef
::LCID
;
11 use shared
::windef
::{HDC, RECT, SIZE}
;
12 use shared
::winerror
::{FACILITY_ITF, SEVERITY_ERROR}
;
14 use um
::winnt
::{HRESULT, LONG, WCHAR}
;
15 pub const SCRIPT_UNDEFINED
: WORD
= 0;
16 pub const USP_E_SCRIPT_NOT_IN_FONT
: HRESULT
= MAKE_HRESULT
!(
17 SEVERITY_ERROR
, FACILITY_ITF
, 0x200
19 DECLARE_HANDLE
!{SCRIPT_CACHE, SCRIPT_CACHE__}
21 pub fn ScriptFreeCache(
22 psc
: *mut SCRIPT_CACHE
25 STRUCT
!{struct SCRIPT_CONTROL
{
28 BITFIELD
!{SCRIPT_CONTROL bit_fields
: DWORD
[
29 uDefaultLanguage set_uDefaultLanguage
[0..16],
30 fContextDigits set_fContextDigits
[16..17],
31 fInvertPreBoundDir set_fInvertPreBoundDir
[17..18],
32 fInvertPostBoundDir set_fInvertPostBoundDir
[18..19],
33 fLinkStringBefore set_fLinkStringBefore
[19..20],
34 fLinkStringAfter set_fLinkStringAfter
[20..21],
35 fNeutralOverride set_fNeutralOverride
[21..22],
36 fNumericOverride set_fNumericOverride
[22..23],
37 fLegacyBidiClass set_fLegacyBidiClass
[23..24],
38 fMergeNeutralItems set_fMergeNeutralItems
[24..25],
39 fReserved set_fReserved
[25..32],
41 STRUCT
!{struct SCRIPT_STATE
{
44 BITFIELD
!{SCRIPT_STATE bit_fields
: WORD
[
45 uBidiLevel set_uBidiLevel
[0..5],
46 fOverrideDirection set_fOverrideDirection
[5..6],
47 fInhibitSymSwap set_fInhibitSymSwap
[6..7],
48 fCharShape set_fCharShape
[7..8],
49 fDigitSubstitute set_fDigitSubstitute
[8..9],
50 fInhibitLigate set_fInhibitLigate
[9..10],
51 fDisplayZWG set_fDisplayZWG
[10..11],
52 fArabicNumContext set_fArabicNumContext
[11..12],
53 fGcpClusters set_fGcpClusters
[12..13],
54 fReserved set_fReserved
[13..14],
55 fEngineReserved set_fEngineReserved
[14..16],
57 STRUCT
!{struct SCRIPT_ANALYSIS
{
61 BITFIELD
!{SCRIPT_ANALYSIS bit_fields
: WORD
[
62 eScript set_eScript
[0..10],
63 fRTL set_fRTL
[10..11],
64 fLayoutRTL set_fLayoutRTL
[11..12],
65 fLinkBefore set_fLinkBefore
[12..13],
66 fLinkAfter set_fLinkAfter
[13..14],
67 fLogicalOrder set_fLogicalOrder
[14..15],
68 fNoGlyphIndex set_fNoGlyphIndex
[15..16],
70 STRUCT
!{struct SCRIPT_ITEM
{
76 pwcInChars
: *const WCHAR
,
79 psControl
: *const SCRIPT_CONTROL
,
80 psState
: *const SCRIPT_STATE
,
81 pItems
: *mut SCRIPT_ITEM
,
87 piVisualToLogical
: *mut c_int
,
88 piLogicalToVisual
: *mut c_int
,
91 pub const SCRIPT_JUSTIFY_NONE
: WORD
= 0;
92 pub const SCRIPT_JUSTIFY_ARABIC_BLANK
: WORD
= 1;
93 pub const SCRIPT_JUSTIFY_CHARACTER
: WORD
= 2;
94 pub const SCRIPT_JUSTIFY_RESERVED1
: WORD
= 3;
95 pub const SCRIPT_JUSTIFY_BLANK
: WORD
= 4;
96 pub const SCRIPT_JUSTIFY_RESERVED2
: WORD
= 5;
97 pub const SCRIPT_JUSTIFY_RESERVED3
: WORD
= 6;
98 pub const SCRIPT_JUSTIFY_ARABIC_NORMAL
: WORD
= 7;
99 pub const SCRIPT_JUSTIFY_ARABIC_KASHIDA
: WORD
= 8;
100 pub const SCRIPT_JUSTIFY_ARABIC_ALEF
: WORD
= 9;
101 pub const SCRIPT_JUSTIFY_ARABIC_HA
: WORD
= 10;
102 pub const SCRIPT_JUSTIFY_ARABIC_RA
: WORD
= 11;
103 pub const SCRIPT_JUSTIFY_ARABIC_BA
: WORD
= 12;
104 pub const SCRIPT_JUSTIFY_ARABIC_BARA
: WORD
= 13;
105 pub const SCRIPT_JUSTIFY_ARABIC_SEEN
: WORD
= 14;
106 pub const SCRIPT_JUSTIFY_ARABIC_SEEN_M
: WORD
= 15;
107 STRUCT
!{struct SCRIPT_VISATTR
{
110 BITFIELD
!{SCRIPT_VISATTR bit_fields
: WORD
[
111 uJustification set_uJustification
[0..4],
112 fClusterStart set_fClusterStart
[4..5],
113 fDiacritic set_fDiacritic
[5..6],
114 fZeroWidth set_fZeroWidth
[6..7],
115 fReserved set_fReserved
[7..8],
116 fShapeReserved set_fShapeReserved
[8..16],
121 psc
: *mut SCRIPT_CACHE
,
122 pwcChars
: *const WCHAR
,
125 psa
: *mut SCRIPT_ANALYSIS
,
126 pwOutGlyphs
: *mut WORD
,
127 pwLogClust
: *mut WORD
,
128 psva
: *mut SCRIPT_VISATTR
,
129 pcGlyphs
: *mut c_int
,
132 STRUCT
!{struct GOFFSET
{
139 psc
: *mut SCRIPT_CACHE
,
140 pwGlyphs
: *const WORD
,
142 psva
: *const SCRIPT_VISATTR
,
143 psa
: *mut SCRIPT_ANALYSIS
,
144 piAdvance
: *mut c_int
,
145 pGoffset
: *mut GOFFSET
,
148 pub fn ScriptTextOut(
150 psc
: *mut SCRIPT_CACHE
,
155 psa
: *const SCRIPT_ANALYSIS
,
156 pwcReserved
: *const WCHAR
,
158 pwGlyphs
: *const WORD
,
160 piAdvance
: *const c_int
,
161 piJustify
: *const c_int
,
162 pGoffset
: *const GOFFSET
,
164 pub fn ScriptJustify(
165 psva
: *const SCRIPT_VISATTR
,
166 piAdvance
: *const c_int
,
170 piJustify
: *mut c_int
,
173 STRUCT
!{struct SCRIPT_LOGATTR
{
176 BITFIELD
!{SCRIPT_LOGATTR bit_fields
: BYTE
[
177 fSoftBreak set_fSoftBreak
[0..1],
178 fWhiteSpace set_fWhiteSpace
[1..2],
179 fCharStop set_fCharStop
[2..3],
180 fWordStop set_fWordStop
[3..4],
181 fInvalid set_fInvalid
[4..5],
182 fReserved set_fReserved
[5..8],
186 pwcChars
: *const WCHAR
,
188 psa
: *const SCRIPT_ANALYSIS
,
189 psla
: *mut SCRIPT_LOGATTR
,
196 pwLogClust
: *const WORD
,
197 psva
: *const SCRIPT_VISATTR
,
198 piAdvance
: *const c_int
,
199 psa
: *const SCRIPT_ANALYSIS
,
206 pwLogClust
: *const WORD
,
207 psva
: *const SCRIPT_VISATTR
,
208 piAdvance
: *const c_int
,
209 psa
: *const SCRIPT_ANALYSIS
,
211 piTrailing
: *mut c_int
,
213 pub fn ScriptGetLogicalWidths(
214 psa
: *const SCRIPT_ANALYSIS
,
217 piGlyphWidth
: *const c_int
,
218 pwLogClust
: *const WORD
,
219 psva
: *const SCRIPT_VISATTR
,
222 pub fn ScriptApplyLogicalWidth(
226 pwLogClust
: *const WORD
,
227 psva
: *const SCRIPT_VISATTR
,
228 piAdvance
: *const c_int
,
229 psa
: *const SCRIPT_ANALYSIS
,
231 piJustify
: *mut c_int
,
234 pub const SGCM_RTL
: DWORD
= 0x00000001;
236 pub fn ScriptGetCMap(
238 psc
: *mut SCRIPT_CACHE
,
239 pwcInChars
: *const WCHAR
,
242 pwOutGlyphs
: *mut WORD
,
244 pub fn ScriptGetGlyphABCWidth(
246 psc
: *mut SCRIPT_CACHE
,
251 STRUCT
!{struct SCRIPT_PROPERTIES
{
255 BITFIELD
!{SCRIPT_PROPERTIES bit_fields1
: DWORD
[
256 langid set_langid
[0..16],
257 fNumeric set_fNumeric
[16..17],
258 fComplex set_fComplex
[17..18],
259 fNeedsWordBreaking set_fNeedsWordBreaking
[18..19],
260 fNeedsCaretInfo set_fNeedsCaretInfo
[19..20],
261 bCharSet set_bCharSet
[20..28],
262 fControl set_fControl
[28..29],
263 fPrivateUseArea set_fPrivateUseArea
[29..30],
264 fNeedsCharacterJustify set_fNeedsCharacterJustify
[30..31],
265 fInvalidGlyph set_fInvalidGlyph
[31..32],
267 BITFIELD
!{SCRIPT_PROPERTIES bit_fields2
: DWORD
[
268 fInvalidLogAttr set_fInvalidLogAttr
[0..1],
270 fAmbiguousCharSet set_fAmbiguousCharSet
[2..3],
271 fClusterSizeVaries set_fClusterSizeVaries
[3..4],
272 fRejectInvalid set_fRejectInvalid
[4..5],
275 pub fn ScriptGetProperties(
276 ppSp
: *mut *mut *const SCRIPT_PROPERTIES
,
277 piNumScripts
: *mut c_int
,
280 STRUCT
!{struct SCRIPT_FONTPROPERTIES
{
286 iKashidaWidth
: c_int
,
289 pub fn ScriptGetFontProperties(
291 psc
: *mut SCRIPT_CACHE
,
292 sfp
: *mut SCRIPT_FONTPROPERTIES
,
294 pub fn ScriptCacheGetHeight(
296 psc
: *mut SCRIPT_CACHE
,
297 tmHeight
: *mut c_long
,
300 pub const SSA_PASSWORD
: DWORD
= 0x00000001;
301 pub const SSA_TAB
: DWORD
= 0x00000002;
302 pub const SSA_CLIP
: DWORD
= 0x00000004;
303 pub const SSA_FIT
: DWORD
= 0x00000008;
304 pub const SSA_DZWG
: DWORD
= 0x00000010;
305 pub const SSA_FALLBACK
: DWORD
= 0x00000020;
306 pub const SSA_BREAK
: DWORD
= 0x00000040;
307 pub const SSA_GLYPHS
: DWORD
= 0x00000080;
308 pub const SSA_RTL
: DWORD
= 0x00000100;
309 pub const SSA_GCP
: DWORD
= 0x00000200;
310 pub const SSA_HOTKEY
: DWORD
= 0x00000400;
311 pub const SSA_METAFILE
: DWORD
= 0x00000800;
312 pub const SSA_LINK
: DWORD
= 0x00001000;
313 pub const SSA_HIDEHOTKEY
: DWORD
= 0x00002000;
314 pub const SSA_HOTKEYONLY
: DWORD
= 0x00002400;
315 pub const SSA_FULLMEASURE
: DWORD
= 0x04000000;
316 pub const SSA_LPKANSIFALLBACK
: DWORD
= 0x08000000;
317 pub const SSA_PIDX
: DWORD
= 0x10000000;
318 pub const SSA_LAYOUTRTL
: DWORD
= 0x20000000;
319 pub const SSA_DONTGLYPH
: DWORD
= 0x40000000;
320 pub const SSA_NOKASHIDA
: DWORD
= 0x80000000;
321 STRUCT
!{struct SCRIPT_TABDEF
{
324 pTabStops
: *mut c_int
,
327 DECLARE_HANDLE
!{SCRIPT_STRING_ANALYSIS, SCRIPT_STRING_ANALYSIS__}
329 pub fn ScriptStringAnalyse(
331 pString
: *const c_void
,
337 psControl
: *mut SCRIPT_CONTROL
,
338 psState
: *mut SCRIPT_STATE
,
340 pTabdef
: *mut SCRIPT_TABDEF
,
341 pbInClass
: *const BYTE
,
342 pssa
: *mut SCRIPT_STRING_ANALYSIS
,
344 pub fn ScriptStringFree(
345 pssa
: *mut SCRIPT_STRING_ANALYSIS
347 pub fn ScriptString_pSize(
348 ssa
: SCRIPT_STRING_ANALYSIS
350 pub fn ScriptString_pcOutChars(
351 ssa
: SCRIPT_STRING_ANALYSIS
353 pub fn ScriptString_pLogAttr(
354 ssa
: SCRIPT_STRING_ANALYSIS
355 ) -> *const SCRIPT_LOGATTR
;
356 pub fn ScriptStringGetOrder(
357 ssa
: SCRIPT_STRING_ANALYSIS
,
360 pub fn ScriptStringCPtoX(
361 ssa
: SCRIPT_STRING_ANALYSIS
,
366 pub fn ScriptStringXtoCP(
367 ssa
: SCRIPT_STRING_ANALYSIS
,
370 piTrailing
: *mut c_int
,
372 pub fn ScriptStringGetLogicalWidths(
373 ssa
: SCRIPT_STRING_ANALYSIS
,
376 pub fn ScriptStringValidate(
377 ssa
: SCRIPT_STRING_ANALYSIS
379 pub fn ScriptStringOut(
380 ssa
: SCRIPT_STRING_ANALYSIS
,
390 pub const SIC_COMPLEX
: DWORD
= 1;
391 pub const SIC_ASCIIDIGIT
: DWORD
= 2;
392 pub const SIC_NEUTRAL
: DWORD
= 4;
394 pub fn ScriptIsComplex(
395 pwcInChars
: *const WCHAR
,
400 STRUCT
!{struct SCRIPT_DIGITSUBSTITUTE
{
405 BITFIELD
!{SCRIPT_DIGITSUBSTITUTE bit_fields1
: DWORD
[
406 NationalDigitLanguage set_NationalDigitLanguage
[0..16],
407 TraditionalDigitLanguage set_TraditionalDigitLanguage
[16..32],
409 BITFIELD
!{SCRIPT_DIGITSUBSTITUTE bit_fields2
: DWORD
[
410 DigitSubstitute set_DigitSubstitute
[0..8],
413 pub fn ScriptRecordDigitSubstitution(
415 psds
: *mut SCRIPT_DIGITSUBSTITUTE
,
418 pub const SCRIPT_DIGITSUBSTITUTE_CONTEXT
: BYTE
= 0;
419 pub const SCRIPT_DIGITSUBSTITUTE_NONE
: BYTE
= 1;
420 pub const SCRIPT_DIGITSUBSTITUTE_NATIONAL
: BYTE
= 2;
421 pub const SCRIPT_DIGITSUBSTITUTE_TRADITIONAL
: BYTE
= 3;
423 pub fn ScriptApplyDigitSubstitution(
424 psds
: *const SCRIPT_DIGITSUBSTITUTE
,
425 psc
: *mut SCRIPT_CONTROL
,
426 pss
: *mut SCRIPT_STATE
,
429 pub type OPENTYPE_TAG
= ULONG
;
430 pub const SCRIPT_TAG_UNKNOWN
: OPENTYPE_TAG
= 0x00000000;
431 STRUCT
!{struct OPENTYPE_FEATURE_RECORD
{
432 tagFeature
: OPENTYPE_TAG
,
435 STRUCT
!{struct TEXTRANGE_PROPERTIES
{
436 potfRecords
: *mut OPENTYPE_FEATURE_RECORD
,
439 STRUCT
!{struct SCRIPT_CHARPROP
{
442 BITFIELD
!{SCRIPT_CHARPROP bit_fields
: WORD
[
443 fCanGlyphAlone set_fCanGlyphAlone
[0..1],
444 reserved set_reserved
[1..16],
446 STRUCT
!{struct SCRIPT_GLYPHPROP
{
451 pub fn ScriptShapeOpenType(
453 psc
: *mut SCRIPT_CACHE
,
454 psa
: *mut SCRIPT_ANALYSIS
,
455 tagScript
: OPENTYPE_TAG
,
456 tagLangSys
: OPENTYPE_TAG
,
457 rcRangeChars
: *mut c_int
,
458 rpRangeProperties
: *mut *mut TEXTRANGE_PROPERTIES
,
460 pwcChars
: *const WCHAR
,
463 pwLogClust
: *mut WORD
,
464 pCharProps
: *mut SCRIPT_CHARPROP
,
465 pwOutGlyphs
: *mut WORD
,
466 pOutGlyphProps
: *mut SCRIPT_GLYPHPROP
,
467 pcGlyphs
: *mut c_int
,
469 pub fn ScriptPlaceOpenType(
471 psc
: *mut SCRIPT_CACHE
,
472 psa
: *mut SCRIPT_ANALYSIS
,
473 tagScript
: OPENTYPE_TAG
,
474 tagLangSys
: OPENTYPE_TAG
,
475 rcRangeChars
: *mut c_int
,
476 rpRangeProperties
: *mut *mut TEXTRANGE_PROPERTIES
,
478 pwcChars
: *const WCHAR
,
479 pwLogClust
: *mut WORD
,
480 pCharProps
: *mut SCRIPT_CHARPROP
,
482 pwGlyphs
: *const WORD
,
483 pGlyphProps
: *const SCRIPT_GLYPHPROP
,
485 piAdvance
: *mut c_int
,
486 pGoffset
: *mut GOFFSET
,
489 pub fn ScriptItemizeOpenType(
490 pwcInChars
: *const WCHAR
,
493 psControl
: *const SCRIPT_CONTROL
,
494 psState
: *const SCRIPT_STATE
,
495 pItems
: *mut SCRIPT_ITEM
,
496 pScriptTags
: *mut OPENTYPE_TAG
,
499 pub fn ScriptGetFontScriptTags(
501 psc
: *mut SCRIPT_CACHE
,
502 psa
: *mut SCRIPT_ANALYSIS
,
504 pScriptTags
: *mut OPENTYPE_TAG
,
507 pub fn ScriptGetFontLanguageTags(
509 psc
: *mut SCRIPT_CACHE
,
510 psa
: *mut SCRIPT_ANALYSIS
,
511 tagScript
: OPENTYPE_TAG
,
513 pLangsysTags
: *mut OPENTYPE_TAG
,
516 pub fn ScriptGetFontFeatureTags(
518 psc
: *mut SCRIPT_CACHE
,
519 psa
: *mut SCRIPT_ANALYSIS
,
520 tagScript
: OPENTYPE_TAG
,
521 tagLangSys
: OPENTYPE_TAG
,
523 pFeatureTags
: *mut OPENTYPE_TAG
,
526 pub fn ScriptGetFontAlternateGlyphs(
528 psc
: *mut SCRIPT_CACHE
,
529 psa
: *mut SCRIPT_ANALYSIS
,
530 tagScript
: OPENTYPE_TAG
,
531 tagLangSys
: OPENTYPE_TAG
,
532 tagFeature
: OPENTYPE_TAG
,
534 cMaxAlternates
: c_int
,
535 pAlternateGlyphs
: *mut WORD
,
536 pcAlternates
: *mut c_int
,
538 pub fn ScriptSubstituteSingleGlyph(
540 psc
: *mut SCRIPT_CACHE
,
541 psa
: *mut SCRIPT_ANALYSIS
,
542 tagScript
: OPENTYPE_TAG
,
543 tagLangSys
: OPENTYPE_TAG
,
544 tagFeature
: OPENTYPE_TAG
,
547 pwOutGlyphId
: *mut WORD
,
549 pub fn ScriptPositionSingleGlyph(
551 psc
: *mut SCRIPT_CACHE
,
552 psa
: *mut SCRIPT_ANALYSIS
,
553 tagScript
: OPENTYPE_TAG
,
554 tagLangSys
: OPENTYPE_TAG
,
555 tagFeature
: OPENTYPE_TAG
,
560 piOutAdvance
: *mut c_int
,
561 pOutGoffset
: *mut GOFFSET
,