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
TextAnalysisSource1No documentation.
textPosition
intNo documentation.
textLength
intNo documentation.
analysisSink
TextAnalysisSink1No 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
floatThe spacing before each character, in reading order.
trailingSpacing
floatThe spacing after each character, in reading order.
minimumAdvanceWidth
floatThe minimum advance of each character, to prevent characters from becoming too thin or zero-width. This must be zero or greater.
textLength
intThe length of the clustermap and original text.
glyphCount
intThe 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
FontFaceThe font face to read.
baseline
BaselineA Baseline-typed value that specifies the baseline of interest.
isVertical
RawBoolWhether the baseline is vertical or horizontal.
isSimulationAllowed
RawBoolSimulate the baseline if it is missing in the font.
scriptAnalysis
ScriptAnalysisScript analysis result from AnalyzeScript.
Note??You can pass an empty script analysis structure, like this
, and this method will return the default baseline. ?scriptAnalysis = {};
localeName
stringThe language of the run.
baselineCoordinate
intThe baseline coordinate value in design units.
exists
RawBoolWhether 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
GlyphOrientationAngleA GlyphOrientationAngle-typed value that specifies the angle that was reported into IDWriteTextAnalysisSink1::SetGlyphOrientation.
isSideways
RawBoolWhether the run's glyphs are sideways or not.
transform
RawMatrix3x2Returned 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
FontFaceFont face that was used for shaping. This is mainly important for returning correct results of the kashida width.
May be
null
.fontEmSize
floatFont em size used for the glyph run.
scriptAnalysis
ScriptAnalysisScript of the text from the itemizer.
textLength
intLength of the text.
glyphCount
intNumber of glyphs.
textString
stringCharacters 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
FontFaceFont face used for shaping.
May be
null
.fontEmSize
floatFont em size used for the glyph run.
scriptAnalysis
ScriptAnalysisScript of the text from the itemizer.
textLength
intLength of the text.
glyphCount
intNumber of glyphs.
maxGlyphCount
intMaximum 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
intThe 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
ScriptAnalysisThe script for a run of text returned from IDWriteTextAnalyzer::AnalyzeScript.
scriptProperties
ScriptPropertiesA 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
stringNo documentation.
textLength
intNo documentation.
fontFace
FontFaceNo documentation.
isTextSimple
RawBoolNo documentation.
textLengthRead
intNo 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
floatThe line width.
glyphCount
intThe 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