IDWriteTextAnalyzer1

<summary> Analyzes various text properties for complex script processing. </summary>

interface IDWriteTextAnalyzer1 : IDWriteTextAnalyzer {}

Members

Functions

AnalyzeVerticalGlyphOrientation
HRESULT AnalyzeVerticalGlyphOrientation(IDWriteTextAnalysisSource1 analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink1 analysisSink)

<summary> Analyzes a text range for script orientation, reading text and attributes from the source and reporting results to the sink. </summary> <param name="analysisSource">Source object to analyze.</param> <param name="textPosition">Starting position within the source object.</param> <param name="textLength">Length to analyze.</param> <param name="analysisSink">Callback object.</param> <returns> Standard HRESULT error code. </returns> <remarks> All bidi analysis should be resolved before calling this. </remarks>

ApplyCharacterSpacing
HRESULT ApplyCharacterSpacing(FLOAT leadingSpacing, FLOAT trailingSpacing, FLOAT minimumAdvanceWidth, UINT32 textLength, UINT32 glyphCount, const(UINT16)* clusterMap, const(FLOAT)* glyphAdvances, const(DWRITE_GLYPH_OFFSET)* glyphOffsets, const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProperties, FLOAT* modifiedGlyphAdvances, DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets)

<summary> Applies spacing between characters, properly adjusting glyph clusters and diacritics. </summary> <param name="leadingSpacing">The spacing before each character, in reading order.</param> <param name="trailingSpacing">The spacing after each character, in reading order.</param> <param name="minimumAdvanceWidth">The minimum advance of each character, to prevent characters from becoming too thin or zero-width. This must be zero or greater.</param> <param name="textLength">The length of the clustermap and original text.</param> <param name="glyphCount">The number of glyphs.</param> <param name="clusterMap">Mapping from character ranges to glyph ranges.</param> <param name="glyphAdvances">The advance width of each glyph.</param> <param name="glyphOffsets">The offset of the origin of each glyph.</param> <param name="glyphProperties">Properties of each glyph, from GetGlyphs.</param> <param name="modifiedGlyphAdvances">The new advance width of each glyph.</param> <param name="modifiedGlyphOffsets">The new offset of the origin of each glyph.</param> <remarks> The input and output advances/offsets are allowed to alias the same array. </remarks> <returns> Standard HRESULT error code. </returns>

GetBaseline
HRESULT GetBaseline(IDWriteFontFace fontFace, DWRITE_BASELINE baseline, BOOL isVertical, BOOL isSimulationAllowed, DWRITE_SCRIPT_ANALYSIS scriptAnalysis, const(WCHAR)* localeName, INT32* baselineCoordinate, BOOL* exists)

<summary> Retrieves the given baseline from the font. </summary> <param name="fontFace">The font face to read.</param> <param name="baseline">The baseline of interest.</param> <param name="isVertical">Whether the baseline is vertical or horizontal.</param> <param name="isSimulationAllowed">Simulate the baseline if it is missing in the font.</param> <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> <param name="localeName">The language of the run.</param> <param name="baselineCoordinate">The baseline coordinate value in design units.</param> <param name="exists">Whether the returned baseline exists in the font.</param> <remarks> If the baseline does not exist in the font, it is not considered an error, but the function will return exists = false. You may then use heuristics to calculate the missing base, or, if the flag simulationAllowed is true, the function will compute a reasonable approximation for you. </remarks> <returns> Standard HRESULT error code. </returns>

GetGlyphOrientationTransform
HRESULT GetGlyphOrientationTransform(DWRITE_GLYPH_ORIENTATION_ANGLE glyphOrientationAngle, BOOL isSideways, DWRITE_MATRIX* transform)

<summary> Returns 2x3 transform matrix for the respective angle to draw the glyph run. </summary> <param name="glyphOrientationAngle">The angle reported into SetGlyphOrientation.</param> <param name="isSideways">Whether the run's glyphs are sideways or not.</param> <param name="transform">Returned transform.</param> </remarks> <returns> Standard HRESULT error code. </returns> <remarks> The returned displacement is zero. </remarks>

GetJustificationOpportunities
HRESULT GetJustificationOpportunities(IDWriteFontFace fontFace, FLOAT fontEmSize, DWRITE_SCRIPT_ANALYSIS scriptAnalysis, UINT32 textLength, UINT32 glyphCount, const(WCHAR)* textString, const(UINT16)* clusterMap, const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProperties, DWRITE_JUSTIFICATION_OPPORTUNITY* justificationOpportunities)

<summary> Retrieves justification opportunity information for each of the glyphs given the text and shaping glyph properties. </summary> <param name="fontFace">Font face that was used for shaping. This is mainly important for returning correct results of the kashida width.</param> <param name="fontEmSize">Font em size used for the glyph run.</param> <param name="scriptAnalysis">Script of the text from the itemizer.</param> <param name="textLength">Length of the text.</param> <param name="glyphCount">Number of glyphs.</param> <param name="textString">Characters used to produce the glyphs.</param> <param name="clusterMap">Clustermap produced from shaping.</param> <param name="glyphProperties">Glyph properties produced from shaping.</param> <param name="justificationOpportunities">Receives information for the allowed justification expansion/compression for each glyph.</param> <remarks> This function is called per-run, after shaping is done via GetGlyphs(). Note this function only supports natural metrics (DWRITE_MEASURING_MODE_NATURAL). </remarks> <returns> Standard HRESULT error code. </returns>

GetJustifiedGlyphs
HRESULT GetJustifiedGlyphs(IDWriteFontFace fontFace, FLOAT fontEmSize, DWRITE_SCRIPT_ANALYSIS scriptAnalysis, UINT32 textLength, UINT32 glyphCount, UINT32 maxGlyphCount, const(UINT16)* clusterMap, const(UINT16)* glyphIndices, const(FLOAT)* glyphAdvances, const(FLOAT)* justifiedGlyphAdvances, const(DWRITE_GLYPH_OFFSET)* justifiedGlyphOffsets, const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProperties, UINT32* actualGlyphCount, UINT16* modifiedClusterMap, UINT16* modifiedGlyphIndices, FLOAT* modifiedGlyphAdvances, DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets)

<summary> Fills in new glyphs for complex scripts where justification increased the advances of glyphs, such as Arabic with kashida. </summary> <param name="fontFace">Font face used for shaping.</param> <param name="fontEmSize">Font em size used for the glyph run.</param> <param name="scriptAnalysis">Script of the text from the itemizer.</param> <param name="textLength">Length of the text.</param> <param name="glyphCount">Number of glyphs.</param> <param name="maxGlyphCount">Maximum number of output glyphs allocated by caller.</param> <param name="clusterMap">Clustermap produced from shaping.</param> <param name="glyphIndices">Original glyphs produced from shaping.</param> <param name="glyphAdvances">Original glyph advances produced from shaping.</param> <param name="justifiedGlyphAdvances">Justified glyph advances from JustifyGlyphAdvances().</param> <param name="justifiedGlyphOffsets">Justified glyph offsets from JustifyGlyphAdvances().</param> <param name="glyphProperties">Properties of each glyph, from GetGlyphs.</param> <param name="actualGlyphCount">The new glyph count written to the modified arrays, or the needed glyph count if the size is not large enough.</param> <param name="modifiedClusterMap">Updated clustermap.</param> <param name="modifiedGlyphIndices">Updated glyphs with new glyphs inserted where needed.</param> <param name="modifiedGlyphAdvances">Updated glyph advances.</param> <param name="modifiedGlyphOffsets">Updated glyph offsets.</param> <remarks> This is called after the line has been justified, and it is per-run. It only needs to be called if the script has a specific justification character via GetScriptProperties, and it is mainly for cursive scripts like Arabic. If maxGlyphCount is not large enough, the error E_NOT_SUFFICIENT_BUFFER will be returned, with actualGlyphCount holding the final/needed glyph count. </remarks> <returns> Standard HRESULT error code. </returns>

GetScriptProperties
HRESULT GetScriptProperties(DWRITE_SCRIPT_ANALYSIS scriptAnalysis, DWRITE_SCRIPT_PROPERTIES* scriptProperties)

<summary> Returns the properties for a given script. </summary> <param name="scriptAnalysis">The script for a run of text returned from IDWriteTextAnalyzer::AnalyzeScript.</param> <param name="scriptProperties">Information for the script.</param> <returns> Returns properties for the given script. If the script is invalid, it returns generic properties for the unknown script and E_INVALIDARG. </returns>

GetTextComplexity
HRESULT GetTextComplexity(const(WCHAR)* textString, UINT32 textLength, IDWriteFontFace fontFace, BOOL* isTextSimple, UINT32* textLengthRead, UINT16* glyphIndices)

<summary> Determines the complexity of text, and whether or not full script shaping needs to be called (GetGlyphs). </summary> <param name="fontFace">The font face to read.</param> <param name="textLength">Length of the text to check.</param> <param name="textString">The text to check for complexity. This string may be UTF-16, but any supplementary characters will be considered complex.</param> <param name="isTextSimple">If true, the text is simple, and the glyphIndices array will already have the nominal glyphs for you. Otherwise you need to call GetGlyphs to properly shape complex scripts and OpenType features. </param> <param name="textLengthRead">The length read of the text run with the same complexity, simple or complex. You may call again from that point onward.</param> <param name="glyphIndices">Optional glyph indices for the text. If the function returned that the text was simple, you already have the glyphs you need. Otherwise the glyph indices are not meaningful, and you should call shaping instead.</param> <remarks> Text is not simple if the characters are part of a script that has complex shaping requirements, require bidi analysis, combine with other characters, reside in the supplementary planes, or have glyphs which participate in standard OpenType features. The length returned will not split combining marks from their base characters. </remarks> <returns> Standard HRESULT error code. </returns>

JustifyGlyphAdvances
HRESULT JustifyGlyphAdvances(FLOAT lineWidth, UINT32 glyphCount, const(DWRITE_JUSTIFICATION_OPPORTUNITY)* justificationOpportunities, const(FLOAT)* glyphAdvances, const(DWRITE_GLYPH_OFFSET)* glyphOffsets, FLOAT* justifiedGlyphAdvances, DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets)

<summary> Justifies an array of glyph advances to fit the line width. </summary> <param name="lineWidth">Width of the line.</param> <param name="glyphCount">Number of glyphs.</param> <param name="justificationOpportunities">Opportunities per glyph. Call GetJustificationOpportunities() to get suitable opportunities according to script.</param> <param name="glyphAdvances">Original glyph advances from shaping.</param> <param name="glyphOffsets">Original glyph offsets from shaping.</param> <param name="justifiedGlyphAdvances">Justified glyph advances.</param> <param name="justifiedGlyphOffsets">Justified glyph offsets.</param> <remarks> This is called after all the opportunities have been collected, and it spans across the entire line. The input and output arrays are allowed to alias each other, permitting in-place update. </remarks> <returns> Standard HRESULT error code. </returns>

Inherited Members

From IDWriteTextAnalyzer

AnalyzeScript
HRESULT AnalyzeScript(IDWriteTextAnalysisSource analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink analysisSink)

<summary> Analyzes a text range for script boundaries, reading text attributes from the source and reporting the Unicode script ID to the sink callback SetScript. </summary> <param name="analysisSource">Source object to analyze.</param> <param name="textPosition">Starting position within the source object.</param> <param name="textLength">Length to analyze.</param> <param name="analysisSink">Callback object.</param> <returns> Standard HRESULT error code. </returns>

AnalyzeBidi
HRESULT AnalyzeBidi(IDWriteTextAnalysisSource analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink analysisSink)

<summary> Analyzes a text range for script directionality, reading attributes from the source and reporting levels to the sink callback SetBidiLevel. </summary> <param name="analysisSource">Source object to analyze.</param> <param name="textPosition">Starting position within the source object.</param> <param name="textLength">Length to analyze.</param> <param name="analysisSink">Callback object.</param> <returns> Standard HRESULT error code. </returns> <remarks> While the function can handle multiple paragraphs, the text range should not arbitrarily split the middle of paragraphs. Otherwise the returned levels may be wrong, since the Bidi algorithm is meant to apply to the paragraph as a whole. </remarks> <remarks> Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account. </remarks>

AnalyzeNumberSubstitution
HRESULT AnalyzeNumberSubstitution(IDWriteTextAnalysisSource analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink analysisSink)

<summary> Analyzes a text range for spans where number substitution is applicable, reading attributes from the source and reporting substitutable ranges to the sink callback SetNumberSubstitution. </summary> <param name="analysisSource">Source object to analyze.</param> <param name="textPosition">Starting position within the source object.</param> <param name="textLength">Length to analyze.</param> <param name="analysisSink">Callback object.</param> <returns> Standard HRESULT error code. </returns> <remarks> While the function can handle multiple ranges of differing number substitutions, the text ranges should not arbitrarily split the middle of numbers. Otherwise it will treat the numbers separately and will not translate any intervening punctuation. </remarks> <remarks> Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account. </remarks>

AnalyzeLineBreakpoints
HRESULT AnalyzeLineBreakpoints(IDWriteTextAnalysisSource analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink analysisSink)

<summary> Analyzes a text range for potential breakpoint opportunities, reading attributes from the source and reporting breakpoint opportunities to the sink callback SetLineBreakpoints. </summary> <param name="analysisSource">Source object to analyze.</param> <param name="textPosition">Starting position within the source object.</param> <param name="textLength">Length to analyze.</param> <param name="analysisSink">Callback object.</param> <returns> Standard HRESULT error code. </returns> <remarks> While the function can handle multiple paragraphs, the text range should not arbitrarily split the middle of paragraphs, unless the given text span is considered a whole unit. Otherwise the returned properties for the first and last characters will inappropriately allow breaks. </remarks> <remarks> Special cases include the first, last, and surrogate characters. Any text span is treated as if adjacent to inline objects on either side. So the rules with contingent-break opportunities are used, where the edge between text and inline objects is always treated as a potential break opportunity, dependent on any overriding rules of the adjacent objects to prohibit or force the break (see Unicode TR #14). Surrogate pairs never break between. </remarks>

GetGlyphs
HRESULT GetGlyphs(const(WCHAR)* textString, UINT32 textLength, IDWriteFontFace fontFace, BOOL isSideways, BOOL isRightToLeft, const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, const(WCHAR)* localeName, IDWriteNumberSubstitution numberSubstitution, const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, const(UINT32)* featureRangeLengths, UINT32 featureRanges, UINT32 maxGlyphCount, UINT16* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, UINT16* glyphIndices, DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps, UINT32* actualGlyphCount)

<summary> Parses the input text string and maps it to the set of glyphs and associated glyph data according to the font and the writing system's rendering rules. </summary> <param name="textString">The string to convert to glyphs.</param> <param name="textLength">The length of textString.</param> <param name="fontFace">The font face to get glyphs from.</param> <param name="isSideways">Set to true if the text is intended to be drawn vertically.</param> <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> <param name="localeName">The locale to use when selecting glyphs. e.g. the same character may map to different glyphs for ja-jp vs zh-chs. If this is NULL then the default mapping based on the script is used.</param> <param name="numberSubstitution">Optional number substitution which selects the appropriate glyphs for digits and related numeric characters, depending on the results obtained from AnalyzeNumberSubstitution. Passing null indicates that no substitution is needed and that the digits should receive nominal glyphs.</param> <param name="features">An array of pointers to the sets of typographic features to use in each feature range.</param> <param name="featureRangeLengths">The length of each feature range, in characters. The sum of all lengths should be equal to textLength.</param> <param name="featureRanges">The number of feature ranges.</param> <param name="maxGlyphCount">The maximum number of glyphs that can be returned.</param> <param name="clusterMap">The mapping from character ranges to glyph ranges.</param> <param name="textProps">Per-character output properties.</param> <param name="glyphIndices">Output glyph indices.</param> <param name="glyphProps">Per-glyph output properties.</param> <param name="actualGlyphCount">The actual number of glyphs returned if the call succeeds.</param> <returns> Standard HRESULT error code. </returns> <remarks> Note that the mapping from characters to glyphs is, in general, many- to-many. The recommended estimate for the per-glyph output buffers is (3 * textLength / 2 + 16). This is not guaranteed to be sufficient.

GetGlyphPlacements
HRESULT GetGlyphPlacements(const(WCHAR)* textString, const(UINT16)* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, UINT32 textLength, const(UINT16)* glyphIndices, const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProps, UINT32 glyphCount, IDWriteFontFace fontFace, FLOAT fontEmSize, BOOL isSideways, BOOL isRightToLeft, const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, const(WCHAR)* localeName, const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, const(UINT32)* featureRangeLengths, UINT32 featureRanges, FLOAT* glyphAdvances, DWRITE_GLYPH_OFFSET* glyphOffsets)

<summary> Place glyphs output from the GetGlyphs method according to the font and the writing system's rendering rules. </summary> <param name="textString">The original string the glyphs came from.</param> <param name="clusterMap">The mapping from character ranges to glyph ranges. Returned by GetGlyphs.</param> <param name="textProps">Per-character properties. Returned by GetGlyphs.</param> <param name="textLength">The length of textString.</param> <param name="glyphIndices">Glyph indices. See GetGlyphs</param> <param name="glyphProps">Per-glyph properties. See GetGlyphs</param> <param name="glyphCount">The number of glyphs.</param> <param name="fontFace">The font face the glyphs came from.</param> <param name="fontEmSize">Logical font size in DIP's.</param> <param name="isSideways">Set to true if the text is intended to be drawn vertically.</param> <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> <param name="localeName">The locale to use when selecting glyphs. e.g. the same character may map to different glyphs for ja-jp vs zh-chs. If this is NULL then the default mapping based on the script is used.</param> <param name="features">An array of pointers to the sets of typographic features to use in each feature range.</param> <param name="featureRangeLengths">The length of each feature range, in characters. The sum of all lengths should be equal to textLength.</param> <param name="featureRanges">The number of feature ranges.</param> <param name="glyphAdvances">The advance width of each glyph.</param> <param name="glyphOffsets">The offset of the origin of each glyph.</param> <returns> Standard HRESULT error code. </returns>

GetGdiCompatibleGlyphPlacements
HRESULT GetGdiCompatibleGlyphPlacements(const(WCHAR)* textString, const(UINT16)* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, UINT32 textLength, const(UINT16)* glyphIndices, const(DWRITE_SHAPING_GLYPH_PROPERTIES)* glyphProps, UINT32 glyphCount, IDWriteFontFace fontFace, FLOAT fontEmSize, FLOAT pixelsPerDip, const(DWRITE_MATRIX)* transform, BOOL useGdiNatural, BOOL isSideways, BOOL isRightToLeft, const(DWRITE_SCRIPT_ANALYSIS)* scriptAnalysis, const(WCHAR)* localeName, const(DWRITE_TYPOGRAPHIC_FEATURES*)* features, const(UINT32)* featureRangeLengths, UINT32 featureRanges, FLOAT* glyphAdvances, DWRITE_GLYPH_OFFSET* glyphOffsets)

<summary> Place glyphs output from the GetGlyphs method according to the font and the writing system's rendering rules. </summary> <param name="textString">The original string the glyphs came from.</param> <param name="clusterMap">The mapping from character ranges to glyph ranges. Returned by GetGlyphs.</param> <param name="textProps">Per-character properties. Returned by GetGlyphs.</param> <param name="textLength">The length of textString.</param> <param name="glyphIndices">Glyph indices. See GetGlyphs</param> <param name="glyphProps">Per-glyph properties. See GetGlyphs</param> <param name="glyphCount">The number of glyphs.</param> <param name="fontFace">The font face the glyphs came from.</param> <param name="fontEmSize">Logical font size in DIP's.</param> <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param> <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified by the font size and pixelsPerDip.</param> <param name="useGdiNatural"> When set to FALSE, the metrics are the same as the metrics of GDI aliased text. When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font created with CLEARTYPE_NATURAL_QUALITY. </param> <param name="isSideways">Set to true if the text is intended to be drawn vertically.</param> <param name="isRightToLeft">Set to TRUE for right-to-left text.</param> <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> <param name="localeName">The locale to use when selecting glyphs. e.g. the same character may map to different glyphs for ja-jp vs zh-chs. If this is NULL then the default mapping based on the script is used.</param> <param name="features">An array of pointers to the sets of typographic features to use in each feature range.</param> <param name="featureRangeLengths">The length of each feature range, in characters. The sum of all lengths should be equal to textLength.</param> <param name="featureRanges">The number of feature ranges.</param> <param name="glyphAdvances">The advance width of each glyph.</param> <param name="glyphOffsets">The offset of the origin of each glyph.</param> <returns> Standard HRESULT error code. </returns>

Meta