using System; using System.Linq; using System.Runtime.InteropServices; using Vanara.Extensions; using static Vanara.PInvoke.Gdi32; namespace Vanara.PInvoke { /// Items from the Usp10.dll. public static partial class Usp10 { private const string Lib_Usp10 = "Usp10.dll"; /// Creates an from four characters. /// The first character. /// The second character. /// The third character. /// The fourth character. /// An from the input. public static OPENTYPE_TAG OTF_TAG(char a, char b, char c, char d) => new(a, b, c, d); /// Creates an from a four character string. /// The four character string. /// An from the input. public static OPENTYPE_TAG OTF_TAG(string tag) => new(tag); /// Creates an from a four characters array. /// The four character array. /// An from the input. public static OPENTYPE_TAG OTF_TAG(char[] chars) => new(chars); /// Creates an from a four byte array. /// The four byte array. /// An from the input. public static OPENTYPE_TAG OTF_TAG(byte[] bytes) => new(bytes); /// Applies the specified digit substitution settings to the specified script control and script state structures. /// /// Pointer to a SCRIPT_DIGITSUBSTITUTE structure. The application sets this parameter to NULL if the function is to call /// ScriptRecordDigitSubstitution with LOCALE_USER_DEFAULT. /// /// Pointer to a SCRIPT_CONTROL structure with the fContextDigits and uDefaultLanguage members updated. /// Pointer to a SCRIPT_STATE structure with the fDigitSubstitute member updated. /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. /// The function returns E_INVALIDARG if it does not recognize the DigitSubstitute member of SCRIPT_DIGITSUBSTITUTE. /// /// /// /// This function does not actually substitute digits. It just fills in the structures that describe the digit substitution policy. /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptapplydigitsubstitution HRESULT // ScriptApplyDigitSubstitution( [in] const SCRIPT_DIGITSUBSTITUTE *psds, [out] SCRIPT_CONTROL *psc, [out] SCRIPT_STATE *pss ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptApplyDigitSubstitution")] public static extern HRESULT ScriptApplyDigitSubstitution(in SCRIPT_DIGITSUBSTITUTE psds, out SCRIPT_CONTROL psc, out SCRIPT_STATE pss); /// Applies the specified digit substitution settings to the specified script control and script state structures. /// /// Pointer to a SCRIPT_DIGITSUBSTITUTE structure. The application sets this parameter to NULL if the function is to call /// ScriptRecordDigitSubstitution with LOCALE_USER_DEFAULT. /// /// Pointer to a SCRIPT_CONTROL structure with the fContextDigits and uDefaultLanguage members updated. /// Pointer to a SCRIPT_STATE structure with the fDigitSubstitute member updated. /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. /// The function returns E_INVALIDARG if it does not recognize the DigitSubstitute member of SCRIPT_DIGITSUBSTITUTE. /// /// /// /// This function does not actually substitute digits. It just fills in the structures that describe the digit substitution policy. /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptapplydigitsubstitution HRESULT // ScriptApplyDigitSubstitution( [in] const SCRIPT_DIGITSUBSTITUTE *psds, [out] SCRIPT_CONTROL *psc, [out] SCRIPT_STATE *pss ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptApplyDigitSubstitution")] public static extern HRESULT ScriptApplyDigitSubstitution([In, Optional] IntPtr psds, out SCRIPT_CONTROL psc, out SCRIPT_STATE pss); /// Takes an array of advance widths for a run and generates an array of adjusted advance glyph widths. /// Pointer to an array of advance widths in logical order, one per code point. /// Count of the logical code points in the run. /// Glyph count. /// Pointer to an array of logical clusters from ScriptShape. /// Pointer to a SCRIPT_VISATTR structure from ScriptShape and updated by ScriptPlace. /// Pointer to an array of glyph advance widths from ScriptPlace. /// Pointer to a SCRIPT_ANALYSIS structure from ScriptItemize and updated by ScriptShape and ScriptPlace. /// /// Pointer to the overall ABC width of a run. On input, the parameter should contain the run ABC widths retrieved by ScriptPlace. On /// output, the parameter indicates the ABC width updated to match the new widths. /// /// /// Pointer to an array in which the function retrieves the glyph advance widths. This array is suitable for passing to the /// piJustify parameter of ScriptTextOut. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// This function can be used to reapply logical widths obtained with ScriptGetLogicalWidths. It can be useful in situations such as /// metafiling, for which advance width information must be recorded and reapplied in a font-independent manner, independent of glyph /// substitutions, such as ligaturization. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptapplylogicalwidth HRESULT ScriptApplyLogicalWidth( [in] // const int *piDx, [in] int cChars, [in] int cGlyphs, [in] const WORD *pwLogClust, [in] const SCRIPT_VISATTR *psva, [in] const int // *piAdvance, [in] const SCRIPT_ANALYSIS *psa, [in, out, optional] ABC *pABC, [out] int *piJustify ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptApplyLogicalWidth")] public static extern HRESULT ScriptApplyLogicalWidth([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] piDx, int cChars, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ushort[] pwLogClust, in SCRIPT_VISATTR psva, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piAdvance, in SCRIPT_ANALYSIS psa, ref ABC pABC, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piJustify); /// Retrieves information for determining line breaks. /// Pointer to the Unicode characters to process. /// Number of Unicode characters to process. /// Pointer to the SCRIPT_ANALYSIS structure obtained from an earlier call to ScriptItemize. /// Pointer to a buffer in which this function retrieves the character attributes as a SCRIPT_LOGATTR structure. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// This function does not require a device context and does not perform glyph shaping. /// /// This function retrieves cursor movement and formatting break positions for an item in an array of SCRIPT_LOGATTR structures. To /// support mixed formatting within a single word correctly, the call to ScriptBreak should pass whole items as retrieved by /// ScriptItemize, and not the finer formatting runs. /// /// /// The SCRIPT_LOGATTR structure identifies valid caret positions and line breaks. The fCharStop member specifies a flag that /// marks cluster boundaries for scripts that are conventionally restricted from moving inside clusters. The same boundaries can also /// be inferred by inspecting the logical cluster information retrieved by ScriptShape. However, ScriptBreak is considerably /// faster in implementation and does not require a device context to be prepared. /// /// /// The flags designated by the fWordStop, fSoftBreak, and fWhiteSpace members of SCRIPT_LOGATTR are only /// available through ScriptBreak. /// /// /// Most shaping engines that identify invalid sequences set the flag indicated by the fInvalid member of SCRIPT_LOGATTR in /// ScriptBreak. The fInvalidLogAttr member of SCRIPT_PROPERTIES identifies the applicable scripts. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptbreak HRESULT ScriptBreak( [in] const WCHAR *pwcChars, // [in] int cChars, [in] const SCRIPT_ANALYSIS *psa, [out] SCRIPT_LOGATTR *psla ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptBreak")] public static extern HRESULT ScriptBreak([MarshalAs(UnmanagedType.LPWStr)] string pwcChars, int cChars, in SCRIPT_ANALYSIS psa, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] SCRIPT_LOGATTR[] psla); /// Retrieves the height of the currently cached font. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Pointer to a buffer in which the function retrieves the font height. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptcachegetheight HRESULT ScriptCacheGetHeight( [in] HDC hdc, // [in, out] SCRIPT_CACHE *psc, [out] long *tmHeight ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptCacheGetHeight")] public static extern HRESULT ScriptCacheGetHeight([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, out int tmHeight); /// /// Generates the x offset from the left end or leading edge of a run to either the leading or trailing edge of a logical character cluster. /// /// /// Logical character position in the run. This parameter corresponds to the offset of any logical character in the cluster. /// /// /// TRUE to use the trailing edge of the logical character cluster to compute the offset. This parameter is set to /// FALSE to use the leading edge of the logical character cluster. /// /// Number of characters in the run. /// Number of glyphs in the run. /// Pointer to the logical clusters. /// Pointer to a SCRIPT_VISATTR array of visual attributes. /// Pointer to an advance widths value. /// /// Pointer to a SCRIPT_ANALYSIS structure. The fLogicalOrder member specifies the end of the run from which to measure the /// offset. If the flag is set, the leading edge of the run is used. If the flag is not set, the left end of the run is used. /// /// Pointer to the buffer in which the function retrieves the x position of the caret. /// /// Returns 0 if successful. This function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// The leading or trailing edge of the character and the leading edge of a run depend on the direction of text in the run. /// /// For scripts in which the caret is conventionally placed in the middle of clusters (for example, Arabic and Hebrew), the retrieved /// x position of the carat can be an interpolated position for any code point in the line. /// /// /// For scripts in which the caret is conventionally snapped to the boundaries of clusters (for example, Thai and Indian), the x /// position is snapped to the requested edge of the cluster containing the logical character position indicated by iCP. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptcptox HRESULT ScriptCPtoX( [in] int iCP, [in] BOOL // fTrailing, [in] int cChars, [in] int cGlyphs, [in] const WORD *pwLogClust, [in] const SCRIPT_VISATTR *psva, [in] const int // *piAdvance, [in] const SCRIPT_ANALYSIS *psa, [out] int *piX ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptCPtoX")] public static extern HRESULT ScriptCPtoX(int iCP, [MarshalAs(UnmanagedType.Bool)] bool fTrailing, int cChars, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ushort[] pwLogClust, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] SCRIPT_VISATTR[] psva, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] int[] piAdvance, in SCRIPT_ANALYSIS psa, out int piX); /// Frees a script cache. /// Pointer to the SCRIPT_CACHE structure. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application cant test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// /// An application can free the script cache at any time, with certain limitations if the application is multi-threaded. Uniscribe /// maintains reference counts in its font and shaper caches and frees font data only when all sizes of the font are free. It frees /// shaper data only when all supported fonts are freed. /// /// The application should free the script cache for a style when it discards that style. /// ScriptFreeCache always sets its parameter to NULL to help avoid misreferencing. /// /// Uniscribe functions are re-entrant. Cache creation is interlocked through a single process-wide semaphore. ScriptFreeCache /// should not be called at a time when another thread might be accessing the particular cache to free. For performance reasons, the /// cache is not locked during ScriptShape or ScriptPlace. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptfreecache HRESULT ScriptFreeCache( [in, out] SCRIPT_CACHE // *psc ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptFreeCache")] public static extern HRESULT ScriptFreeCache(ref IntPtr psc); /// /// Retrieves the glyph indexes of the Unicode characters in a string according to either the TrueType cmap table or the standard /// cmap table implemented for old-style fonts. /// /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Pointer to a string of Unicode characters. /// Number of Unicode characters in the string indicated by pwcInChars. /// /// /// Flags specifying any special handling of the glyphs. By default, the glyphs are provided in logical order with no special /// handling. This parameter can have the following value. /// /// /// /// Value /// Meaning /// /// /// SGCM_RTL /// The glyph array indicated by pwOutGlyphs should contain mirrored glyphs for those glyphs that have a mirrored equivalent. /// /// /// /// /// Pointer to a buffer in which the function retrieves an array of glyph indexes. This buffer should be of the same length as the /// input buffer indicated by pwcInChars. Each code point maps to a single glyph. /// /// /// /// Returns S_OK if all Unicode code points are present in the font. The function returns one of the nonzero HRESULT values listed /// below if it does not succeed. /// /// /// /// Return value /// Meaning /// /// /// E_HANDLE /// The font or the operating system does not support glyph indexes. /// /// /// S_FALSE /// Some of the Unicode code points were mapped to the default glyph. /// /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// This function can be used to determine the characters in a run that are supported by the selected font. The application can scan /// the retrieved glyph buffer, looking for the default glyph to determine characters that are not available. The application should /// determine the default glyph index for the selected font by calling ScriptGetFontProperties. /// /// The return value for this function indicates the presence of any missing glyphs. /// /// Note The function assumes a 1:1 relationship between the elements in the input and output arrays. However, the function /// does not support this relationship for UTF-16 surrogate pairs. For a surrogate pair, the function does not retrieve the glyph /// index for the supplementary-plane character. Similarly, the function does not support Unicode Variation-Selector (VS) sequences, /// each of which consists of a Unicode graphic character followed by one of a set of VARIATION SELECTOR characters to select a /// particular glyph representation for that graphic character. For a VS sequence, the function retrieves the glyph index for the /// default glyph mapped by the cmap for the two characters, instead of the glyph index for the particular glyph for the VS sequence. /// /// /// Some code points can be rendered by a combination of glyphs, as well as by a single glyph, for example, 00C9; LATIN CAPITAL /// LETTER E WITH ACUTE. In this case, if the font supports the capital E glyph and the acute glyph, but not a single glyph for 00C9, /// ScriptGetCMap shows that 00C9 is unsupported. To determine the font support for a string that contains these kinds of code /// points, the application can call ScriptShape. If the function returns S_OK, the application should check the output for missing glyphs. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetcmap HRESULT ScriptGetCMap( [in] HDC hdc, [in, out] // SCRIPT_CACHE *psc, [in] const WCHAR *pwcInChars, [in] int cChars, [in] DWORD dwFlags, [out] WORD *pwOutGlyphs ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetCMap")] public static extern HRESULT ScriptGetCMap([In] HDC hdc, SafeSCRIPT_CACHE psc, [MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cChars, SGCM dwFlags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ushort[] pwOutGlyphs); /// /// Retrieves a list of alternate glyphs for a specified character that can be accessed through a specified OpenType feature. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure defining the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the array of alternate glyphs can be created with the correct scope. /// /// Alternatively, the application can set this parameter to NULL to receive unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag associated with alternate glyphs. /// An OPENTYPE_TAG structure defining the language tag associated with alternate glyphs. /// An OPENTYPE_TAG structure defining the feature tag associated with alternate glyphs. /// The identifier of the original glyph mapped from the character map table. /// Length of the array specified by pAlternateGlyphs. /// /// /// Pointer to buffer in which this function retrieves an array of glyph identifiers. The array includes the original glyph, followed /// by alternate glyphs. The first element is always the original glyph. Alternate forms are identified by an index into the array. /// The index is a value greater than one and less than the value of pcAlternates. /// /// /// When the user chooses an alternate form from the user interface, the alternate glyph is applied to the corresponding character /// and the rendering is reformatted. /// /// /// Pointer to the number of elements in the array specified by pAlternateGlyphs. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of alternate glyphs exceeds the value of cMaxAlternates, the function fails with E_OUTOFMEMORY. The /// application can try calling again with larger buffers. /// /// /// /// /// When using alternate glyphs, the application first reshapes the original glyph without applying any feature tag, then selects an /// alternate. The original glyph is established as the base glyph. If another alternate is required, the original glyph provides /// information to match with the corresponding alternates list. /// /// /// If an alternate glyph is used as the base glyph, no matching output list is found. The user interface uses the selected final /// form without providing the capability to choose another alternate. /// /// /// The operations of ScriptGetFontAlternateGlyphs can be emulated by ScriptSubstituteSingleGlyph. The application should try /// parameters one by one while glyphs are substituted. /// /// For shaping fonts with Uniscribe, ScriptShapeOpenType is preferred over the older ScriptShape function. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontalternateglyphs HRESULT // ScriptGetFontAlternateGlyphs( [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] // OPENTYPE_TAG tagScript, [in] OPENTYPE_TAG tagLangSys, [in] OPENTYPE_TAG tagFeature, [in] WORD wGlyphId, [in] int cMaxAlternates, // [out] WORD *pAlternateGlyphs, [out] int *pcAlternates ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontAlternateGlyphs")] public static extern HRESULT ScriptGetFontAlternateGlyphs([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, OPENTYPE_TAG tagFeature, ushort wGlyphId, int cMaxAlternates, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] ushort[] pAlternateGlyphs, out int pcAlternates); /// /// Retrieves a list of alternate glyphs for a specified character that can be accessed through a specified OpenType feature. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure defining the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the array of alternate glyphs can be created with the correct scope. /// /// Alternatively, the application can set this parameter to NULL to receive unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag associated with alternate glyphs. /// An OPENTYPE_TAG structure defining the language tag associated with alternate glyphs. /// An OPENTYPE_TAG structure defining the feature tag associated with alternate glyphs. /// The identifier of the original glyph mapped from the character map table. /// Length of the array specified by pAlternateGlyphs. /// /// /// Pointer to buffer in which this function retrieves an array of glyph identifiers. The array includes the original glyph, followed /// by alternate glyphs. The first element is always the original glyph. Alternate forms are identified by an index into the array. /// The index is a value greater than one and less than the value of pcAlternates. /// /// /// When the user chooses an alternate form from the user interface, the alternate glyph is applied to the corresponding character /// and the rendering is reformatted. /// /// /// Pointer to the number of elements in the array specified by pAlternateGlyphs. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of alternate glyphs exceeds the value of cMaxAlternates, the function fails with E_OUTOFMEMORY. The /// application can try calling again with larger buffers. /// /// /// /// /// When using alternate glyphs, the application first reshapes the original glyph without applying any feature tag, then selects an /// alternate. The original glyph is established as the base glyph. If another alternate is required, the original glyph provides /// information to match with the corresponding alternates list. /// /// /// If an alternate glyph is used as the base glyph, no matching output list is found. The user interface uses the selected final /// form without providing the capability to choose another alternate. /// /// /// The operations of ScriptGetFontAlternateGlyphs can be emulated by ScriptSubstituteSingleGlyph. The application should try /// parameters one by one while glyphs are substituted. /// /// For shaping fonts with Uniscribe, ScriptShapeOpenType is preferred over the older ScriptShape function. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontalternateglyphs HRESULT // ScriptGetFontAlternateGlyphs( [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] // OPENTYPE_TAG tagScript, [in] OPENTYPE_TAG tagLangSys, [in] OPENTYPE_TAG tagFeature, [in] WORD wGlyphId, [in] int cMaxAlternates, // [out] WORD *pAlternateGlyphs, [out] int *pcAlternates ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontAlternateGlyphs")] public static extern HRESULT ScriptGetFontAlternateGlyphs([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, OPENTYPE_TAG tagFeature, ushort wGlyphId, int cMaxAlternates, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] ushort[] pAlternateGlyphs, out int pcAlternates); /// /// Retrieves a list of typographic features for the defined writing system for OpenType processing. The typographic feature tags /// comprising the list are retrieved from the font in the supplied device context or cache. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the font feature tags for the appropriate font and scripts can be retrieved. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag associated with the specified feature tags. /// An OPENTYPE_TAG structure defining the language tag associated with the specified feature tags. /// The length of the array specified by pFeatureTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures defining the typographic feature /// tags supported by the font in the device context or cache for the defined writing system. /// /// Pointer to the number of elements in the feature tag array. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds the value of cMaxTags, the function fails with E_OUTOFMEMORY. The application can /// try calling again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, an OPENTYPE_TAG structure contains a 4-byte array that contains four 8-bit ASCII values /// of space, A-Z, or a-z. For example, the feature tag for the Ligature feature is "liga". /// /// /// This function hides script-required or language-required features because the shaping engine controls these features. The /// application has no control over the shaping engine handling for language-required features. For example, /// ScriptGetFontFeatureTags hides the Arabic script features for initial, medial, and final forms. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontfeaturetags HRESULT ScriptGetFontFeatureTags( [in, // optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] // OPENTYPE_TAG tagLangSys, [in] int cMaxTags, [out] OPENTYPE_TAG *pFeatureTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontFeatureTags")] public static extern HRESULT ScriptGetFontFeatureTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] OPENTYPE_TAG[] pFeatureTags, out int pcTags); /// /// Retrieves a list of typographic features for the defined writing system for OpenType processing. The typographic feature tags /// comprising the list are retrieved from the font in the supplied device context or cache. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the font feature tags for the appropriate font and scripts can be retrieved. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag associated with the specified feature tags. /// An OPENTYPE_TAG structure defining the language tag associated with the specified feature tags. /// The length of the array specified by pFeatureTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures defining the typographic feature /// tags supported by the font in the device context or cache for the defined writing system. /// /// Pointer to the number of elements in the feature tag array. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds the value of cMaxTags, the function fails with E_OUTOFMEMORY. The application can /// try calling again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, an OPENTYPE_TAG structure contains a 4-byte array that contains four 8-bit ASCII values /// of space, A-Z, or a-z. For example, the feature tag for the Ligature feature is "liga". /// /// /// This function hides script-required or language-required features because the shaping engine controls these features. The /// application has no control over the shaping engine handling for language-required features. For example, /// ScriptGetFontFeatureTags hides the Arabic script features for initial, medial, and final forms. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontfeaturetags HRESULT ScriptGetFontFeatureTags( [in, // optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] // OPENTYPE_TAG tagLangSys, [in] int cMaxTags, [out] OPENTYPE_TAG *pFeatureTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontFeatureTags")] public static extern HRESULT ScriptGetFontFeatureTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] OPENTYPE_TAG[] pFeatureTags, out int pcTags); /// /// Retrieves a list of language tags that are available for the specified item and are supported by a specified script tag for /// OpenType processing. The tags comprising the list are retrieved from the font in the specified device context or cache. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the font language tags for the appropriate font and scripts can be retrieved. /// /// Alternately, the application can set this parameter to NULL to retrieve unfiltered results. /// /// /// An OPENTYPE_TAG structure defining the script tag for which the list of associated language tags is requested. /// /// The length of the array specified by pLangSysTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures identifying the language tags matching /// input criteria. /// /// Pointer to the number of elements in the language tag array. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds cMaxTags, the function fails with E_OUTOFMEMORY. The application can try calling /// again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, the OPENTYPE_TAG structure contains a 4-byte array that contains four 8-bit ASCII values /// of space, A-Z, or a-z. For example, the language tags for Romanian, Urdu, and Persian are "ROM ", "URD ", and "FAR ", /// respectively. Note that each tag ends with a space. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontlanguagetags HRESULT ScriptGetFontLanguageTags( // [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] int // cMaxTags, [out] OPENTYPE_TAG *pLangsysTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontLanguageTags")] public static extern HRESULT ScriptGetFontLanguageTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] OPENTYPE_TAG[] pLangsysTags, out int pcTags); /// /// Retrieves a list of language tags that are available for the specified item and are supported by a specified script tag for /// OpenType processing. The tags comprising the list are retrieved from the font in the specified device context or cache. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the font language tags for the appropriate font and scripts can be retrieved. /// /// Alternately, the application can set this parameter to NULL to retrieve unfiltered results. /// /// /// An OPENTYPE_TAG structure defining the script tag for which the list of associated language tags is requested. /// /// The length of the array specified by pLangSysTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures identifying the language tags matching /// input criteria. /// /// Pointer to the number of elements in the language tag array. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds cMaxTags, the function fails with E_OUTOFMEMORY. The application can try calling /// again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, the OPENTYPE_TAG structure contains a 4-byte array that contains four 8-bit ASCII values /// of space, A-Z, or a-z. For example, the language tags for Romanian, Urdu, and Persian are "ROM ", "URD ", and "FAR ", /// respectively. Note that each tag ends with a space. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontlanguagetags HRESULT ScriptGetFontLanguageTags( // [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] int // cMaxTags, [out] OPENTYPE_TAG *pLangsysTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontLanguageTags")] public static extern HRESULT ScriptGetFontLanguageTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, OPENTYPE_TAG tagScript, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] OPENTYPE_TAG[] pLangsysTags, out int pcTags); /// Retrieves information from the font cache on the special glyphs used by a font. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// Pointer to a SCRIPT_FONTPROPERTIES structure in which this function retrieves the information from the font cache. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// The structure retrieved by this function identifies the glyphs that are used for blanks, missing glyphs, invalid combinations, /// and the smallest kashida. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontproperties HRESULT ScriptGetFontProperties( [in] // HDC hdc, [in, out] SCRIPT_CACHE *psc, [out] SCRIPT_FONTPROPERTIES *sfp ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontProperties")] public static extern HRESULT ScriptGetFontProperties([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, ref SCRIPT_FONTPROPERTIES sfp); /// /// Retrieves a list of scripts available in the font for OpenType processing. Scripts comprising the list are retrieved from the /// font located in the supplied device context or from the script shaping engine that processes the font of the current run. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the appropriate font script tags can be retrieved. The application supplies a non- NULL value for /// this parameter to retrieve script tags appropriate for the current run. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// The length of the array specified by pScriptTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures defining script tags from the device /// context or the scripting engine associated with the current run. If the value of the eScript member of the SCRIPT_ANALYSIS /// structure provided in the psa parameter has a definite script tag associated with it and the tag is present in the font, /// pScriptTags contains only this tag. /// /// Pointer to the number of elements in the script tag array indicated by pScriptTags. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds the value of cMaxTags, the function fails with E_OUTOFMEMORY. The application can /// try calling again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, OPENTYPE_TAG defines a 4-byte array that contains four 8-bit ASCII values of space, A-Z /// or a-z. For example, the script tags for Latin and Arabic scripts are "latn" and "arab", respectively. /// /// This function retrieves a single tag from a font in the following cases: /// /// /// The psa value is associated with text for a single complex script. /// /// /// The psa parameter indicates NULL and the font supports a single script. /// /// /// /// If ScriptGetFontScriptTags retrieves all tags from a font, the tags are usually for neutral items, such as digits. Note /// that more than one tag might be applicable because some text runs of neutral items are not script-specific. /// /// /// If a tag corresponding to a particular script is present, a shaping engine might be unable to use the font to shape the given /// item because the engine lacks a needed item, such as a specific language system or a specific feature. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontscripttags HRESULT ScriptGetFontScriptTags( [in, // optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] int cMaxTags, [out] OPENTYPE_TAG // *pScriptTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontScriptTags")] public static extern HRESULT ScriptGetFontScriptTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] OPENTYPE_TAG[] pScriptTags, out int pcTags); /// /// Retrieves a list of scripts available in the font for OpenType processing. Scripts comprising the list are retrieved from the /// font located in the supplied device context or from the script shaping engine that processes the font of the current run. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine, so that the appropriate font script tags can be retrieved. The application supplies a non- NULL value for /// this parameter to retrieve script tags appropriate for the current run. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// The length of the array specified by pScriptTags. /// /// Pointer to a buffer in which this function retrieves an array of OPENTYPE_TAG structures defining script tags from the device /// context or the scripting engine associated with the current run. If the value of the eScript member of the SCRIPT_ANALYSIS /// structure provided in the psa parameter has a definite script tag associated with it and the tag is present in the font, /// pScriptTags contains only this tag. /// /// Pointer to the number of elements in the script tag array indicated by pScriptTags. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// If the number of matching tags exceeds the value of cMaxTags, the function fails with E_OUTOFMEMORY. The application can /// try calling again with larger buffers. /// /// /// /// /// While formally declared as a ULONG type, OPENTYPE_TAG defines a 4-byte array that contains four 8-bit ASCII values of space, A-Z /// or a-z. For example, the script tags for Latin and Arabic scripts are "latn" and "arab", respectively. /// /// This function retrieves a single tag from a font in the following cases: /// /// /// The psa value is associated with text for a single complex script. /// /// /// The psa parameter indicates NULL and the font supports a single script. /// /// /// /// If ScriptGetFontScriptTags retrieves all tags from a font, the tags are usually for neutral items, such as digits. Note /// that more than one tag might be applicable because some text runs of neutral items are not script-specific. /// /// /// If a tag corresponding to a particular script is present, a shaping engine might be unable to use the font to shape the given /// item because the engine lacks a needed item, such as a specific language system or a specific feature. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetfontscripttags HRESULT ScriptGetFontScriptTags( [in, // optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] int cMaxTags, [out] OPENTYPE_TAG // *pScriptTags, [out] int *pcTags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetFontScriptTags")] public static extern HRESULT ScriptGetFontScriptTags([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, int cMaxTags, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] OPENTYPE_TAG[] pScriptTags, out int pcTags); /// Retrieves the ABC width of a given glyph. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Glyph to analyze. /// Pointer to the ABC width of the specified glyph. /// /// Returns S_OK if the ABC width of the glyph is retrieved. The function returns a nonzero HRESULT value if it does not succeed. /// The function returns E_HANDLE if the font or operating system does not support glyph indexes. /// /// /// /// This function is limited in its usefulness. For example, it is useful for drawing glyph charts. It should not be used for /// ordinary complex script text formatting. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetglyphabcwidth HRESULT ScriptGetGlyphABCWidth( [in] HDC // hdc, [in, out] SCRIPT_CACHE *psc, [in] WORD wGlyph, [out] ABC *pABC ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetGlyphABCWidth")] public static extern HRESULT ScriptGetGlyphABCWidth([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, ushort wGlyph, out ABC pABC); /// Converts the glyph advance widths for a specific font into logical widths. /// Pointer to a SCRIPT_ANALYSIS structure. /// Count of the logical code points in the run. /// Count of the glyphs in the run. /// Pointer to an array of glyph advance widths. /// Pointer to an array of logical clusters. /// Pointer to a SCRIPT_VISATTR structure defining visual attributes. /// Pointer to an array of logical widths. /// Currently returns S_OK in all cases. /// /// /// This function is useful for recording widths in a font-independent manner. It converts the glyph advance widths calculated for a /// specific font into logical widths, one per code point, in the same order as the code points. If the same string is then displayed /// on a different device using a different font, the logical widths can be applied by using ScriptApplyLogicalWidth to approximate /// the original placement. This mechanism is useful when implementing print preview. On the preview screen, it is important to match /// the layout and placement of the final printed result. /// /// Note Ligature glyph widths are divided evenly among the characters they represent. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetlogicalwidths HRESULT ScriptGetLogicalWidths( [in] // const SCRIPT_ANALYSIS *psa, [in] int cChars, [in] int cGlyphs, [in] const int *piGlyphWidth, [in] const WORD *pwLogClust, [in] // const SCRIPT_VISATTR *psva, [out] int *piDx ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetLogicalWidths")] public static extern HRESULT ScriptGetLogicalWidths(in SCRIPT_ANALYSIS psa, int cChars, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piGlyphWidth, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ushort[] pwLogClust, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_VISATTR[] psva, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] piDx); /// Retrieves information about the current scripts. /// Pointer to an array of pointers to SCRIPT_PROPERTIES structures indexed by script. /// Pointer to the number of scripts. The valid range for this value is 0 through piNumScripts-1. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// See Determining If a Script Requires Glyph Shaping for an example of the use of this function. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetproperties HRESULT ScriptGetProperties( [out] const // SCRIPT_PROPERTIES ***ppSp, [out] int *piNumScripts ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetProperties")] public static extern HRESULT ScriptGetProperties(out IntPtr ppSp, out int piNumScripts); /// Retrieves information about the current scripts. /// Pointer to an array of pointers to SCRIPT_PROPERTIES structures indexed by script. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// See Determining If a Script Requires Glyph Shaping for an example of the use of this function. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptgetproperties HRESULT ScriptGetProperties( [out] const // SCRIPT_PROPERTIES ***ppSp, [out] int *piNumScripts ); [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptGetProperties")] public static HRESULT ScriptGetProperties(out SCRIPT_PROPERTIES[] ppSp) { HRESULT hr = ScriptGetProperties(out IntPtr p, out int c); ppSp = hr.Succeeded ? Array.ConvertAll(p.ToArray(c), i => (SCRIPT_PROPERTIES)Marshal.ReadInt64(i)) : null; return hr; } /// Determines whether a Unicode string requires complex script processing. /// Pointer to the string to test. /// Length of the input string, in characters. /// /// Flags specifying testing details. This parameter can have one of the following values. /// /// /// Value /// Meaning /// /// /// SIC_ASCIIDIGIT /// /// Treat digits U+0030 to U+0039 as complex. The application sets this flag if the string is displayed with digit substitution /// enabled. If the application is following the user's National Language Support (NLS) settings using the /// ScriptRecordDigitSubstitution function, it can pass a SCRIPT_DIGITSUBSTITUTE structure with the DigitSubstitute member set /// to SCRIPT_DIGITSUBSTITUTE_NONE. /// /// /// /// SIC_COMPLEX /// Treat complex script letters as complex. This flag should normally be set. /// /// /// SIC_NEUTRAL /// Treat neutrals as complex. The application sets this flag to display the string with right-to-left reading order. /// /// /// /// /// Returns S_OK if the string requires complex script processing. The function returns S_FALSE if the string can be handled by /// standard API function calls, that is, it contains only characters laid out side-by-side and left-to-right. The function returns a /// nonzero HRESULT value if it does not succeed. /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptiscomplex HRESULT ScriptIsComplex( [in] const WCHAR // *pwcInChars, [in] int cInChars, [in] DWORD dwFlags ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptIsComplex")] public static extern HRESULT ScriptIsComplex([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, SIC dwFlags); /// Breaks a Unicode string into individually shapeable items. /// Pointer to a Unicode string to itemize. /// Number of characters in pwcInChars to itemize. /// Maximum number of SCRIPT_ITEM structures defining items to process. /// /// Pointer to a SCRIPT_CONTROL structure indicating the type of itemization to perform. /// /// Alternatively, the application can set this parameter to NULL if no SCRIPT_CONTROL properties are needed. For more /// information, see the Remarks section. /// /// /// /// Pointer to a SCRIPT_STATE structure indicating the initial bidirectional algorithm state. /// /// Alternatively, the application can set this parameter to NULL if the script state is not needed. For more information, see /// the Remarks section. /// /// /// /// Pointer to a buffer in which the function retrieves SCRIPT_ITEM structures representing the items that have been processed. The /// buffer should be (cMaxItems + 1) * sizeof(SCRIPT_ITEM) bytes in length. It is invalid to call this function with a buffer /// that handles less than two SCRIPT_ITEM structures. The function always adds a terminal item to the item analysis array so /// that the length of the item with zero-based index "i" is always available as: /// pItems[i+1].iCharPos -pItems[i].iCharPos; /// /// Pointer to the number of SCRIPT_ITEM structures processed. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. /// /// The function returns E_INVALIDARG if pwcInChars is set to NULL, cInChars is 0, pItems is set to /// NULL, or cMaxItems < 2. /// /// /// The function returns E_OUTOFMEMORY if the value of cMaxItems is insufficient. As in all error cases, no items are fully /// processed and no part of the output array contains defined values. If the function returns E_OUTOFMEMORY, the application can /// call it again with a larger pItems buffer. /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// The function delimits items by either a change of shaping engine or a change of direction. /// /// The application can create multiple ranges, or runs that fall entirely within a single item, from each SCRIPT_ITEM structure /// retrieved by ScriptItemize. However, it should not combine multiple items into a single run. Later, when measuring or /// rendering, the application can call ScriptShape for each run and must pass the SCRIPT_ANALYSIS structure retrieved by /// ScriptItemize in the SCRIPT_ITEM structure. /// /// /// If the text handled by an application can include any right-to-left content, the application uses the psControl and /// psState parameters in calling ScriptItemize. However, the application does not have to do this and can handle /// bidirectional text itself instead of relying on Uniscribe to do so. The psControl and psState parameters are useful /// in some strictly left-to-right scenarios, for example, when the fLinkStringBefore member of SCRIPT_CONTROL is not specific /// to right-to-left scripts. The application sets psControl and psState to NULL to have ScriptItemize /// break the Unicode string purely by character code. /// /// /// The application can set all parameters to non- NULL values to have the function perform a full Unicode bidirectional /// analysis. To permit a correct Unicode bidirectional analysis, the SCRIPT_STATE structure should be initialized according to the /// reading order at paragraph start, and ScriptItemize should be passed the whole paragraph. In particular, the /// uBidiLevel member should be initialized to 0 for left-to-right and 1 for right-to-left. /// /// /// The fRTL member of SCRIPT_ANALYSIS is referenced in SCRIPT_ITEM enabled="1". The fNumeric member of /// SCRIPT_PROPERTIES is retrieved by ScriptGetProperties. These members together provide the same classification as the /// lpClass member of GCP_RESULTS, referenced by lpResults in GetCharacterPlacement. /// /// European digits U+0030 through U+0039 can be rendered as national digits, as shown in the following table. /// /// /// SCRIPT_STATE.fDigitSubstitute /// SCRIPT_CONTROL.fContextDigits /// Digit shapes displayed for Unicode U+0030 through U+0039 /// /// /// FALSE /// Any /// European digits /// /// /// TRUE /// FALSE /// As specified in uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// TRUE /// TRUE /// As prior strong text, defaulting to uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// In context digit mode, one of the following actions occurs: /// /// /// /// If the script specified by uDefaultLanguage is in the same direction as the output, all digits encountered before the /// first letters are rendered in the language indicated by uDefaultLanguage. /// /// /// /// /// If the script specified by uDefaultLanguage is in the opposite direction from the output, all digits encountered before /// the first letters are rendered in European digits. /// /// /// /// /// For example, if uDefaultLanguage indicates LANG_ARABIC, initial digits are in Arabic-Indic in a right-to-left embedding. /// However, they are in European digits in a left-to-right embedding. /// /// For more information, see Digit Shapes. /// /// The Unicode control characters and definitions, and their effects on SCRIPT_STATE members, are provided in the following table. /// For more information on Unicode control characters, see the The Unicode Standard. /// /// /// /// Unicode control characters /// Meaning /// Effect on SCRIPT_STATE /// /// /// NADS /// Override European digits (NODS) with national digit shapes. /// Set fDigitSubstitute. /// /// /// NODS /// Use nominal digit shapes, otherwise known as European digits. See NADS. /// Clear fDigitSubstitute. /// /// /// ASS /// /// Activate swapping of symmetric pairs, for example, parentheses. For these characters, left and right are interpreted as opening /// and closing. This is the default. See ISS. /// /// Clear fInhibitSymSwap. /// /// /// ISS /// Inhibit swapping of symmetric pairs. See ASS. /// Set fInhibitSymSwap. /// /// /// AAFS /// Activate Arabic form shaping for Arabic presentation forms. See IAFS. /// Set fCharShape. /// /// /// IAFS /// /// Inhibit Arabic form shaping, that is, ligatures and cursive connections, for Arabic presentation forms. Nominal Arabic characters /// are not affected. This is the default. See AAFS. /// /// Clear fCharShape. /// /// /// /// The fArabicNumContext member of SCRIPT_STATE supports the context-sensitive display of numerals in Arabic script text. It /// indicates if digits are rendered using native Arabic script digit shapes or European digits. At the beginning of a paragraph, /// this member should normally be initialized to TRUE for an Arabic locale, or FALSE for any other locale. The /// function updates the script state it as it processes strong text. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptitemize HRESULT ScriptItemize( [in] const WCHAR // *pwcInChars, [in] int cInChars, [in] int cMaxItems, [in, optional] const SCRIPT_CONTROL *psControl, [in, optional] const // SCRIPT_STATE *psState, [out] SCRIPT_ITEM *pItems, [out] int *pcItems ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptItemize")] public static extern HRESULT ScriptItemize([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, int cMaxItems, in SCRIPT_CONTROL psControl, in SCRIPT_STATE psState, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_ITEM[] pItems, out int pcItems); /// Breaks a Unicode string into individually shapeable items. /// Pointer to a Unicode string to itemize. /// Number of characters in pwcInChars to itemize. /// Maximum number of SCRIPT_ITEM structures defining items to process. /// /// Pointer to a SCRIPT_CONTROL structure indicating the type of itemization to perform. /// /// Alternatively, the application can set this parameter to NULL if no SCRIPT_CONTROL properties are needed. For more /// information, see the Remarks section. /// /// /// /// Pointer to a SCRIPT_STATE structure indicating the initial bidirectional algorithm state. /// /// Alternatively, the application can set this parameter to NULL if the script state is not needed. For more information, see /// the Remarks section. /// /// /// /// Pointer to a buffer in which the function retrieves SCRIPT_ITEM structures representing the items that have been processed. The /// buffer should be (cMaxItems + 1) * sizeof(SCRIPT_ITEM) bytes in length. It is invalid to call this function with a buffer /// that handles less than two SCRIPT_ITEM structures. The function always adds a terminal item to the item analysis array so /// that the length of the item with zero-based index "i" is always available as: /// pItems[i+1].iCharPos -pItems[i].iCharPos; /// /// Pointer to the number of SCRIPT_ITEM structures processed. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. /// /// The function returns E_INVALIDARG if pwcInChars is set to NULL, cInChars is 0, pItems is set to /// NULL, or cMaxItems < 2. /// /// /// The function returns E_OUTOFMEMORY if the value of cMaxItems is insufficient. As in all error cases, no items are fully /// processed and no part of the output array contains defined values. If the function returns E_OUTOFMEMORY, the application can /// call it again with a larger pItems buffer. /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// The function delimits items by either a change of shaping engine or a change of direction. /// /// The application can create multiple ranges, or runs that fall entirely within a single item, from each SCRIPT_ITEM structure /// retrieved by ScriptItemize. However, it should not combine multiple items into a single run. Later, when measuring or /// rendering, the application can call ScriptShape for each run and must pass the SCRIPT_ANALYSIS structure retrieved by /// ScriptItemize in the SCRIPT_ITEM structure. /// /// /// If the text handled by an application can include any right-to-left content, the application uses the psControl and /// psState parameters in calling ScriptItemize. However, the application does not have to do this and can handle /// bidirectional text itself instead of relying on Uniscribe to do so. The psControl and psState parameters are useful /// in some strictly left-to-right scenarios, for example, when the fLinkStringBefore member of SCRIPT_CONTROL is not specific /// to right-to-left scripts. The application sets psControl and psState to NULL to have ScriptItemize /// break the Unicode string purely by character code. /// /// /// The application can set all parameters to non- NULL values to have the function perform a full Unicode bidirectional /// analysis. To permit a correct Unicode bidirectional analysis, the SCRIPT_STATE structure should be initialized according to the /// reading order at paragraph start, and ScriptItemize should be passed the whole paragraph. In particular, the /// uBidiLevel member should be initialized to 0 for left-to-right and 1 for right-to-left. /// /// /// The fRTL member of SCRIPT_ANALYSIS is referenced in SCRIPT_ITEM enabled="1". The fNumeric member of /// SCRIPT_PROPERTIES is retrieved by ScriptGetProperties. These members together provide the same classification as the /// lpClass member of GCP_RESULTS, referenced by lpResults in GetCharacterPlacement. /// /// European digits U+0030 through U+0039 can be rendered as national digits, as shown in the following table. /// /// /// SCRIPT_STATE.fDigitSubstitute /// SCRIPT_CONTROL.fContextDigits /// Digit shapes displayed for Unicode U+0030 through U+0039 /// /// /// FALSE /// Any /// European digits /// /// /// TRUE /// FALSE /// As specified in uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// TRUE /// TRUE /// As prior strong text, defaulting to uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// In context digit mode, one of the following actions occurs: /// /// /// /// If the script specified by uDefaultLanguage is in the same direction as the output, all digits encountered before the /// first letters are rendered in the language indicated by uDefaultLanguage. /// /// /// /// /// If the script specified by uDefaultLanguage is in the opposite direction from the output, all digits encountered before /// the first letters are rendered in European digits. /// /// /// /// /// For example, if uDefaultLanguage indicates LANG_ARABIC, initial digits are in Arabic-Indic in a right-to-left embedding. /// However, they are in European digits in a left-to-right embedding. /// /// For more information, see Digit Shapes. /// /// The Unicode control characters and definitions, and their effects on SCRIPT_STATE members, are provided in the following table. /// For more information on Unicode control characters, see the The Unicode Standard. /// /// /// /// Unicode control characters /// Meaning /// Effect on SCRIPT_STATE /// /// /// NADS /// Override European digits (NODS) with national digit shapes. /// Set fDigitSubstitute. /// /// /// NODS /// Use nominal digit shapes, otherwise known as European digits. See NADS. /// Clear fDigitSubstitute. /// /// /// ASS /// /// Activate swapping of symmetric pairs, for example, parentheses. For these characters, left and right are interpreted as opening /// and closing. This is the default. See ISS. /// /// Clear fInhibitSymSwap. /// /// /// ISS /// Inhibit swapping of symmetric pairs. See ASS. /// Set fInhibitSymSwap. /// /// /// AAFS /// Activate Arabic form shaping for Arabic presentation forms. See IAFS. /// Set fCharShape. /// /// /// IAFS /// /// Inhibit Arabic form shaping, that is, ligatures and cursive connections, for Arabic presentation forms. Nominal Arabic characters /// are not affected. This is the default. See AAFS. /// /// Clear fCharShape. /// /// /// /// The fArabicNumContext member of SCRIPT_STATE supports the context-sensitive display of numerals in Arabic script text. It /// indicates if digits are rendered using native Arabic script digit shapes or European digits. At the beginning of a paragraph, /// this member should normally be initialized to TRUE for an Arabic locale, or FALSE for any other locale. The /// function updates the script state it as it processes strong text. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptitemize HRESULT ScriptItemize( [in] const WCHAR // *pwcInChars, [in] int cInChars, [in] int cMaxItems, [in, optional] const SCRIPT_CONTROL *psControl, [in, optional] const // SCRIPT_STATE *psState, [out] SCRIPT_ITEM *pItems, [out] int *pcItems ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptItemize")] public static extern HRESULT ScriptItemize([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, int cMaxItems, [In, Optional] IntPtr psControl, [In, Optional] IntPtr psState, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_ITEM[] pItems, out int pcItems); /// /// Breaks a Unicode string into individually shapeable items and provides an array of feature tags for each shapeable item for /// OpenType processing. /// /// Pointer to a Unicode string to itemize. /// Number of characters in pwcInChars to itemize. /// Maximum number of SCRIPT_ITEM structures defining items to process. /// /// Pointer to a SCRIPT_CONTROL structure indicating the type of itemization to perform. /// /// Alternatively, the application can set this parameter to NULL if no SCRIPT_CONTROL properties are needed. For more /// information, see the Remarks section. /// /// /// /// Pointer to a SCRIPT_STATE structure indicating the initial bidirectional algorithm state. /// /// Alternatively, the application can set this parameter to NULL if the script state is not needed. For more information, see /// the Remarks section. /// /// /// /// Pointer to a buffer in which the function retrieves SCRIPT_ITEM structures representing the items that have been processed. The /// buffer should be (cMaxItems + 1) * sizeof(SCRIPT_ITEM) bytes in length. It is invalid to call this function with a buffer /// that handles less than two SCRIPT_ITEM structures. The function always adds a terminal item to the item analysis array so /// that the length of the item with zero-based index "i" is always available as: /// pItems[i+1].iCharPos -pItems[i].iCharPos; /// /// /// /// Pointer to a buffer in which the function retrieves an array of OPENTYPE_TAG structures representing script tags. The buffer /// should be /// cMaxItems * sizeof(OPENTYPE_TAG) /// bytes in length. /// /// /// Note When all characters in an item are neutral, the value of this parameter is SCRIPT_TAG_UNKNOWN (0x00000000). This can /// happen, for example, if an item consists entirely of punctuation. /// /// /// Pointer to the number of SCRIPT_ITEM structures processed. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, no items are /// fully processed and no part of the output contains defined values. The application can test the return value with the /// SUCCEEDED and FAILED macros. /// /// /// The function returns E_OUTOFMEMORY if the size indicated by cMaxItems is too small. The application can try calling the /// function again with a larger buffer. /// /// The function returns E_INVALIDARG if one or more of the following conditions occur: /// /// /// pwcInChars is set to NULL /// /// /// cInChars is 0 /// /// /// pItems is set to NULL /// /// /// pScriptTags is set to NULL /// /// /// cMaxItems < 2 /// /// /// /// /// /// ScriptItemizeOpenType is preferred over the older ScriptItemize function. One advantage of ScriptItemizeOpenType is /// the availability of feature tags for each shapeable item. /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// The function delimits items by either a change of shaping engine or a change of direction. /// /// The application can create multiple ranges, or runs that fall entirely within a single item, from each SCRIPT_ITEM structure /// retrieved by ScriptItemizeOpenType. However, it should not combine multiple items into a single run. When measuring or /// rendering, the application can call ScriptShapeOpenType for each run and must pass the corresponding SCRIPT_ANALYSIS structure in /// the SCRIPT_ITEM structure retrieved by ScriptItemizeOpenType. /// /// /// If the text handled by an application can include any right-to-left content, the application uses the psControl and /// psState parameters in calling ScriptItemizeOpenType. However, the application does not have to do this and can /// handle bidirectional text itself instead of relying on Uniscribe to do so. The psControl and psState parameters are /// useful in some strictly left-to-right scenarios, for example, when the fLinkStringBefore member of SCRIPT_CONTROL is not /// specific to right-to-left scripts. The application sets psControl and psState to NULL to have /// ScriptItemizeOpenType break the Unicode string purely by character code. /// /// /// The application can set all parameters to non- NULL values to have the function perform a full Unicode bidirectional /// analysis. To permit a correct Unicode bidirectional analysis, the SCRIPT_STATE structure should be initialized according to the /// reading order at paragraph start, and ScriptItemizeOpenType should be passed the whole paragraph. In particular, the /// uBidiLevel member should be initialized to 0 for left-to-right and 1 for right-to-left. /// /// /// The fRTL member of SCRIPT_ANALYSIS is referenced in SCRIPT_ITEM. The fNumeric member of SCRIPT_PROPERTIES is /// retrieved by ScriptGetProperties. These members together provide the same classification as the lpClass member of /// GCP_RESULTS, referenced by lpResults in GetCharacterPlacement. /// /// European digits U+0030 through U+0039 can be rendered as national digits, as shown in the following table. /// /// /// SCRIPT_STATE.fDigitSubstitute /// SCRIPT_CONTROL.fContextDigits /// Digit shapes displayed for Unicode U+0030 through U+0039 /// /// /// FALSE /// Any /// European digits /// /// /// TRUE /// FALSE /// As specified in uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// TRUE /// TRUE /// As prior strong text, defaulting to uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// In context digit mode, one of the following actions occurs: /// /// /// /// If the script specified by uDefaultLanguage is in the same direction as the output, all digits encountered before the /// first letters are rendered in the language indicated by uDefaultLanguage. /// /// /// /// /// If the script specified by uDefaultLanguage is in the opposite direction from the output, all digits encountered before /// the first letters are rendered in European digits. /// /// /// /// /// For example, if uDefaultLanguage indicates LANG_ARABIC, initial digits are in Arabic-Indic in a right-to-left embedding. /// However they are in European digits in a left-to-right embedding. /// /// For more information, see Digit Shapes. /// /// The Unicode control characters and definitions, and their effects on SCRIPT_STATE members, are provided in the following table. /// For more information on Unicode control characters, see the The Unicode Standard. /// /// /// /// Unicode control characters /// Meaning /// Effect on SCRIPT_STATE /// /// /// NADS /// Override European digits (NODS) with national digit shapes. /// Set fDigitSubstitute. /// /// /// NODS /// Use nominal digit shapes, otherwise known as European digits. See NADS. /// Clear fDigitSubstitute. /// /// /// ASS /// /// Activate swapping of symmetric pairs, for example, parentheses. For these characters, left and right are interpreted as opening /// and closing. This is the default. See ISS. /// /// Clear fInhibitSymSwap. /// /// /// ISS /// Inhibit swapping of symmetric pairs. See ASS. /// Set fInhibitSymSwap. /// /// /// AAFS /// Activate Arabic form shaping for Arabic presentation forms. See IAFS. /// Set fCharShape. /// /// /// IAFS /// /// Inhibit Arabic form shaping, that is, ligatures and cursive connections, for Arabic presentation forms. Nominal Arabic characters /// are not affected. This is the default. See AAFS. /// /// Clear fCharShape. /// /// /// /// The fArabicNumContext member of SCRIPT_STATE supports the context-sensitive display of numerals in Arabic script text. It /// indicates if digits are rendered using native Arabic script digit shapes or European digits. At the beginning of a paragraph, /// this member should normally be initialized to TRUE for an Arabic locale, or FALSE for any other locale. The /// function updates the script state it as it processes strong text. /// /// /// The output parameter pScriptTags indicates an array with entries parallel to items. For each item, this function retrieves /// a script tag that should be used for shaping in all subsequent operations. /// /// /// A script tag is usually determined by ScriptItemizeOpenType from input characters. If the function retrieves a specific /// script tag, the application should pass it to other functions without change. However, when characters are neutral (for example, /// digits) and the script cannot be determined, the application should choose an appropriate script tag, for example, based on font /// and language associated with text. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptitemizeopentype HRESULT ScriptItemizeOpenType( [in] const // WCHAR *pwcInChars, [in] int cInChars, [in] int cMaxItems, [in, optional] const SCRIPT_CONTROL *psControl, [in, optional] const // SCRIPT_STATE *psState, [out] SCRIPT_ITEM *pItems, [out] OPENTYPE_TAG *pScriptTags, [out] int *pcItems ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptItemizeOpenType")] public static extern HRESULT ScriptItemizeOpenType([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, int cMaxItems, in SCRIPT_CONTROL psControl, in SCRIPT_STATE psState, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_ITEM[] pItems, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] OPENTYPE_TAG[] pScriptTags, out int pcItems); /// /// Breaks a Unicode string into individually shapeable items and provides an array of feature tags for each shapeable item for /// OpenType processing. /// /// Pointer to a Unicode string to itemize. /// Number of characters in pwcInChars to itemize. /// Maximum number of SCRIPT_ITEM structures defining items to process. /// /// Pointer to a SCRIPT_CONTROL structure indicating the type of itemization to perform. /// /// Alternatively, the application can set this parameter to NULL if no SCRIPT_CONTROL properties are needed. For more /// information, see the Remarks section. /// /// /// /// Pointer to a SCRIPT_STATE structure indicating the initial bidirectional algorithm state. /// /// Alternatively, the application can set this parameter to NULL if the script state is not needed. For more information, see /// the Remarks section. /// /// /// /// Pointer to a buffer in which the function retrieves SCRIPT_ITEM structures representing the items that have been processed. The /// buffer should be (cMaxItems + 1) * sizeof(SCRIPT_ITEM) bytes in length. It is invalid to call this function with a buffer /// that handles less than two SCRIPT_ITEM structures. The function always adds a terminal item to the item analysis array so /// that the length of the item with zero-based index "i" is always available as: /// pItems[i+1].iCharPos -pItems[i].iCharPos; /// /// /// /// Pointer to a buffer in which the function retrieves an array of OPENTYPE_TAG structures representing script tags. The buffer /// should be /// cMaxItems * sizeof(OPENTYPE_TAG) /// bytes in length. /// /// /// Note When all characters in an item are neutral, the value of this parameter is SCRIPT_TAG_UNKNOWN (0x00000000). This can /// happen, for example, if an item consists entirely of punctuation. /// /// /// Pointer to the number of SCRIPT_ITEM structures processed. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, no items are /// fully processed and no part of the output contains defined values. The application can test the return value with the /// SUCCEEDED and FAILED macros. /// /// /// The function returns E_OUTOFMEMORY if the size indicated by cMaxItems is too small. The application can try calling the /// function again with a larger buffer. /// /// The function returns E_INVALIDARG if one or more of the following conditions occur: /// /// /// pwcInChars is set to NULL /// /// /// cInChars is 0 /// /// /// pItems is set to NULL /// /// /// pScriptTags is set to NULL /// /// /// cMaxItems < 2 /// /// /// /// /// /// ScriptItemizeOpenType is preferred over the older ScriptItemize function. One advantage of ScriptItemizeOpenType is /// the availability of feature tags for each shapeable item. /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// The function delimits items by either a change of shaping engine or a change of direction. /// /// The application can create multiple ranges, or runs that fall entirely within a single item, from each SCRIPT_ITEM structure /// retrieved by ScriptItemizeOpenType. However, it should not combine multiple items into a single run. When measuring or /// rendering, the application can call ScriptShapeOpenType for each run and must pass the corresponding SCRIPT_ANALYSIS structure in /// the SCRIPT_ITEM structure retrieved by ScriptItemizeOpenType. /// /// /// If the text handled by an application can include any right-to-left content, the application uses the psControl and /// psState parameters in calling ScriptItemizeOpenType. However, the application does not have to do this and can /// handle bidirectional text itself instead of relying on Uniscribe to do so. The psControl and psState parameters are /// useful in some strictly left-to-right scenarios, for example, when the fLinkStringBefore member of SCRIPT_CONTROL is not /// specific to right-to-left scripts. The application sets psControl and psState to NULL to have /// ScriptItemizeOpenType break the Unicode string purely by character code. /// /// /// The application can set all parameters to non- NULL values to have the function perform a full Unicode bidirectional /// analysis. To permit a correct Unicode bidirectional analysis, the SCRIPT_STATE structure should be initialized according to the /// reading order at paragraph start, and ScriptItemizeOpenType should be passed the whole paragraph. In particular, the /// uBidiLevel member should be initialized to 0 for left-to-right and 1 for right-to-left. /// /// /// The fRTL member of SCRIPT_ANALYSIS is referenced in SCRIPT_ITEM. The fNumeric member of SCRIPT_PROPERTIES is /// retrieved by ScriptGetProperties. These members together provide the same classification as the lpClass member of /// GCP_RESULTS, referenced by lpResults in GetCharacterPlacement. /// /// European digits U+0030 through U+0039 can be rendered as national digits, as shown in the following table. /// /// /// SCRIPT_STATE.fDigitSubstitute /// SCRIPT_CONTROL.fContextDigits /// Digit shapes displayed for Unicode U+0030 through U+0039 /// /// /// FALSE /// Any /// European digits /// /// /// TRUE /// FALSE /// As specified in uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// TRUE /// TRUE /// As prior strong text, defaulting to uDefaultLanguage member of SCRIPT_CONTROL. /// /// /// In context digit mode, one of the following actions occurs: /// /// /// /// If the script specified by uDefaultLanguage is in the same direction as the output, all digits encountered before the /// first letters are rendered in the language indicated by uDefaultLanguage. /// /// /// /// /// If the script specified by uDefaultLanguage is in the opposite direction from the output, all digits encountered before /// the first letters are rendered in European digits. /// /// /// /// /// For example, if uDefaultLanguage indicates LANG_ARABIC, initial digits are in Arabic-Indic in a right-to-left embedding. /// However they are in European digits in a left-to-right embedding. /// /// For more information, see Digit Shapes. /// /// The Unicode control characters and definitions, and their effects on SCRIPT_STATE members, are provided in the following table. /// For more information on Unicode control characters, see the The Unicode Standard. /// /// /// /// Unicode control characters /// Meaning /// Effect on SCRIPT_STATE /// /// /// NADS /// Override European digits (NODS) with national digit shapes. /// Set fDigitSubstitute. /// /// /// NODS /// Use nominal digit shapes, otherwise known as European digits. See NADS. /// Clear fDigitSubstitute. /// /// /// ASS /// /// Activate swapping of symmetric pairs, for example, parentheses. For these characters, left and right are interpreted as opening /// and closing. This is the default. See ISS. /// /// Clear fInhibitSymSwap. /// /// /// ISS /// Inhibit swapping of symmetric pairs. See ASS. /// Set fInhibitSymSwap. /// /// /// AAFS /// Activate Arabic form shaping for Arabic presentation forms. See IAFS. /// Set fCharShape. /// /// /// IAFS /// /// Inhibit Arabic form shaping, that is, ligatures and cursive connections, for Arabic presentation forms. Nominal Arabic characters /// are not affected. This is the default. See AAFS. /// /// Clear fCharShape. /// /// /// /// The fArabicNumContext member of SCRIPT_STATE supports the context-sensitive display of numerals in Arabic script text. It /// indicates if digits are rendered using native Arabic script digit shapes or European digits. At the beginning of a paragraph, /// this member should normally be initialized to TRUE for an Arabic locale, or FALSE for any other locale. The /// function updates the script state it as it processes strong text. /// /// /// The output parameter pScriptTags indicates an array with entries parallel to items. For each item, this function retrieves /// a script tag that should be used for shaping in all subsequent operations. /// /// /// A script tag is usually determined by ScriptItemizeOpenType from input characters. If the function retrieves a specific /// script tag, the application should pass it to other functions without change. However, when characters are neutral (for example, /// digits) and the script cannot be determined, the application should choose an appropriate script tag, for example, based on font /// and language associated with text. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptitemizeopentype HRESULT ScriptItemizeOpenType( [in] const // WCHAR *pwcInChars, [in] int cInChars, [in] int cMaxItems, [in, optional] const SCRIPT_CONTROL *psControl, [in, optional] const // SCRIPT_STATE *psState, [out] SCRIPT_ITEM *pItems, [out] OPENTYPE_TAG *pScriptTags, [out] int *pcItems ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptItemizeOpenType")] public static extern HRESULT ScriptItemizeOpenType([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, int cMaxItems, [In, Optional] IntPtr psControl, [In, Optional] IntPtr psState, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_ITEM[] pItems, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] OPENTYPE_TAG[] pScriptTags, out int pcItems); /// Creates an advance widths table to allow text justification when passed to the ScriptTextOut function. /// /// Pointer to an array, of length indicated by cGlyphs, containing SCRIPT_VISATTR structures. Each structure contains visual /// attributes for a glyph in the line to process. /// /// /// Pointer to an advance widths array, of length indicated by cGlyphs, obtained from a previous call to ScriptPlace. /// /// /// Count of glyphs for the arrays indicated by psva and piAdvance. This parameter also indicates the count of glyphs /// for the output parameter piJustify. /// /// Width, in pixels, of the desired change, either an increase of decrease. /// Minimum width of a kashida glyph to generate. /// /// Pointer to a buffer in which this function retrieves an array, of length indicated by cGlyphs, containing justified /// advance widths. The justified widths are sometimes called "cell widths" to distinguish them from unjustified advance widths. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// This function provides a simple implementation of multilingual justification. It establishes the amount of adjustment to make at /// each glyph position on the line. It interprets the SCRIPT_VISATTR array generated by a call to ScriptShape, giving top priority /// to kashida. The function uses interword spacing if no kashida points are available. It uses intercharacter spacing if no /// interword points are available. /// /// /// Note Sophisticated text formatters might generate their own delta dx array by combining formatter-specific features with /// the information retrieved by ScriptShape in the SCRIPT_VISATTR array. /// /// /// The application should pass the justified advance widths generated by ScriptJustify to ScriptTextOut in the /// piJustify parameter. /// /// /// ScriptJustify creates a justified array containing updated advance widths for each glyph. When an advance width for a /// glyph is increased, the extra width is rendered to the right of the glyph, with a white space or, for Arabic text, a kashida. /// /// /// Note Kashida insertion occurs to the right of the glyph to justify visually. Microsoft Word and Microsoft PowerPoint use /// this concept. Any change in the kashida placement algorithm should accompany a change in the corresponding ScriptTextOut handler /// for a particular script, for example, the Arabic TextOut justification handler. /// /// /// Sometimes the application tries to handle glyphs that cannot be justified, in which case the uJustification member of /// SCRIPT_VISATTR is set to SCRIPT_JUSTIFY_NONE. In this case, ScriptJustify copies the input array indicated by /// piAdvance to the output array indicated by piJustify and returns S_FALSE to the application. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptjustify HRESULT ScriptJustify( [in] const SCRIPT_VISATTR // *psva, [in] const int *piAdvance, [in] int cGlyphs, [in] int iDx, [in] int iMinKashida, [out] int *piJustify ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptJustify")] public static extern HRESULT ScriptJustify([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_VISATTR[] psva, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piAdvance, int cGlyphs, int iDx, int iMinKashida, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piJustify); /// Converts an array of run embedding levels to a map of visual-to-logical position and/or logical-to-visual position. /// Number of runs to process. /// /// Pointer to an array, of length indicated by cRuns, containing run embedding levels. Embedding levels for all runs on the /// line must be included, ordered logically. For more information, see the Remarks section. /// /// /// Pointer to an array, of length indicated by cRuns, in which this function retrieves the run embedding levels reordered to /// visual order. The first array element represents the run to display at the far left, and subsequent entries should be displayed /// progressing from left to right. The function sets this parameter to NULL if there is no output. /// /// /// Pointer to an array, of length indicated by cRuns, in which this function retrieves the visual run positions. The first /// array element is the relative visual position where the first logical run should be displayed, the leftmost display position /// being 0. The function sets this parameter to NULL if there is no output. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// This function handles only data that pertains to a single line of text. /// /// The run embedding levels are defined in the Unicode bidirectional algorithm. They describe the direction of a run, the direction /// of any runs in which it is embedded, and the direction of the paragraph. No other input is required for the call to this /// function. For more information, see Unicode. /// /// The following table lists the predefined embedding levels. The application can add levels as needed. /// /// /// Level /// Meaning /// /// /// 0 /// A left-to-right run in a left-to-right paragraph. /// /// /// 1 /// /// A right-to-left run embedded in a left-to-right run in a left-to-right paragraph. Alternatively, a right-to-left run, not /// embedded in another run, in a right-to-left paragraph. /// /// /// /// 2 /// A left-to-right run embedded in a right-to-left run of type 1. /// /// /// 3 /// A right-to-left run embedded in a left-to-right run of type 2. /// /// /// /// A "logical position" refers to the placement of a run relative to other runs. It is the position in a backing store, and /// corresponds to the order in which the user reads the text aloud. The "visual position" of a run refers to the way the run is /// visually displayed on the line, taking into account the possible directions that the run can have. /// /// The application can call this function setting either piLogicalToVisual or piVisualToLogical, or both. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptlayout HRESULT ScriptLayout( [in] int cRuns, [in] const // BYTE *pbLevel, [out, optional] int *piVisualToLogical, [out, optional] int *piLogicalToVisual ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptLayout")] public static extern HRESULT ScriptLayout(int cRuns, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] byte[] pbLevel, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] piVisualToLogical, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] piLogicalToVisual); /// Generates glyph advance width and two-dimensional offset information from the output of ScriptShape. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Pointer to a glyph buffer obtained from an earlier call to the ScriptShape function. /// Count of glyphs in the glyph buffer. /// Pointer to an array of SCRIPT_VISATTR structures indicating visual attributes. /// /// Pointer to a SCRIPT_ANALYSIS structure. On input, this structure is obtained from a previous call to ScriptItemize. On output, /// this structure contains values retrieved by ScriptPlace. /// /// Pointer to an array in which this function retrieves advance width information. /// /// Optional. Pointer to an array of GOFFSET structures in which this function retrieves the x and y offsets of combining glyphs. /// This array must be of length indicated by cGlyphs. /// /// Pointer to an ABC structure in which this function retrieves the ABC width for the entire run. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// The function returns E_PENDING if the script cache specified by the psc parameter does not contain enough information to /// place the glyphs, and the hdc parameter is set to NULL so that the function cannot complete the placement process. /// The application should set up a correct device context for the run, and call this function again with the appropriate device /// context and with all other parameters the same. /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// The composite ABC width for the whole item identifies how much the glyphs overhang to the left of the start position and to the /// right of the length implied by the sum of the advance widths. The total advance width of the line is exactly abcA+abcB+abcC. The /// abcA and abcC values are maintained as proportions of the cell height represented in 8 bits and are thus roughly +/-1 percent. /// The total width retrieved, which is the sum of the abcA+abcB+abcC values indicated by piAdvance, is accurate to the /// resolution of the TrueType shaping engine. /// /// /// All arrays are in visual order unless the fLogicalOrder member is set in the SCRIPT_ANALYSIS structure indicated by the /// psa parameter. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptplace HRESULT ScriptPlace( [in] HDC hdc, [in, out] // SCRIPT_CACHE *psc, [in] const WORD *pwGlyphs, [in] int cGlyphs, [in] const SCRIPT_VISATTR *psva, [in, out] SCRIPT_ANALYSIS *psa, // [out] int *piAdvance, [out] GOFFSET *pGoffset, [out] ABC *pABC ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPlace")] public static extern HRESULT ScriptPlace([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ushort[] pwGlyphs, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] SCRIPT_VISATTR[] psva, ref SCRIPT_ANALYSIS psa, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] int[] piAdvance, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] GOFFSET[] pGoffset, out ABC pABC); /// Generates glyph advance width and two-dimensional offset information from the output of ScriptShape. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Pointer to a glyph buffer obtained from an earlier call to the ScriptShape function. /// Count of glyphs in the glyph buffer. /// Pointer to an array of SCRIPT_VISATTR structures indicating visual attributes. /// /// Pointer to a SCRIPT_ANALYSIS structure. On input, this structure is obtained from a previous call to ScriptItemize. On output, /// this structure contains values retrieved by ScriptPlace. /// /// Pointer to an array in which this function retrieves advance width information. /// /// Optional. Pointer to an array of GOFFSET structures in which this function retrieves the x and y offsets of combining glyphs. /// This array must be of length indicated by cGlyphs. /// /// Pointer to an ABC structure in which this function retrieves the ABC width for the entire run. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// The function returns E_PENDING if the script cache specified by the psc parameter does not contain enough information to /// place the glyphs, and the hdc parameter is set to NULL so that the function cannot complete the placement process. /// The application should set up a correct device context for the run, and call this function again with the appropriate device /// context and with all other parameters the same. /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// The composite ABC width for the whole item identifies how much the glyphs overhang to the left of the start position and to the /// right of the length implied by the sum of the advance widths. The total advance width of the line is exactly abcA+abcB+abcC. The /// abcA and abcC values are maintained as proportions of the cell height represented in 8 bits and are thus roughly +/-1 percent. /// The total width retrieved, which is the sum of the abcA+abcB+abcC values indicated by piAdvance, is accurate to the /// resolution of the TrueType shaping engine. /// /// /// All arrays are in visual order unless the fLogicalOrder member is set in the SCRIPT_ANALYSIS structure indicated by the /// psa parameter. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptplace HRESULT ScriptPlace( [in] HDC hdc, [in, out] // SCRIPT_CACHE *psc, [in] const WORD *pwGlyphs, [in] int cGlyphs, [in] const SCRIPT_VISATTR *psva, [in, out] SCRIPT_ANALYSIS *psa, // [out] int *piAdvance, [out] GOFFSET *pGoffset, [out] ABC *pABC ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPlace")] public static extern HRESULT ScriptPlace([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ushort[] pwGlyphs, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] SCRIPT_VISATTR[] psva, [In, Optional] IntPtr psa, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] int[] piAdvance, [Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] GOFFSET[] pGoffset, out ABC pABC); /// Generates glyphs and visual attributes for a Unicode run with OpenType information from the output of ScriptShapeOpenType. /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This structures identifies the /// shaping engine that governs the generated list of glyphs and their associated widths, and x and y placement offsets. /// /// Alternatively, the application can set this parameter to NULL to receive unfiltered results. /// /// An OPENTYPE_TAG structure containing the OpenType script tag for the writing system to use. /// An OPENTYPE_TAG structure containing the OpenType language tag for the writing system. /// /// Array of the number of characters in each range. The number of members is indicated in the cRanges parameter. The total of /// values should equal the value of cChars. /// /// /// Array of TEXTRANGE_PROPERTIES structures defining properties for each range. The number of elements is defined by the /// cRanges parameter. /// /// The number of OpenType feature ranges. /// /// Pointer to an array of Unicode characters containing the run. The number of elements is defined by the cRanges parameter. /// /// /// Pointer to an array of logical cluster information. Each element in the array corresponds to a character in the array defined by /// pwcChars. The value of each element is the offset from the first glyph in the run to the first glyph in the cluster /// containing the corresponding character. Note that, when the fRTL member of the SCRIPT_ANALYSIS structure is set to /// TRUE, the elements in pwLogClust decrease as the array is read. /// /// Pointer to an array of character property values in the Unicode run. /// Number of characters in the Unicode run. /// Pointer to a glyph buffer obtained from an earlier call to the ScriptShapeOpenType function. /// /// Pointer to an array of attributes for each of the glyphs to retrieve. The number of values equals the value of cGlyphs. /// Since there is one glyph property per glyph, this parameter has the number of elements indicated by cGlyphs. /// /// Count of glyphs in a glyph array buffer. /// /// Pointer to an array, of length indicated by cGlyphs, in which this function retrieves advance width information. /// /// /// Pointer to an array of GOFFSET structures in which this structure retrieves the x and y offsets of combining glyphs. This array /// must be of length indicated by cGlyphs. /// /// Pointer to an ABC structure in which this function retrieves the ABC width for the entire run. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, the output /// values are undefined. The application can test the return value with the SUCCEEDED and FAILED macros. /// /// /// The function returns E_OUTOFMEMORY if the output buffer length indicated by cGlyphs is too small. The application can try /// calling again with larger buffers. /// /// /// The function returns E_PENDING if the script cache specified by the psc parameter does not contain enough information to /// place the glyphs, and the hdc parameter is passed as NULL so that the function is unable to complete the placement /// process. The application should set up a correct device context for the run, and call this function again with the appropriate /// value in hdc and with all other parameters the same. /// /// /// /// /// This function is preferred over the older ScriptPlace function. Some advantages of ScriptPlaceOpenType include the following: /// /// /// /// Parameters directly correspond to OpenType tags in font layout tables. /// /// /// /// Parameters define features applied to each character. Input is divided into ranges, and each range has OpenType properties /// associated with it. /// /// /// /// /// The composite ABC width for the whole item identifies how much the glyphs overhang to the left of the start position and to the /// right of the length implied by the sum of the advance widths. The total advance width of the line is exactly abcA+abcB+abcC. The /// abcA and abcC values are maintained as proportions of the cell height represented in 8 bits and are thus roughly +/-1 percent. /// The total width retrieved, which is the sum of the abcA+abcB+abcC values indicated by piAdvance, is accurate to the /// resolution of the TrueType shaping engine. /// /// /// All arrays are in visual order unless the fLogicalOrder member is set in the SCRIPT_ANALYSIS structure indicated by the /// psa parameter. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptplaceopentype HRESULT ScriptPlaceOpenType( [in, optional] // HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, out] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] OPENTYPE_TAG tagLangSys, // [in, optional] int *rcRangeChars, [in, optional] TEXTRANGE_PROPERTIES **rpRangeProperties, [in] int cRanges, [in] const WCHAR // *pwcChars, [in] WORD *pwLogClust, [in] SCRIPT_CHARPROP *pCharProps, [in] int cChars, [in] const WORD *pwGlyphs, [in] const // SCRIPT_GLYPHPROP *pGlyphProps, [in] int cGlyphs, [out] int *piAdvance, [out] GOFFSET *pGoffset, [out, optional] ABC *pABC ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPlaceOpenType")] public static extern HRESULT ScriptPlaceOpenType([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] int[] rcRangeChars, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] IntPtr[] rpRangeProperties, int cRanges, [MarshalAs(UnmanagedType.LPWStr)] string pwcChars, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 11)] ushort[] pwLogClust, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 11)] SCRIPT_CHARPROP[] pCharProps, int cChars, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] ushort[] pwGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] SCRIPT_GLYPHPROP[] pGlyphProps, int cGlyphs, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] int piAdvance, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] GOFFSET[] pGoffset, out ABC pABC); /// Generates glyphs and visual attributes for a Unicode run with OpenType information from the output of ScriptShapeOpenType. /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This structures identifies the /// shaping engine that governs the generated list of glyphs and their associated widths, and x and y placement offsets. /// /// Alternatively, the application can set this parameter to NULL to receive unfiltered results. /// /// An OPENTYPE_TAG structure containing the OpenType script tag for the writing system to use. /// An OPENTYPE_TAG structure containing the OpenType language tag for the writing system. /// /// Array of the number of characters in each range. The number of members is indicated in the cRanges parameter. The total of /// values should equal the value of cChars. /// /// /// Array of TEXTRANGE_PROPERTIES structures defining properties for each range. The number of elements is defined by the /// cRanges parameter. /// /// The number of OpenType feature ranges. /// /// Pointer to an array of Unicode characters containing the run. The number of elements is defined by the cRanges parameter. /// /// /// Pointer to an array of logical cluster information. Each element in the array corresponds to a character in the array defined by /// pwcChars. The value of each element is the offset from the first glyph in the run to the first glyph in the cluster /// containing the corresponding character. Note that, when the fRTL member of the SCRIPT_ANALYSIS structure is set to /// TRUE, the elements in pwLogClust decrease as the array is read. /// /// Pointer to an array of character property values in the Unicode run. /// Number of characters in the Unicode run. /// Pointer to a glyph buffer obtained from an earlier call to the ScriptShapeOpenType function. /// /// Pointer to an array of attributes for each of the glyphs to retrieve. The number of values equals the value of cGlyphs. /// Since there is one glyph property per glyph, this parameter has the number of elements indicated by cGlyphs. /// /// Count of glyphs in a glyph array buffer. /// /// Pointer to an array, of length indicated by cGlyphs, in which this function retrieves advance width information. /// /// /// Pointer to an array of GOFFSET structures in which this structure retrieves the x and y offsets of combining glyphs. This array /// must be of length indicated by cGlyphs. /// /// Pointer to an ABC structure in which this function retrieves the ABC width for the entire run. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, the output /// values are undefined. The application can test the return value with the SUCCEEDED and FAILED macros. /// /// /// The function returns E_OUTOFMEMORY if the output buffer length indicated by cGlyphs is too small. The application can try /// calling again with larger buffers. /// /// /// The function returns E_PENDING if the script cache specified by the psc parameter does not contain enough information to /// place the glyphs, and the hdc parameter is passed as NULL so that the function is unable to complete the placement /// process. The application should set up a correct device context for the run, and call this function again with the appropriate /// value in hdc and with all other parameters the same. /// /// /// /// /// This function is preferred over the older ScriptPlace function. Some advantages of ScriptPlaceOpenType include the following: /// /// /// /// Parameters directly correspond to OpenType tags in font layout tables. /// /// /// /// Parameters define features applied to each character. Input is divided into ranges, and each range has OpenType properties /// associated with it. /// /// /// /// /// The composite ABC width for the whole item identifies how much the glyphs overhang to the left of the start position and to the /// right of the length implied by the sum of the advance widths. The total advance width of the line is exactly abcA+abcB+abcC. The /// abcA and abcC values are maintained as proportions of the cell height represented in 8 bits and are thus roughly +/-1 percent. /// The total width retrieved, which is the sum of the abcA+abcB+abcC values indicated by piAdvance, is accurate to the /// resolution of the TrueType shaping engine. /// /// /// All arrays are in visual order unless the fLogicalOrder member is set in the SCRIPT_ANALYSIS structure indicated by the /// psa parameter. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptplaceopentype HRESULT ScriptPlaceOpenType( [in, optional] // HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, out] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] OPENTYPE_TAG tagLangSys, // [in, optional] int *rcRangeChars, [in, optional] TEXTRANGE_PROPERTIES **rpRangeProperties, [in] int cRanges, [in] const WCHAR // *pwcChars, [in] WORD *pwLogClust, [in] SCRIPT_CHARPROP *pCharProps, [in] int cChars, [in] const WORD *pwGlyphs, [in] const // SCRIPT_GLYPHPROP *pGlyphProps, [in] int cGlyphs, [out] int *piAdvance, [out] GOFFSET *pGoffset, [out, optional] ABC *pABC ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPlaceOpenType")] public static extern HRESULT ScriptPlaceOpenType([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, ref SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] int[] rcRangeChars, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] IntPtr[] rpRangeProperties, int cRanges, [MarshalAs(UnmanagedType.LPWStr)] string pwcChars, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 11)] ushort[] pwLogClust, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 11)] SCRIPT_CHARPROP[] pCharProps, int cChars, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] ushort[] pwGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] SCRIPT_GLYPHPROP[] pGlyphProps, int cGlyphs, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] int[] piAdvance, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 14)] GOFFSET[] pGoffset, out ABC pABC); /// /// Positions a single glyph with a single adjustment using a specified feature provided in the font for OpenType processing. Most /// often, applications use this function to align a glyph optically at the beginning or end of a line. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This structure identifies the /// shaping engine, so that the advance widths can be retrieved. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag for shaping. /// An OPENTYPE_TAG structure defining the language tag for shaping. /// An OPENTYPE_TAG structure defining the feature tag to use for shaping the alternate glyph. /// /// A flag specifying if single substitution should be applied to the identifier specified in wGlyphId. The application sets /// this parameter to 1 to apply the single substitution feature to the identifier. The application sets the parameter to 0 if the /// function should not apply the feature. /// /// The identifier of the original glyph being shaped. /// The original glyph advance width. /// The original glyph offset. Typically, this value is an output of ScriptPlaceOpenType or ScriptPlace. /// /// Pointer to the location in which this function retrieves the new advance width adjusted for the alternate glyph. /// /// /// Pointer to the location in which this function retrieves the new glyph offset adjusted for the alternate glyph. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// This function positions an individual glyph by adjusting the advance width and/or the offset of the given glyph. The function /// assumes that the font requires only one adjustment. /// /// /// A typical use of this function is the slight adjustment of the margin to account for the visual impression made by certain /// characters. In Latin script, for example, at the beginning of a line it is common to make a slight adjustment to the left for an /// initial capital (such as "T" or "O") that does not have a vertical line on the left part of the glyph. Although doing this breaks /// the strict linear margin, the eye perceives the margin as more even. /// /// /// The following examples demonstrate this effect. The first example shows strict alignment; the next two examples show an /// adjustment of the initial "T" to the left. The adjustments are by one pixel and two pixels, respectively. The magnified images to /// the right show how the "T" pushes slightly farther into the left margin in each successive case. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptpositionsingleglyph HRESULT ScriptPositionSingleGlyph( // [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] // OPENTYPE_TAG tagLangSys, [in] OPENTYPE_TAG tagFeature, [in] LONG lParameter, [in] WORD wGlyphId, [in] int iAdvance, [in] GOFFSET // GOffset, [out] int *piOutAdvance, [out] GOFFSET *pOutGoffset ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPositionSingleGlyph")] public static extern HRESULT ScriptPositionSingleGlyph([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, OPENTYPE_TAG tagFeature, int lParameter, ushort wGlyphId, int iAdvance, GOFFSET GOffset, out int piOutAdvance, out GOFFSET pOutGoffset); /// /// Positions a single glyph with a single adjustment using a specified feature provided in the font for OpenType processing. Most /// often, applications use this function to align a glyph optically at the beginning or end of a line. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This structure identifies the /// shaping engine, so that the advance widths can be retrieved. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag for shaping. /// An OPENTYPE_TAG structure defining the language tag for shaping. /// An OPENTYPE_TAG structure defining the feature tag to use for shaping the alternate glyph. /// /// A flag specifying if single substitution should be applied to the identifier specified in wGlyphId. The application sets /// this parameter to 1 to apply the single substitution feature to the identifier. The application sets the parameter to 0 if the /// function should not apply the feature. /// /// The identifier of the original glyph being shaped. /// The original glyph advance width. /// The original glyph offset. Typically, this value is an output of ScriptPlaceOpenType or ScriptPlace. /// /// Pointer to the location in which this function retrieves the new advance width adjusted for the alternate glyph. /// /// /// Pointer to the location in which this function retrieves the new glyph offset adjusted for the alternate glyph. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// This function positions an individual glyph by adjusting the advance width and/or the offset of the given glyph. The function /// assumes that the font requires only one adjustment. /// /// /// A typical use of this function is the slight adjustment of the margin to account for the visual impression made by certain /// characters. In Latin script, for example, at the beginning of a line it is common to make a slight adjustment to the left for an /// initial capital (such as "T" or "O") that does not have a vertical line on the left part of the glyph. Although doing this breaks /// the strict linear margin, the eye perceives the margin as more even. /// /// /// The following examples demonstrate this effect. The first example shows strict alignment; the next two examples show an /// adjustment of the initial "T" to the left. The adjustments are by one pixel and two pixels, respectively. The magnified images to /// the right show how the "T" pushes slightly farther into the left margin in each successive case. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptpositionsingleglyph HRESULT ScriptPositionSingleGlyph( // [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] // OPENTYPE_TAG tagLangSys, [in] OPENTYPE_TAG tagFeature, [in] LONG lParameter, [in] WORD wGlyphId, [in] int iAdvance, [in] GOFFSET // GOffset, [out] int *piOutAdvance, [out] GOFFSET *pOutGoffset ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptPositionSingleGlyph")] public static extern HRESULT ScriptPositionSingleGlyph([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [In, Optional] IntPtr psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, OPENTYPE_TAG tagFeature, int lParameter, ushort wGlyphId, int iAdvance, GOFFSET GOffset, out int piOutAdvance, out GOFFSET pOutGoffset); /// /// Reads the National Language Support (NLS) native digit and digit substitution settings and records them in a /// SCRIPT_DIGITSUBSTITUTE structure. For more information, see Digit Shapes. /// /// /// Locale identifier of the locale to query. Typically, the application should set this parameter to LOCALE_USER_DEFAULT. /// Alternatively, the setting can indicate a specific locale combined with LOCALE_NOUSEROVERRIDE to obtain the default settings. /// /// Pointer to a SCRIPT_DIGITSUBSTITUTE structure. This structure can be passed later to ScriptApplyDigitSubstitution. /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. /// Error returns include: /// /// /// E_INVALIDARG. The Locale parameter indicates a locale that is invalid or not installed. /// /// /// E_POINTER. The psds parameter is set to NULL. /// /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// This function supports context digit substitution only for Arabic and Persian locales. For other locales, context digit /// substitution is mapped to no substitution. /// /// The following example shows the typical way to call this function. /// /// SCRIPT_DIGITSUBSTITUTE sds; ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds); /// /// At every itemization, the application can use the results as shown in the next example. /// /// SCRIPT_CONTROL sc = {0}; SCRIPT_STATE ss = {0}; ScriptApplyDigitSubstitution(&sds, &sc, &ss); /// /// /// For performance reasons, your application should not call ScriptRecordDigitSubstitution frequently. The function requires /// considerable overhead to call it every time ScriptItemize or ScriptStringAnalyse is called. Instead, the application can save the /// SCRIPT_DIGITSUBSTITUTE structure and update it only when a WM_SETTINGCHANGE message is received. Alternatively, the application /// can update the structure when a RegNotifyChangeKeyValue call in a dedicated thread indicates a change in the registry under /// HKCU\Control Panel\International. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptrecorddigitsubstitution HRESULT // ScriptRecordDigitSubstitution( [in] LCID Locale, [out] SCRIPT_DIGITSUBSTITUTE *psds ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptRecordDigitSubstitution")] public static extern HRESULT ScriptRecordDigitSubstitution(LCID Locale, out SCRIPT_DIGITSUBSTITUTE psds); /// Generates glyphs and visual attributes for a Unicode run. /// Optional. Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Pointer to an array of Unicode characters defining the run. /// Number of characters in the Unicode run. /// /// Maximum number of glyphs to generate, and the length of pwOutGlyphs. A reasonable value is /// (1.5 * cChars + 16) /// , but this value might be insufficient in some circumstances. For more information, see the Remarks section. /// /// Pointer to the SCRIPT_ANALYSIS structure for the run, containing the results from an earlier call to ScriptItemize. /// /// Pointer to a buffer in which this function retrieves an array of glyphs with size as indicated by cMaxGlyphs. /// /// /// Pointer to a buffer in which this function retrieves an array of logical cluster information. Each array element corresponds to a /// character in the array of Unicode characters; therefore this array has the number of elements indicated by cChars. The value of /// each element is the offset from the first glyph in the run to the first glyph in the cluster containing the corresponding /// character. Note that, when the fRTL member is set to TRUE in the SCRIPT_ANALYSIS structure, the elements decrease /// as the array is read. /// /// /// Pointer to a buffer in which this function retrieves an array of SCRIPT_VISATTR structures containing visual attribute /// information. Since each glyph has only one visual attribute, this array has the number of elements indicated by cMaxGlyphs. /// /// Pointer to the location in which this function retrieves the number of glyphs indicated in pwOutGlyphs. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, the content of /// all output parameters is undefined. /// /// Error returns include: /// /// /// E_OUTOFMEMORY. The output buffer length indicated by cMaxGlyphs is insufficient. /// /// /// /// E_PENDING. The script cache specified by the psc parameter does not contain enough information to shape the string, and /// the device context has been passed as NULL so that the function is unable to complete the shaping process. The application /// should set up a correct device context for the run, and call this function again with the appropriate value in hdc and /// with all other parameters the same. /// /// /// /// /// USP_E_SCRIPT_NOT_IN_FONT. The font corresponding to the device context does not support the script required by the run indicated /// by pwcChars. The application should choose another font, using either ScriptGetCMap or another function to select the font. /// /// /// /// /// /// See Displaying Text with Uniscribe for a discussion of the context in which this function is normally called. /// /// If this function returns E_OUTOFMEMORY, the application might call ScriptShape repeatedly, with successively larger output /// buffers, until a large enough buffer is provided. The number of glyphs generated by a code point varies according to the script /// and the font. For a simple script, a Unicode code point might generate a single glyph. However, a complex script font might /// construct characters from components, and thus generate several times as many glyphs as characters. Also, there are special /// cases, such as invalid character representations, in which extra glyphs are added to represent the invalid sequence. Therefore, a /// reasonable guess for the size of the buffer indicated by pwOutGlyphs is 1.5 times the length of the character buffer, plus /// an additional 16 glyphs for rare cases, for example, invalid sequence representation. /// /// /// This function can set the fNoGlyphIndex member of the SCRIPT_ANALYSIS structure if the font or operating system cannot /// support glyph indexes. /// /// /// The application can call ScriptShape to determine if a font supports the characters in a given string. If the function /// returns S_OK, the application should check the output for missing glyphs. If fLogicalOrder is set to TRUE in the /// SCRIPT_ANALYSIS structure, the function always generates glyphs in the same order as the original Unicode characters. If /// fLogicalOrder is set to FALSE, the function generates right-to-left items in reverse order so that ScriptTextOut /// does not have to reverse them before calling ExtTextOut. /// /// /// If the eScript member of SCRIPT_ANALYSIS is set to SCRIPT_UNDEFINED, shaping is disabled. In this case, ScriptShape /// displays the glyph that is in the font cmap table. If no glyph is in the table, the function indicates that glyphs are missing. /// /// /// ScriptShape sequences clusters uniformly within the run, and sequences glyphs uniformly within a cluster. It uses the /// value of the fRTL member of SCRIPT_ANALYSIS, from ScriptItemize, to identify sequencing as left-to-right or right-to-left. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// Examples /// /// The following example shows how ScriptShape generates a logical cluster array ( pwLogClust) from a character array /// ( pwcChars) and a glyph array ( pwOutGlyphs). The run has four clusters. /// /// /// /// First cluster: one character represented by one glyph /// /// /// Second cluster: one character represented by three glyphs /// /// /// Third cluster: three characters represented by one glyph /// /// /// Fourth cluster: two characters represented by three glyphs /// /// /// Character array, where c<n>u<m> means cluster n, Unicode code point m: /// /// /// | c1u1 | c2u1 | c3u1 c3u2 c3u3 | c4u1 c4u2 | /// /// /// Glyph array, where c<n>g<m> means cluster n, glyph m: /// /// /// | c1g1 | c2g1 c2g2 c2g3 | c3g1 | c4g1 c4g2 c4g3 | /// /// /// Cluster array, that is, the offset (in glyphs) to the cluster containing the character: /// /// /// | 0 | 1 | 4 4 4 | 5 5 | /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptshape HRESULT ScriptShape( [in] HDC hdc, [in, out] // SCRIPT_CACHE *psc, [in] const WCHAR *pwcChars, [in] int cChars, [in] int cMaxGlyphs, [in, out] SCRIPT_ANALYSIS *psa, [out] WORD // *pwOutGlyphs, [out] WORD *pwLogClust, [out] SCRIPT_VISATTR *psva, [out] int *pcGlyphs ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptShape")] public static extern HRESULT ScriptShape([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, [MarshalAs(UnmanagedType.LPWStr)] string pwcChars, int cChars, int cMaxGlyphs, ref SCRIPT_ANALYSIS psa, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] ushort[] pwOutGlyphs, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ushort[] pwLogClust, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SCRIPT_VISATTR[] psva, out int pcGlyphs); /// /// Generates glyphs and visual attributes for a Unicode run with OpenType information. Each run consists of one call to this function. /// /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. The structure identifies the /// shaping engine, so that glyphs can be formed correctly. /// /// Alternatively, the application can set this parameter to NULL to receive unfiltered results. /// /// An OPENTYPE_TAG structure defining the OpenType script tag for the writing system. /// An OPENTYPE_TAG structure containing the OpenType language tag for the writing system. /// /// Array of characters in each range. The number of array elements is indicated by cRanges. The values of the elements of /// this array add up to the value of cChars. /// /// /// Array of TEXTRANGE_PROPERTIES structures, each representing one OpenType feature range. The number of structures is indicated by /// the cRanges parameter. For more information on rpRangeProperties, see the Remarks section. /// /// The number of OpenType feature ranges. /// Pointer to an array of Unicode characters containing the run. /// Number of characters in the Unicode run. /// Maximum number of glyphs to generate. /// /// Pointer to a buffer in which this function retrieves an array of logical cluster information. Each array element corresponds to a /// character in the array of Unicode characters. The value of each element is the offset from the first glyph in the run to the /// first glyph in the cluster containing the corresponding character. Note that, when the fRTL member of the SCRIPT_ANALYSIS /// structure is TRUE, the elements decrease as the array is read. /// /// /// Pointer to a buffer in which this function retrieves an array of character property values, of length indicated by cChars. /// /// Pointer to a buffer in which this function retrieves an array of glyphs. /// /// Pointer to a buffer in which this function retrieves an array of attributes for each of the retrieved glyphs. The length of the /// values equals the value of pcGlyphs. Since one glyph property is indicated per glyph, the value of this parameter /// indicates the number of elements specified by cMaxGlyphs. /// /// Pointer to the location in which this function retrieves the number of glyphs indicated in pwOutGlyphs. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. In all error cases, the content of /// all output array values is undefined. /// /// Error returns include: /// /// /// E_OUTOFMEMORY. The output buffer length indicated by cMaxGlyphs is insufficient. /// /// /// /// E_PENDING. The script cache specified by the psc parameter does not contain enough information to shape the string, and /// the device context has been passed as NULL so that the function is unable to complete the shaping process. The application /// should set up a correct device context for the run and call this function again with the appropriate context value in hdc /// and with all other parameters the same. /// /// /// /// /// USP_E_SCRIPT_NOT_IN_FONT. The font corresponding to the device context does not support the required script. The application /// should choose another font, using either ScriptGetCMap or another method to select the font. /// /// /// /// /// /// /// ScriptShapeOpenType is preferred over the older ScriptShape function. Some advantages of the ScriptShapeOpenType /// include the following: /// /// /// /// Parameters directly correspond to OpenType tags in font layout tables. /// /// /// Parameters define features applied to each character. /// /// /// Input is divided into runs. Each run has OpenType properties and consists of a single call to ScriptShapeOpenType. /// /// /// /// If this function returns E_OUTOFMEMORY, the application might call ScriptShapeOpenType repeatedly, with successively /// larger output buffers, until a large enough buffer is provided. The number of glyphs generated by a code point varies according /// to the script and the font. For a simple script, a Unicode code point might generate a single glyph. However, a complex script /// font might construct characters from components, and thus generate several times as many glyphs as characters. Also, there are /// special cases, such as invalid character representations, in which extra glyphs are added to represent the invalid sequence. /// Therefore, a reasonable guess for the size of the buffer indicated by pwOutGlyphs is 1.5 times the length of the character /// buffer, plus an additional 16 glyphs for rare cases, for example, invalid sequence representation. /// /// /// This function can set the fNoGlyphIndex member of the SCRIPT_ANALYSIS structure if the font or operating system cannot /// support glyph indexes. /// /// /// The application can call ScriptShapeOpenType to determine if a font supports the characters in a given string. If the /// function returns S_OK, the application should check the output for missing glyphs. If fLogicalOrder is set to TRUE /// in the SCRIPT_ANALYSIS structure, the function always generates glyphs in the same order as the original Unicode characters. If /// fLogicalOrder is set to FALSE, the function generates right-to-left items in reverse order so that ScriptTextOut /// does not have to reverse them before calling ExtTextOut. /// /// /// If the eScript member of SCRIPT_ANALYSIS is set to SCRIPT_UNDEFINED, shaping is disabled. In this case, /// ScriptShapeOpenType displays the glyph that is in the font cmap table. If no glyph is in the table, the function indicates /// that glyphs are missing. /// /// /// ScriptShapeOpenType sequences clusters uniformly within the run, and sequences glyphs uniformly within a cluster. It uses /// the value of the fRTL member of SCRIPT_ANALYSIS, from ScriptItemizeOpenType, to identify if sequencing is left-to-right or right-to-left. /// /// /// For the rpRangeProperties parameter, the TEXTRANGE_PROPERTIES structure points to an array of OPENTYPE_FEATURE_RECORD /// structures. This array is used as follows: /// /// /// /// Each element of the array indicated for rpRangeProperties describes a range. /// /// /// /// Spans of text sharing particular properties tend to "nest," and nested spans can share OPENTYPE_FEATURE_RECORD information. For /// example, in the illustration below: /// /// /// /// Note The illustration makes use of many calls to ScriptShapeOpenType, each representing one run. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// Examples /// /// The following example shows how ScriptShapeOpenType generates a logical cluster array ( pwLogClust) from a /// character array ( pwcChars) and a glyph array ( pwOutGlyphs). The run has four clusters. /// /// /// /// First cluster: one character represented by one glyph /// /// /// Second cluster: one character represented by three glyphs /// /// /// Third cluster: three characters represented by one glyph /// /// /// Fourth cluster: two characters represented by three glyphs /// /// /// The run is described as follows in the character and glyph arrays. /// Character array: /// /// /// | c1u1 | c2u1 | c3u1 c3u2 c3u3 | c4u1 c4u2 | /// /// /// Glyph array: /// /// /// | c1g1 | c2g1 c2g2 c2g3 | c3g1 | c4g1 c4g2 c4g3 | /// /// /// Notation for the array elements consists of these items: /// /// /// c<n> means cluster n. /// /// /// g<m> means glyph m. /// /// /// u<p> means Unicode code point p. /// /// /// The generated cluster array stores offsets to the cluster containing the character. Units are expressed in glyphs. /// /// /// | 0 | 1 | 4 4 4 | 5 5 | /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptshapeopentype HRESULT ScriptShapeOpenType( [in, optional] // HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, out] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] OPENTYPE_TAG tagLangSys, // [in, optional] int *rcRangeChars, [in, optional] TEXTRANGE_PROPERTIES **rpRangeProperties, [in] int cRanges, [in] const WCHAR // *pwcChars, [in] int cChars, [in] int cMaxGlyphs, [out] WORD *pwLogClust, [out] SCRIPT_CHARPROP *pCharProps, [out] WORD // *pwOutGlyphs, [out] SCRIPT_GLYPHPROP *pOutGlyphProps, [out] int *pcGlyphs ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptShapeOpenType")] public static extern HRESULT ScriptShapeOpenType([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, ref SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] int[] rcRangeChars, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] IntPtr[] rpRangeProperties, int cRanges, [MarshalAs(UnmanagedType.LPWStr)] string pwcChars, int cChars, int cMaxGlyphs, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 9)] ushort[] pwLogClust, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 9)] SCRIPT_CHARPROP[] pCharProps, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 10)] ushort[] pwOutGlyphs, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 10)] SCRIPT_GLYPHPROP[] pOutGlyphProps, out int pcGlyphs); /// Returns a pointer to the length of a string after clipping. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// /// Returns a pointer to the length of the string after clipping if successful. The length is the number of Unicode code points. The /// function returns NULL if it does not succeed. /// /// /// To use this function, the application needs to specify SSA_CLIP in its original call to ScriptStringAnalyse. /// /// The pointer returned by this function is valid only until the application passes the associated SCRIPT_STRING_ANALYSIS structure /// to ScriptStringFree. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstring_pcoutchars const int * ScriptString_pcOutChars( // [in] SCRIPT_STRING_ANALYSIS ssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptString_pcOutChars")] public static extern unsafe int* ScriptString_pcOutChars([In] SafeSCRIPT_STRING_ANALYSIS ssa); /// Returns a pointer to a logical attributes buffer for an analyzed string. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// /// Returns a pointer to a buffer containing SCRIPT_LOGATTR structures defining logical attributes if successful. The function /// returns NULL if it does not succeed. /// /// /// /// The pointer returned by this function is valid only until the application passes the associated SCRIPT_STRING_ANALYSIS structure /// to ScriptStringFree. /// /// The logical attribute buffer contains at least the number of integers indicated by the ssa parameter of ScriptString_pcOutChars. /// /// When scanning the SCRIPT_LOGATTR array for a word break point, the application should look backward for the values of the /// fWordStop and fWhiteSpace members. ScriptStringAnalyse just calls ScriptBreak on each run, and ScriptBreak /// never sets fWordBreak on the first character of a run, because it has no information that the previous run ended in white space. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstring_plogattr const SCRIPT_LOGATTR * // ScriptString_pLogAttr( [in] SCRIPT_STRING_ANALYSIS ssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptString_pLogAttr")] public static extern unsafe SCRIPT_LOGATTR* ScriptString_pLogAttr([In] SafeSCRIPT_STRING_ANALYSIS ssa); /// Returns a pointer to a SIZE structure for an analyzed string. /// A SCRIPT_STRING_ANALYSIS structure for a string. /// /// Returns a pointer to a SIZE structure containing the size (width and height) of the analyzed string if successful. The function /// returns NULL if it does not succeed. /// /// /// /// The size returned by this function is the size before the effect of the justification requested by setting the SSA_FIT flag in /// ScriptStringAnalyse. The difference between the value of iReqWidth in ScriptStringAnalyse and the size returned by /// ScriptString_pSize is the effect of justification. /// /// /// The pointer returned by this function is valid only until the application passes the associated SCRIPT_STRING_ANALYSIS structure /// to ScriptStringFree. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstring_psize const SIZE * ScriptString_pSize( [in] // SCRIPT_STRING_ANALYSIS ssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptString_pSize")] public static extern unsafe SIZE* ScriptString_pSize([In] SafeSCRIPT_STRING_ANALYSIS ssa); /// Analyzes a plain text string. /// /// Handle to the device context. If dwFlags is set to SSA_GLYPHS, the device context handle is required. If dwFlags is /// set to SSA_BREAK, the device context handle is optional. If the device context handle is provided, the function inspects the /// current font in the device context. If the current font is a symbolic font, the function treats the character string as a single /// neutral SCRIPT_UNDEFINED item. /// /// /// Pointer to the string to analyze. The string must have at least one character. It can be a Unicode string or use the character /// set from a Windows ANSI code page, as specified by the iCharset parameter. /// /// /// Length of the string to analyze. The length is measured in characters for an ANSI string or in wide characters for a Unicode /// string. The length must be at least 1. /// /// /// Flags indicating the analysis that is required. This parameter can have one of the values listed in the following table. /// /// /// Value /// Meaning /// /// /// SSA_BREAK /// Retrieve break flags, that is, character and word stops. /// /// /// SSA_CLIP /// Clip the string at iReqWidth. /// /// /// SSA_DZWG /// Provide representation glyphs for control characters. /// /// /// SSA_FALLBACK /// Use fallback fonts. /// /// /// SSA_FIT /// Justify the string to iReqWidth. /// /// /// SSA_GCP /// Retrieve missing glyphs and pwLogClust with GetCharacterPlacement conventions. /// /// /// SSA_GLYPHS /// Generate glyphs, positions, and attributes. /// /// /// SSA_HIDEHOTKEY /// Remove the first "&" from displayed string. /// /// /// SSA_HOTKEY /// Replace "&" with underline on subsequent code point. /// /// /// SSA_HOTKEYONLY /// /// Display underline only. The resulting bit pattern might be displayed, using an XOR mask, to toggle the visibility of the hotkey /// underline without disturbing the text. /// /// /// /// SSA_LINK /// Apply East Asian font linking and association to noncomplex text. /// /// /// SSA_METAFILE /// Write items with ExtTextOutW calls, not with glyphs. /// /// /// SSA_PASSWORD /// Duplicate input string containing a single character cString times. /// /// /// SSA_RTL /// Use base embedding level 1. /// /// /// SSA_TAB /// Expand tabs. /// /// /// /// Width required for fitting or clipping. /// /// Pointer to a SCRIPT_CONTROL structure. The application can set this parameter to NULL to indicate that all /// SCRIPT_CONTROL members are set to 0. /// /// /// Pointer to a SCRIPT_STATE structure. The application can set this parameter to NULL to indicate that all /// SCRIPT_STATE members are set to 0. The uBidiLevel member of SCRIPT_STATE is ignored. The value used is /// derived from the SSA_RTL flag in combination with the layout of the device context. /// /// Pointer to the requested logical dx array. /// Pointer to a SCRIPT_TABDEF structure. This value is only required if dwFlags is set to SSA_TAB. /// Pointer to a BYTE value that indicates GetCharacterPlacement character classifications. /// A SCRIPT_STRING_ANALYSIS structure. This structure is dynamically allocated on successful return from the function. /// /// /// Use of this function is the first step in handling plain text strings. Such a string has only one font, one style, one size, one /// color, and so forth. ScriptStringAnalyse allocates temporary buffers for item analyses, glyphs, advance widths, and the /// like. Then it automatically runs ScriptItemize, ScriptShape, ScriptPlace, and ScriptBreak. The results are available through all /// the other ScriptString* functions. /// /// /// On successful return from this function a dynamically allocated structure that the application can pass successively to the other /// ScriptString* functions. The application must ultimately free the structure by calling ScriptStringFree. /// /// /// Although the functionality of ScriptStringAnalyse can be implemented by direct calls to other functions, use of the /// function itself drastically reduces the amount of code required in the application for plain text handling. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringanalyse HRESULT ScriptStringAnalyse( [in] HDC hdc, // [in] const void *pString, [in] int cString, [in] int cGlyphs, [in] int iCharset, [in] DWORD dwFlags, [in] int iReqWidth, [in, // optional] SCRIPT_CONTROL *psControl, [in, optional] SCRIPT_STATE *psState, [in, optional] const int *piDx, [in, optional] // SCRIPT_TABDEF *pTabdef, [in] const BYTE *pbInClass, [out] SCRIPT_STRING_ANALYSIS *pssa ); [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringAnalyse")] public static SafeSCRIPT_STRING_ANALYSIS ScriptStringAnalyse([In, Optional] HDC hdc, string pString, SSA dwFlags, int cString = -1, int iReqWidth = 0, SCRIPT_CONTROL? psControl = null, SCRIPT_STATE? psState = null, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piDx = null, SCRIPT_TABDEF? pTabdef = null, IntPtr pbInClass = default) { unsafe { if (cString == -1) cString = pString.Length; var cGlyphs = MulAdd(cString, 1.5m, 16); using var psc = InteropServices.PinnedObject.FromNullable(psControl); using var pss = InteropServices.PinnedObject.FromNullable(psState); using var ptd = InteropServices.PinnedObject.FromNullable(pTabdef); fixed (char* ps = pString) { ScriptStringAnalyse(hdc, ps, cString, cGlyphs, -1, dwFlags, iReqWidth, (SCRIPT_CONTROL*)(void*)psc, (SCRIPT_STATE*)(void*)pss, piDx, (SCRIPT_TABDEF*)(void*)ptd, (byte*)pbInClass, out var pssa).ThrowIfFailed(); return pssa; } } } /// Analyzes a plain text string. /// /// Handle to the device context. If dwFlags is set to SSA_GLYPHS, the device context handle is required. If dwFlags is /// set to SSA_BREAK, the device context handle is optional. If the device context handle is provided, the function inspects the /// current font in the device context. If the current font is a symbolic font, the function treats the character string as a single /// neutral SCRIPT_UNDEFINED item. /// /// /// Pointer to the string to analyze. The string must have at least one character. It can be a Unicode string or use the character /// set from a Windows ANSI code page, as specified by the iCharset parameter. /// /// /// Length of the string to analyze. The length is measured in characters for an ANSI string or in wide characters for a Unicode /// string. The length must be at least 1. /// /// /// Size of the glyph buffer, in WORD values. This size is required. The recommended size is (1.5 * cString + 16). /// /// /// /// Character set descriptor. If the input string is an ANSI string, this descriptor is set to the character set identifier. If the /// string is a Unicode string, this descriptor is set to -1. /// /// The following character set identifiers are defined: /// /// /// Flags indicating the analysis that is required. This parameter can have one of the values listed in the following table. /// /// /// Value /// Meaning /// /// /// SSA_BREAK /// Retrieve break flags, that is, character and word stops. /// /// /// SSA_CLIP /// Clip the string at iReqWidth. /// /// /// SSA_DZWG /// Provide representation glyphs for control characters. /// /// /// SSA_FALLBACK /// Use fallback fonts. /// /// /// SSA_FIT /// Justify the string to iReqWidth. /// /// /// SSA_GCP /// Retrieve missing glyphs and pwLogClust with GetCharacterPlacement conventions. /// /// /// SSA_GLYPHS /// Generate glyphs, positions, and attributes. /// /// /// SSA_HIDEHOTKEY /// Remove the first "&" from displayed string. /// /// /// SSA_HOTKEY /// Replace "&" with underline on subsequent code point. /// /// /// SSA_HOTKEYONLY /// /// Display underline only. The resulting bit pattern might be displayed, using an XOR mask, to toggle the visibility of the hotkey /// underline without disturbing the text. /// /// /// /// SSA_LINK /// Apply East Asian font linking and association to noncomplex text. /// /// /// SSA_METAFILE /// Write items with ExtTextOutW calls, not with glyphs. /// /// /// SSA_PASSWORD /// Duplicate input string containing a single character cString times. /// /// /// SSA_RTL /// Use base embedding level 1. /// /// /// SSA_TAB /// Expand tabs. /// /// /// /// Width required for fitting or clipping. /// /// Pointer to a SCRIPT_CONTROL structure. The application can set this parameter to NULL to indicate that all /// SCRIPT_CONTROL members are set to 0. /// /// /// Pointer to a SCRIPT_STATE structure. The application can set this parameter to NULL to indicate that all /// SCRIPT_STATE members are set to 0. The uBidiLevel member of SCRIPT_STATE is ignored. The value used is /// derived from the SSA_RTL flag in combination with the layout of the device context. /// /// Pointer to the requested logical dx array. /// Pointer to a SCRIPT_TABDEF structure. This value is only required if dwFlags is set to SSA_TAB. /// Pointer to a BYTE value that indicates GetCharacterPlacement character classifications. /// /// Pointer to a buffer in which this function retrieves a SCRIPT_STRING_ANALYSIS structure. This structure is dynamically allocated /// on successful return from the function. /// /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. /// Error returns include: /// /// /// E_INVALIDARG. An invalid parameter is found. /// /// /// USP_E_SCRIPT_NOT_IN_FONT. SSA_FALLBACK has not been specified, or a standard fallback font is missing. /// /// /// /// The function can also return a system error converted to an HRESULT type. An example is an error returned due to lack of memory /// or a GDI call using the device context. /// /// /// /// /// Use of this function is the first step in handling plain text strings. Such a string has only one font, one style, one size, one /// color, and so forth. ScriptStringAnalyse allocates temporary buffers for item analyses, glyphs, advance widths, and the /// like. Then it automatically runs ScriptItemize, ScriptShape, ScriptPlace, and ScriptBreak. The results are available through all /// the other ScriptString* functions. /// /// /// On successful return from this function, pssa indicates a dynamically allocated structure that the application can pass /// successively to the other ScriptString* functions. The application must ultimately free the structure by calling ScriptStringFree. /// /// /// Although the functionality of ScriptStringAnalyse can be implemented by direct calls to other functions, use of the /// function itself drastically reduces the amount of code required in the application for plain text handling. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringanalyse HRESULT ScriptStringAnalyse( [in] HDC hdc, // [in] const void *pString, [in] int cString, [in] int cGlyphs, [in] int iCharset, [in] DWORD dwFlags, [in] int iReqWidth, [in, // optional] SCRIPT_CONTROL *psControl, [in, optional] SCRIPT_STATE *psState, [in, optional] const int *piDx, [in, optional] // SCRIPT_TABDEF *pTabdef, [in] const BYTE *pbInClass, [out] SCRIPT_STRING_ANALYSIS *pssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringAnalyse")] public static extern unsafe HRESULT ScriptStringAnalyse([In] HDC hdc, [In] void* pString, int cString, int cGlyphs, int iCharset, SSA dwFlags, int iReqWidth, [In, Optional] SCRIPT_CONTROL* psControl, [In, Optional] SCRIPT_STATE* psState, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piDx, [In, Optional] SCRIPT_TABDEF* pTabdef, [In, Optional] byte* pbInClass, out SafeSCRIPT_STRING_ANALYSIS pssa); /// Retrieves the x coordinate for the leading or trailing edge of a character position. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// Character position in the string. /// /// TRUE to indicate the trailing edge of the character position ( icp) that corresponds to the x coordinate. This /// parameter is set to FALSE to indicate the leading edge of the character position. /// /// Pointer to a buffer in which this function retrieves the x coordinate corresponding to the character position. /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringcptox HRESULT ScriptStringCPtoX( [in] // SCRIPT_STRING_ANALYSIS ssa, [in] int icp, [in] BOOL fTrailing, [out] int *pX ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringCPtoX")] public static extern HRESULT ScriptStringCPtoX([In] SafeSCRIPT_STRING_ANALYSIS ssa, int icp, [MarshalAs(UnmanagedType.Bool)] bool fTrailing, out int pX); /// Frees a SCRIPT_STRING_ANALYSIS structure. /// Pointer to a SCRIPT_STRING_ANALYSIS structure. /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// /// When your application is finished with a SCRIPT_STRING_ANALYSIS structure, it should free the associated memory by calling this /// function. After this function is called, the pointers retrieved from ScriptString_pcOutChars, ScriptString_pLogAttr, and /// ScriptString_pSize that are associated with the pssa parameter are invalid. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringfree HRESULT ScriptStringFree( [in, out] // SCRIPT_STRING_ANALYSIS *pssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringFree")] public static extern HRESULT ScriptStringFree(ref IntPtr pssa); /// Converts visual widths into logical widths. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// /// Pointer to a buffer in which this function retrieves logical widths. The buffer should have room for at least the number of /// integers indicated by the ssa parameter of ScriptString_pcOutChars. /// /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// /// This function converts the visual widths generated by ScriptStringAnalyse into logical widths, one per original character, in /// logical order. /// /// To use this function, the application needs to specify SSA_GLYPHS in its original call to ScriptStringAnalyse. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringgetlogicalwidths HRESULT // ScriptStringGetLogicalWidths( [in] SCRIPT_STRING_ANALYSIS ssa, [out] int *piDx ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringGetLogicalWidths")] public static extern HRESULT ScriptStringGetLogicalWidths([In] SafeSCRIPT_STRING_ANALYSIS ssa, [Out, MarshalAs(UnmanagedType.LPArray)] int[] piDx); /// Creates an array that maps an original character position to a glyph position. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// /// Pointer to a buffer in which this function retrieves an array of glyph positions, indexed by the original character position. The /// array should have room for at least the number of integers indicated by the ssa parameter of ScriptString_pcOutChars. /// /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// /// When the number of glyphs and the number of characters are equal, the function retrieves an array that references every glyph. /// This is the same treatment that occurs in GetCharacterPlacement. /// /// To use this function, the application needs to specify SSA_GLYPHS in its original call to ScriptStringAnalyse. /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringgetorder HRESULT ScriptStringGetOrder( [in] // SCRIPT_STRING_ANALYSIS ssa, [out] UINT *puOrder ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringGetOrder")] public static extern HRESULT ScriptStringGetOrder([In] SafeSCRIPT_STRING_ANALYSIS ssa, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] puOrder); /// Displays a string generated by a prior call to ScriptStringAnalyse and optionally adds highlighting. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// The x-coordinate of the reference point used to position the string. /// The y-coordinate of the reference point used to position the string. /// /// /// Options specifying the use of the application-defined rectangle. This parameter can be set to 0 or to any of the following /// values. The values can be combined with binary OR. /// /// /// /// Value /// Meaning /// /// /// ETO_CLIPPED /// Clip text to the rectangle. /// /// /// ETO_OPAQUE /// Use current background color to fill the rectangle. /// /// /// /// /// Pointer to a RECT structure that defines the rectangle to use. If uOptions is set to ETO_OPAQUE and NULL is /// provided for prc, the function succeeds and returns S_OK. However, if the application sets uOptions to ETO_CLIPPING /// and provides NULL for prc, the function returns E_INVALIDARG. The application can set this parameter to NULL /// to indicate that no option is needed. /// /// /// Zero-based index specifying the starting position in the string. For no selection, the application should set iMinSel /// >= iMaxSel. /// /// Zero-based index specifying the ending position in the string. /// /// TRUE if the operating system applies disabled-text highlighting by setting the background color to COLOR_HIGHLIGHT behind /// all selected characters. The application can set this parameter to FALSE if the operating system applies enabled-text /// highlighting by setting the background color to COLOR_HIGHLIGHT and the text color to COLOR_HIGHLIGHTTEXT for each selected character. /// /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can't /// test the return value with the SUCCEEDED and FAILED macros. /// /// /// To use this function, the application needs to specify SSA_GLYPHS in its original call to ScriptStringAnalyse. /// /// The application should not use SetTextAlign with TA_UPDATECP when using ScriptStringOut because selected text cannot be /// rendered correctly. If the application must use this flag, it can unset and reset the flag as necessary to avoid the problem. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringout HRESULT ScriptStringOut( [in] // SCRIPT_STRING_ANALYSIS ssa, [in] int iX, [in] int iY, [in] UINT uOptions, [in, optional] const RECT *prc, [in] int iMinSel, [in] // int iMaxSel, [in] BOOL fDisabled ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringOut")] public static extern HRESULT ScriptStringOut([In] SafeSCRIPT_STRING_ANALYSIS ssa, int iX, int iY, ETO uOptions, [In, Optional] PRECT prc, int iMinSel, int iMaxSel, [MarshalAs(UnmanagedType.Bool)] bool fDisabled); /// Checks a SCRIPT_STRING_ANALYSIS structure for invalid sequences. /// A SCRIPT_STRING_ANALYSIS structure for a string. /// /// Returns S_OK if no invalid sequences are found. The function returns S_FALSE if one or more invalid sequences are found. The /// function returns a nonzero HRESULT value if it does not succeed. /// /// /// This function is intended for use in editors that reject the input of invalid sequences. /// /// Invalid sequences are only checked for scripts with the fRejectInvalid member set in the associated SCRIPT_PROPERTIES /// structure. For example, it is conventional for Notepad to reject invalid Thai character sequences. However, invalid Indian /// sequences are not conventionally rejected, but instead are displayed in composition with a missing base character symbol. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringvalidate HRESULT ScriptStringValidate( [in] // SCRIPT_STRING_ANALYSIS ssa ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringValidate")] public static extern HRESULT ScriptStringValidate([In] SafeSCRIPT_STRING_ANALYSIS ssa); /// Converts an x coordinate to a character position. /// A SCRIPT_STRING_ANALYSIS structure for the string. /// The x coordinate. /// Pointer to a variable in which this function retrieves the character position corresponding to the x coordinate. /// /// Pointer to a variable in which this function retrieves a value indicating if the x coordinate is for the leading edge or the /// trailing edge of the character position. For more information, see the Remarks section. /// /// /// Returns S_OK if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the /// return value with the SUCCEEDED and FAILED macros. /// /// /// /// If the x coordinate corresponds to the leading edge of the character, the value of piTrailing is 0. If the x coordinate /// corresponds to the trailing edge of the character, the value of piTrailing is a positive integer. As for ScriptXtoCP, the /// value is 1 for a character that can be rendered on its own. The value is greater than 1 if the character is part of a cluster in /// a script for which cursors are not placed within a cluster, to indicate the offset to the next legitimate logical cursor position. /// /// /// If the x coordinate is before the beginning of the line, the function retrieves -1 for piCh and 1 for piTrailing, /// indicating the trailing edge of the nonexistent character before the line. If the x coordinate is after the end of the line, the /// function retrieves for piCh the first index beyond the length of the line and 0 for piTrailing. The 0 value /// indicates the leading edge of the nonexistent character after the line. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptstringxtocp HRESULT ScriptStringXtoCP( [in] // SCRIPT_STRING_ANALYSIS ssa, [in] int iX, [out] int *piCh, [out] int *piTrailing ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptStringXtoCP")] public static extern HRESULT ScriptStringXtoCP([In] SafeSCRIPT_STRING_ANALYSIS ssa, int iX, out int piCh, out int piTrailing); /// Enables substitution of a single glyph with one alternate form of the same glyph for OpenType processing. /// Handle to the device context. For more information, see Caching. /// Pointer to a SCRIPT_CACHE structure indicating the script cache. /// /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemizeOpenType. This parameter identifies the /// shaping engine so that the correct substitute glyph is used. /// /// Alternatively, the application can set this parameter to NULL to retrieve unfiltered results. /// /// An OPENTYPE_TAG structure defining the script tag for shaping. /// An OPENTYPE_TAG structure defining the language tag for shaping. /// An OPENTYPE_TAG structure defining the feature tag to use for shaping the alternate glyph. /// /// Reference to the alternate glyph to substitute. This reference is an index to an array that contains all the alternate glyphs /// defined in the feature, as illustrated for OPENTYPE_FEATURE_RECORD. The alternate glyph array is one of the items retrieved by ScriptGetFontAlternateGlyphs. /// /// Identifier of the original glyph. /// Pointer to the location in which this function retrieves the identifier of the alternate glyph. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// This function uses one-to-one substitution in which the application can substitute one glyph with one alternate form. Most often, /// applications use this function to set a bullet or an alternate glyph at the beginning or end of a line. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptsubstitutesingleglyph HRESULT ScriptSubstituteSingleGlyph( // [in, optional] HDC hdc, [in, out] SCRIPT_CACHE *psc, [in, optional] SCRIPT_ANALYSIS *psa, [in] OPENTYPE_TAG tagScript, [in] // OPENTYPE_TAG tagLangSys, [in] OPENTYPE_TAG tagFeature, [in] LONG lParameter, [in] WORD wGlyphId, [out] WORD *pwOutGlyphId ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptSubstituteSingleGlyph")] public static extern HRESULT ScriptSubstituteSingleGlyph([In, Optional] HDC hdc, SafeSCRIPT_CACHE psc, in SCRIPT_ANALYSIS psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, OPENTYPE_TAG tagFeature, [In, MarshalAs(UnmanagedType.LPArray)] int[] lParameter, ushort wGlyphId, out ushort pwOutGlyphId); /// Displays text for the specified script shape and place information. /// /// Handle to the device context. For more information, see Caching. Note that, unlike some other related Uniscribe functions, this /// function defines the handle as mandatory. /// /// Pointer to a SCRIPT_CACHE structure identifying the script cache. /// Value of the x coordinate of the first glyph. /// Value of the y coordinate of the first glyph. /// /// Options equivalent to the fuOptions parameter of ExtTextOut. This parameter can be set to either ETO_CLIPPED or /// ETO_OPAQUE, to both values, or to neither value. /// /// /// Pointer to a RECT structure containing the rectangle used to clip the display. The application can set this parameter to NULL. /// /// Pointer to a SCRIPT_ANALYSIS structure obtained from a previous call to ScriptItemize. /// Reserved; must be set to NULL. /// Reserved; must be 0. /// Pointer to an array of glyphs obtained from a previous call to ScriptShape. /// Count of the glyphs in the array indicated by pwGlyphs. The maximum number of glyphs is 65,536. /// Pointer to an array of advance widths obtained from a previous call to ScriptPlace. /// /// Pointer to an array of justified advance widths (cell widths). The application can set this parameter to NULL. /// /// Pointer to a GOFFSET structure containing the x and y offsets for the combining glyph. /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// This function calls the operating system ExtTextOut function for text display. For more information, see Displaying Text with Uniscribe. /// /// /// All arrays are in display order unless the fLogicalOrder member is set in the SCRIPT_ANALYSIS structure indicated by psa. /// /// /// For any run that is rendered right-to-left and was generated in logical order by forcing the fLogicalOrder member of /// SCRIPT_ANALYSIS, the application must call SetTextAlign (hdc, TA_RIGHT) and give the right-side coordinate before calling ScriptTextOut. /// /// /// The array indicated by piJustify provides cell widths for each glyph. When the width of a glyph differs from the /// unjustified width, specified by piAdvance, space is added to or removed from the glyph cell at its trailing edge. The /// glyph is always aligned with the leading edge of its cell. This rule applies even in visual order. /// /// /// When a glyph cell is extended, the extra space is usually made up by the addition of white space. However, for Arabic scripts, /// the extra space is made up by one or more kashida glyphs, unless the extra space is insufficient for the shortest kashida glyph /// in the font. The width of the shortest kashida is available by calling ScriptGetFontProperties. /// /// /// The application should pass a value for piJustify only if the string must be justified by ScriptTextOut. Normally, /// the application should pass NULL. /// /// /// The application should not use ScriptTextOut to write to a metafile unless the metafile will be played back without any /// font substitution, for example, immediately on the same system for scalable page preview. ScriptTextOut records glyph /// numbers in the metafile. Since glyph numbers vary considerably from one font to another, the file is unlikely to play back /// correctly when different fonts are substituted. For example, when a metafile is played back at a different scale, a CreateFont /// request recorded in the metafile can resolve to a bitmap instead of a TrueType font. Likewise, if the metafile is played back on /// a different computer, the requested fonts might not be installed. To write complex scripts in a metafile in a font-independent /// manner, the application should use ExtTextOut to write the logical characters directly, so that glyph generation and placement do /// not occur until the text is played back. /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scripttextout HRESULT ScriptTextOut( [in] const HDC hdc, [in, // out] SCRIPT_CACHE *psc, [in] int x, [in] int y, [in] UINT fuOptions, [in, optional] const RECT *lprc, [in] const SCRIPT_ANALYSIS // *psa, [in] const WCHAR *pwcReserved, [in] int iReserved, [in] const WORD *pwGlyphs, [in] int cGlyphs, [in] const int *piAdvance, // [in, optional] const int *piJustify, [in] const GOFFSET *pGoffset ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptTextOut")] public static extern HRESULT ScriptTextOut([In] HDC hdc, SafeSCRIPT_CACHE psc, int x, int y, uint fuOptions, [In, Optional] PRECT lprc, in SCRIPT_ANALYSIS psa, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwcReserved, [Optional] int iReserved, [In, MarshalAs(UnmanagedType.LPArray)] ushort[] pwGlyphs, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray)] int[] piAdvance, [In, Optional, MarshalAs(UnmanagedType.LPArray)] int[] piJustify, in GOFFSET pGoffset); /// Generates the leading or trailing edge of a logical character cluster from the x offset of a run. /// /// Offset, in logical units, from the end of the run specified by the fLogicalOrder member of the SCRIPT_ANALYSIS structure /// indicated by the psa parameter. /// /// Count of logical code points in the run. /// Count of glyphs in the run. /// Pointer to an array of logical clusters. /// Pointer to an array of SCRIPT_VISATTR structures containing the visual attributes for the glyph. /// Pointer to an array of advance widths. /// /// Pointer to a SCRIPT_ANALYSIS structure. The fLogicalOrder member indicates TRUE to use the leading edge of the run, /// or FALSE to use the trailing edge. /// /// Pointer to a buffer in which this function retrieves the character position corresponding to the x coordinate. /// /// Pointer to a buffer in which this function retrieves the distance, in code points, from the leading edge of the logical character /// to the iX position. If this value is 0, the iX position is at the leading edge of the logical character. For more /// information, see the Remarks section. /// /// /// Returns 0 if successful. The function returns a nonzero HRESULT value if it does not succeed. The application can test the return /// value with the SUCCEEDED and FAILED macros. /// /// /// /// The values passed to this function normally are the results of earlier calls to other Uniscribe functions. See Managing Caret /// Placement and Hit Testing for details. /// /// /// The leading and trailing edges of the logical character are determined by the direction of text in the run (left-to-right or /// right-to-left). For the left-to-right direction, the leading edge is the same as the left edge. For the right-to-left direction, /// the leading edge is the right edge. /// /// /// For scripts in which the caret is conventionally placed in the middle of a cluster, for example, Arabic and Hebrew, the retrieved /// character position can be for any code point in the line. In this case, the piTrailing parameter is set to either 0 or 1. /// /// /// For scripts in which the caret is conventionally snapped to the boundaries of a cluster, the retrieved character position is /// always the position of the first code point in a cluster (considered logically). The piTrailing parameter is set to 0 or /// to the number of code points in the cluster. /// /// /// The appropriate caret position for a mouse hit is always the retrieved character position plus the distance indicated by piTrailing. /// /// /// When iX indicates a position outside the run, ScriptXtoCP acts as if there is an extra infinitely large character /// beyond each end of the run. This results in the behavior shown in the following table. /// /// /// /// iX position (outside the run) /// Result /// /// /// Before the run, that is: iX < 0 if run is left-to-right, or iX >= sum of advances if run is right-to-left /// Value of piCP is -1 and value of piTrailing is 0 /// /// /// After the run, that is: iX >= sum of advances if run is left-to-right, or iX < 0 if run is right-to-left /// Value of piCP is value of cChars and value of piTrailing is 1 /// /// /// /// Important Starting with Windows 8: To maintain the ability to run on Windows 7, a module that uses Uniscribe must specify /// Usp10.lib before gdi32.lib in its library list. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptxtocp HRESULT ScriptXtoCP( [in] int iX, [in] int cChars, // [in] int cGlyphs, [in] const WORD *pwLogClust, [in] const SCRIPT_VISATTR *psva, [in] const int *piAdvance, [in] const // SCRIPT_ANALYSIS *psa, [out] int *piCP, [out] int *piTrailing ); [DllImport(Lib_Usp10, SetLastError = false, ExactSpelling = true)] [PInvokeData("usp10.h", MSDNShortId = "NF:usp10.ScriptXtoCP")] public static extern HRESULT ScriptXtoCP(int iX, int cChars, int cGlyphs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ushort[] pwLogClust, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SCRIPT_VISATTR[] psva, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] piAdvance, in SCRIPT_ANALYSIS psa, out int piCP, out int piTrailing); private static int MulAdd(int x, decimal m, int a) => (int)Math.Round(x * m + a); } }