Table of Contents

Class TextAnalyzer1

Namespace
SharpDX.DirectWrite
Assembly
SharpDX.Direct2D1.dll
[Guid("80DAD800-E21F-4E83-96CE-BFCCE500DB7C")]
public class TextAnalyzer1 : TextAnalyzer
Inheritance
TextAnalyzer1
Derived
Inherited Members

Constructors

TextAnalyzer1(nint)

public TextAnalyzer1(nint nativePtr)

Parameters

nativePtr nint

Methods

AnalyzeVerticalGlyphOrientation(TextAnalysisSource1, int, int, TextAnalysisSink1)

Analyzes a text range for script orientation, reading text and attributes from the source and reporting results to the sink callback SetGlyphOrientation.

public void AnalyzeVerticalGlyphOrientation(TextAnalysisSource1 analysisSource, int textPosition, int textLength, TextAnalysisSink1 analysisSink)

Parameters

analysisSource TextAnalysisSource1

No documentation.

textPosition int

No documentation.

textLength int

No documentation.

analysisSink TextAnalysisSink1

No documentation.

ApplyCharacterSpacing(float, float, float, int, int, short[], float[], GlyphOffset[], ShapingGlyphProperties[], float[], GlyphOffset[])

Applies spacing between characters, properly adjusting glyph clusters and diacritics.

public void ApplyCharacterSpacing(float leadingSpacing, float trailingSpacing, float minimumAdvanceWidth, int textLength, int glyphCount, short[] clusterMap, float[] glyphAdvances, GlyphOffset[] glyphOffsets, ShapingGlyphProperties[] glyphProperties, float[] modifiedGlyphAdvances, GlyphOffset[] modifiedGlyphOffsets)

Parameters

leadingSpacing float

The spacing before each character, in reading order.

trailingSpacing float

The spacing after each character, in reading order.

minimumAdvanceWidth float

The minimum advance of each character, to prevent characters from becoming too thin or zero-width. This must be zero or greater.

textLength int

The length of the clustermap and original text.

glyphCount int

The number of glyphs.

clusterMap short[]

Mapping from character ranges to glyph ranges.

glyphAdvances float[]

The advance width of each glyph.

glyphOffsets GlyphOffset[]

The offset of the origin of each glyph.

glyphProperties ShapingGlyphProperties[]

Properties of each glyph, from GetGlyphs.

modifiedGlyphAdvances float[]

The new advance width of each glyph.

modifiedGlyphOffsets GlyphOffset[]

The new offset of the origin of each glyph.

Remarks

The input and output advances/offsets are allowed to alias the same array.

GetBaseline(FontFace, Baseline, RawBool, RawBool, ScriptAnalysis, string, out int, out RawBool)

Retrieves the given baseline from the font.

public void GetBaseline(FontFace fontFace, Baseline baseline, RawBool isVertical, RawBool isSimulationAllowed, ScriptAnalysis scriptAnalysis, string localeName, out int baselineCoordinate, out RawBool exists)

Parameters

fontFace FontFace

The font face to read.

baseline Baseline

A Baseline-typed value that specifies the baseline of interest.

isVertical RawBool

Whether the baseline is vertical or horizontal.

isSimulationAllowed RawBool

Simulate the baseline if it is missing in the font.

scriptAnalysis ScriptAnalysis

Script analysis result from AnalyzeScript.

Note??You can pass an empty script analysis structure, like this
scriptAnalysis = {};
, and this method will return the default baseline. ?
localeName string

The language of the run.

baselineCoordinate int

The baseline coordinate value in design units.

exists RawBool

Whether the returned baseline exists in the font.

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.

GetGlyphOrientationTransform(GlyphOrientationAngle, RawBool, out RawMatrix3x2)

Returns 2x3 transform matrix for the respective angle to draw the glyph run.

public void GetGlyphOrientationTransform(GlyphOrientationAngle glyphOrientationAngle, RawBool isSideways, out RawMatrix3x2 transform)

Parameters

glyphOrientationAngle GlyphOrientationAngle

A GlyphOrientationAngle-typed value that specifies the angle that was reported into IDWriteTextAnalysisSink1::SetGlyphOrientation.

isSideways RawBool

Whether the run's glyphs are sideways or not.

transform RawMatrix3x2

Returned transform.

Remarks

The translation component of the transform returned is zero.

GetJustificationOpportunities(FontFace, float, ScriptAnalysis, int, int, string, short[], ShapingGlyphProperties[], JustificationOpportunity[])

Retrieves justification opportunity information for each of the glyphs given the text and shaping glyph properties.

public void GetJustificationOpportunities(FontFace fontFace, float fontEmSize, ScriptAnalysis scriptAnalysis, int textLength, int glyphCount, string textString, short[] clusterMap, ShapingGlyphProperties[] glyphProperties, JustificationOpportunity[] justificationOpportunities)

Parameters

fontFace FontFace

Font face that was used for shaping. This is mainly important for returning correct results of the kashida width.

May be null.

fontEmSize float

Font em size used for the glyph run.

scriptAnalysis ScriptAnalysis

Script of the text from the itemizer.

textLength int

Length of the text.

glyphCount int

Number of glyphs.

textString string

Characters used to produce the glyphs.

clusterMap short[]

Clustermap produced from shaping.

glyphProperties ShapingGlyphProperties[]

Glyph properties produced from shaping.

justificationOpportunities JustificationOpportunity[]

A reference to a JustificationOpportunity structure that receives info for the allowed justification expansion/compression for each glyph.

Remarks

This function is called per-run, after shaping is done via the IDWriteTextAnalyzer::GetGlyphs method.

Note??this function only supports natural metrics (DWRITE_MEASURING_MODE_NATURAL).?

GetJustifiedGlyphs(FontFace, float, ScriptAnalysis, int, int, int, short[], short[], float[], float[], GlyphOffset[], ShapingGlyphProperties[], int, short[], short[], float[], GlyphOffset[])

Fills in new glyphs for complex scripts where justification increased the advances of glyphs, such as Arabic with kashida.

public void GetJustifiedGlyphs(FontFace fontFace, float fontEmSize, ScriptAnalysis scriptAnalysis, int textLength, int glyphCount, int maxGlyphCount, short[] clusterMap, short[] glyphIndices, float[] glyphAdvances, float[] justifiedGlyphAdvances, GlyphOffset[] justifiedGlyphOffsets, ShapingGlyphProperties[] glyphProperties, int actualGlyphCount, short[] modifiedClusterMap, short[] modifiedGlyphIndices, float[] modifiedGlyphAdvances, GlyphOffset[] modifiedGlyphOffsets)

Parameters

fontFace FontFace

Font face used for shaping.

May be null.

fontEmSize float

Font em size used for the glyph run.

scriptAnalysis ScriptAnalysis

Script of the text from the itemizer.

textLength int

Length of the text.

glyphCount int

Number of glyphs.

maxGlyphCount int

Maximum number of output glyphs allocated by caller.

clusterMap short[]

Clustermap produced from shaping.

glyphIndices short[]

Original glyphs produced from shaping.

glyphAdvances float[]

Original glyph advances produced from shaping.

justifiedGlyphAdvances float[]

Justified glyph advances from IDWriteTextAnalyzer1::JustifyGlyphAdvances.

justifiedGlyphOffsets GlyphOffset[]

Justified glyph offsets from IDWriteTextAnalyzer1::JustifyGlyphAdvances.

glyphProperties ShapingGlyphProperties[]

Properties of each glyph, from IDWriteTextAnalyzer::GetGlyphs.

actualGlyphCount int

The new glyph count written to the modified arrays, or the needed glyph count if the size is not large enough.

modifiedClusterMap short[]

Updated clustermap.

modifiedGlyphIndices short[]

Updated glyphs with new glyphs inserted where needed.

modifiedGlyphAdvances float[]

Updated glyph advances.

modifiedGlyphOffsets GlyphOffset[]

Updated glyph offsets.

Remarks

You call GetJustifiedGlyphs after the line has been justified, and it is per-run.

You should call GetJustifiedGlyphs if IDWriteTextAnalyzer1::GetScriptProperties returns a non-null ScriptProperties.justificationCharacter for that script.

Use GetJustifiedGlyphs mainly for cursive scripts like Arabic. If maxGlyphCount is not large enough, GetJustifiedGlyphs returns the error E_NOT_SUFFICIENT_BUFFER and fills the variable to which actualGlyphCount points with the needed glyph count.

GetScriptProperties(ScriptAnalysis, out ScriptProperties)

Retrieves the properties for a given script.

public void GetScriptProperties(ScriptAnalysis scriptAnalysis, out ScriptProperties scriptProperties)

Parameters

scriptAnalysis ScriptAnalysis

The script for a run of text returned from IDWriteTextAnalyzer::AnalyzeScript.

scriptProperties ScriptProperties

A reference to a ScriptProperties structure that describes info for the script.

GetTextComplexity(string, int, FontFace, out RawBool, int, short[])

Determines the complexity of text, and whether you need to call IDWriteTextAnalyzer::GetGlyphs for full script shaping.

public void GetTextComplexity(string textString, int textLength, FontFace fontFace, out RawBool isTextSimple, int textLengthRead, short[] glyphIndices)

Parameters

textString string

No documentation.

textLength int

No documentation.

fontFace FontFace

No documentation.

isTextSimple RawBool

No documentation.

textLengthRead int

No documentation.

glyphIndices short[]

No documentation.

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 that participate in standard OpenType features. The length returned will not split combining marks from their base characters.

JustifyGlyphAdvances(float, int, JustificationOpportunity[], float[], GlyphOffset[], float[], GlyphOffset[])

Justifies an array of glyph advances to fit the line width.

public void JustifyGlyphAdvances(float lineWidth, int glyphCount, JustificationOpportunity[] justificationOpportunities, float[] glyphAdvances, GlyphOffset[] glyphOffsets, float[] justifiedGlyphAdvances, GlyphOffset[] justifiedGlyphOffsets)

Parameters

lineWidth float

The line width.

glyphCount int

The glyph count.

justificationOpportunities JustificationOpportunity[]

A reference to a JustificationOpportunity structure that contains info for the allowed justification expansion/compression for each glyph. Get this info from IDWriteTextAnalyzer1::GetJustificationOpportunities.

glyphAdvances float[]

An array of glyph advances.

glyphOffsets GlyphOffset[]

An array of glyph offsets.

justifiedGlyphAdvances float[]

The returned array of justified glyph advances.

justifiedGlyphOffsets GlyphOffset[]

The returned array of justified glyph offsets.

Remarks

You call JustifyGlyphAdvances after you call IDWriteTextAnalyzer1::GetJustificationOpportunities to collect all the opportunities, and JustifyGlyphAdvances spans across the entire line. The input and output arrays are allowed to alias each other, permitting in-place update.

Operators

explicit operator TextAnalyzer1(nint)

public static explicit operator TextAnalyzer1(nint nativePtr)

Parameters

nativePtr nint

Returns

TextAnalyzer1