SceneText Class

A line of text, positioned by its baseline.

public sealed class SceneText : SceneElement
Inheritance
SceneElement SceneText

Constructors

NameDescription
SceneText(double, double, IEnumerable<SceneTextSpan>, SceneFont, SceneColor)Initializes a new instance of the SceneText class whose parts have their own styles.
SceneText(double, double, string, SceneFont, SceneColor)A line of text, positioned by its baseline.

SceneText overloads

SceneText(double, double, IEnumerable<SceneTextSpan>, SceneFont, SceneColor)

SceneText.cs

Initializes a new instance of the SceneText class whose parts have their own styles.

public SceneText(double x, double y, IEnumerable<SceneTextSpan> spans, SceneFont font, SceneColor color)
Parameters
x double
The x coordinate of the anchor.
y double
The y coordinate of the baseline.
spans IEnumerable<SceneTextSpan>
The parts of the text, drawn one after the other.
font SceneFont
The font of the spans that set none.
color SceneColor
The color of the spans that set none.
Exceptions
ArgumentException
spans contains null.

SceneText(double, double, string, SceneFont, SceneColor)

SceneText.cs

A line of text, positioned by its baseline.

public SceneText(double x, double y, string text, SceneFont font, SceneColor color)
Parameters
x double
The x coordinate of the anchor.
y double
The y coordinate of the baseline.
text string
The text.
font SceneFont
The size and the weight of the font.
color SceneColor
The color of the text.

Properties

NameDescription
AnchorGets or sets where the text is anchored horizontally.
BaselineGets or sets the baseline that is on SceneText.Y, as the SVG dominant-baseline property. The default is the alphabetic baseline. Each span is aligned by the baseline of its own font.
ColorGets the color of the text.
DecorationFillGets or sets how the lines of the text (SceneText.Decorations) are painted, or null (the default) to paint them as the glyphs of each span.
DecorationsGets or sets the lines drawn with the text: an underline, a strikethrough, an overline, or several of them. They have the color of the text, and the position and the thickness the font gives them.
DirectionGets or sets the direction the text is written in, as the SVG direction property. The default is from left to right.
FillGets or sets how the glyphs are painted, or null (the default) to paint them with SceneText.Color. A gradient or a pattern is in the coordinates of the text, as for a shape.
FontGets the size and the weight of the font.
LengthAdjustGets or sets how the text is fitted to SceneText.TextLength. The default changes the spacing only.
LetterSpacingGets or sets the space added after each character, in pixels, as the CSS letter-spacing; negative to tighten. The default is 0.
LineCapGets or sets the shape of the ends of the open outlines of the glyphs.
LineJoinGets or sets the shape of the corners of the outline of the glyphs.
MeasuredWidthGets or sets the advance width of the text, as the layout measured it.
MiterLimitGets or sets the limit of SceneLineJoin.Miter joins of the outline of the glyphs. The default is 4, as in SVG; a value less than 1 or not finite is 4.
PaintOrderGets or sets the order in which the fill and the outline of the glyphs are painted, as the SVG paint-order property. A text has no markers: only whether the stroke comes before the fill matters. The default paints the fill first.
PathGets or sets the path the text follows, as an SVG textPath, or null for a straight text on its baseline. With a path, SceneText.X, SceneText.Y and SceneText.Rotation are ignored.
PathStartOffsetGets or sets the distance along SceneText.Path at which the text is anchored, in pixels. The default is 0.
RotationGets or sets the rotation of the text around its anchor, in degrees, clockwise.
SpansGets the parts of the text that have their own styles, or an empty list when the whole text has the style of the text. SceneText.Text is the text of the spans, one after the other.
StrokeGets or sets how the outline of the glyphs is painted, or null (the default) for no outline.
StrokeDashArrayGets or sets the lengths of the dashes and gaps of the outline of the glyphs, or null for a solid outline.
StrokeDashOffsetGets or sets the distance into SceneText.StrokeDashArray at which the dashes of the outline start. A negative distance starts before the pattern, and a value that is not finite is 0.
StrokeWidthGets or sets the width of the outline of the glyphs. The default is 1.
TextGets the text.
TextLengthGets or sets the advance the text is stretched or compressed to, in pixels, as the SVG textLength attribute, or null (the default) for the natural advance of its glyphs.
WordSpacingGets or sets the space added to each space (U+0020 and U+00A0), in pixels, as the CSS word-spacing; negative to tighten. The default is 0.
XGets the x coordinate of the anchor.
YGets the y coordinate of the baseline.

Gets or sets where the text is anchored horizontally.

public SceneTextAnchor Anchor { get; set; }

Property value

SceneTextAnchor

Baseline

SceneText.cs

Gets or sets the baseline that is on SceneText.Y, as the SVG dominant-baseline property. The default is the alphabetic baseline. Each span is aligned by the baseline of its own font.

public SceneTextBaseline Baseline { get; set; }

Property value

SceneTextBaseline

Gets the color of the text.

public SceneColor Color { get; }

Property value

SceneColor

DecorationFill

SceneText.cs

Gets or sets how the lines of the text (SceneText.Decorations) are painted, or null (the default) to paint them as the glyphs of each span.

public ScenePaint? DecorationFill { get; set; }

Property value

ScenePaint?

Remarks

SVG paints the lines with the fill of the element that declares them: a text whose spans have their own colors has lines of the color of the text. Set this paint to draw the lines that way.

Decorations

SceneText.cs

Gets or sets the lines drawn with the text: an underline, a strikethrough, an overline, or several of them. They have the color of the text, and the position and the thickness the font gives them.

public SceneTextDecorations Decorations { get; set; }

Property value

SceneTextDecorations

Direction

SceneText.cs

Gets or sets the direction the text is written in, as the SVG direction property. The default is from left to right.

public SceneTextDirection Direction { get; set; }

Property value

SceneTextDirection

Remarks

From right to left, SceneTextAnchor.Start is the right end of the text, the spans follow each other to the left, and the characters of each span are ordered by the Unicode Bidirectional Algorithm with a right-to-left paragraph. From left to right, the paragraph of each span has the direction of its first strong character. The algorithm does not reorder the spans themselves.

Gets or sets how the glyphs are painted, or null (the default) to paint them with SceneText.Color. A gradient or a pattern is in the coordinates of the text, as for a shape.

public ScenePaint? Fill { get; set; }

Property value

ScenePaint?

Remarks

To draw the outline of the glyphs only, set a SceneText.Stroke and a transparent fill.

Gets the size and the weight of the font.

public SceneFont Font { get; }

Property value

SceneFont

LengthAdjust

SceneText.cs

Gets or sets how the text is fitted to SceneText.TextLength. The default changes the spacing only.

public SceneTextLengthAdjust LengthAdjust { get; set; }

Property value

SceneTextLengthAdjust

LetterSpacing

SceneText.cs

Gets or sets the space added after each character, in pixels, as the CSS letter-spacing; negative to tighten. The default is 0.

public double LetterSpacing { get; set; }

Property value

double

Remarks

The space is added after each grapheme cluster (a character with its marks), the last one included, and the optional ligatures are not formed when it is not 0. A value that is not finite is 0.

Gets or sets the shape of the ends of the open outlines of the glyphs.

public SceneLineCap LineCap { get; set; }

Property value

SceneLineCap

LineJoin

SceneText.cs

Gets or sets the shape of the corners of the outline of the glyphs.

public SceneLineJoin LineJoin { get; set; }

Property value

SceneLineJoin

MeasuredWidth

SceneText.cs

Gets or sets the advance width of the text, as the layout measured it.

public double MeasuredWidth { get; set; }

Property value

double

MiterLimit

SceneText.cs

Gets or sets the limit of SceneLineJoin.Miter joins of the outline of the glyphs. The default is 4, as in SVG; a value less than 1 or not finite is 4.

public double MiterLimit { get; set; }

Property value

double

PaintOrder

SceneText.cs

Gets or sets the order in which the fill and the outline of the glyphs are painted, as the SVG paint-order property. A text has no markers: only whether the stroke comes before the fill matters. The default paints the fill first.

public ScenePaintOrder PaintOrder { get; set; }

Property value

ScenePaintOrder

Gets or sets the path the text follows, as an SVG textPath, or null for a straight text on its baseline. With a path, SceneText.X, SceneText.Y and SceneText.Rotation are ignored.

public PathData? Path { get; set; }

Property value

PathData?

Remarks

The baseline of the text is on the path, and each character is turned to the direction of the path at the middle of its advance. The text starts at SceneText.PathStartOffset along the path, where SceneText.Anchor places it: its start, its middle or its end is there. The characters whose middle is beyond the ends of the path are not drawn. The subpaths are followed one after the other.

PathStartOffset

SceneText.cs

Gets or sets the distance along SceneText.Path at which the text is anchored, in pixels. The default is 0.

public double PathStartOffset { get; set; }

Property value

double

Rotation

SceneText.cs

Gets or sets the rotation of the text around its anchor, in degrees, clockwise.

public double Rotation { get; set; }

Property value

double

Gets the parts of the text that have their own styles, or an empty list when the whole text has the style of the text. SceneText.Text is the text of the spans, one after the other.

public IReadOnlyList<SceneTextSpan> Spans { get; }

Gets or sets how the outline of the glyphs is painted, or null (the default) for no outline.

public ScenePaint? Stroke { get; set; }

Property value

ScenePaint?

Remarks

The outline is centered on the edges of the glyphs: it covers half its width of the fill, unless SceneText.PaintOrder paints it first.

StrokeDashArray

SceneText.cs

Gets or sets the lengths of the dashes and gaps of the outline of the glyphs, or null for a solid outline.

public IReadOnlyList<double>? StrokeDashArray { get; set; }

StrokeDashOffset

SceneText.cs

Gets or sets the distance into SceneText.StrokeDashArray at which the dashes of the outline start. A negative distance starts before the pattern, and a value that is not finite is 0.

public double StrokeDashOffset { get; set; }

Property value

double

StrokeWidth

SceneText.cs

Gets or sets the width of the outline of the glyphs. The default is 1.

public double StrokeWidth { get; set; }

Property value

double

Gets the text.

public string Text { get; }

Property value

string

TextLength

SceneText.cs

Gets or sets the advance the text is stretched or compressed to, in pixels, as the SVG textLength attribute, or null (the default) for the natural advance of its glyphs.

public double? TextLength { get; set; }

Property value

double?

Remarks

The length is the sum of the advances of all the spans, without their shifts (SceneTextSpan.Dx): with SceneTextLengthAdjust.Spacing, the difference is spread over the gaps between the grapheme clusters (none after the last one); with SceneTextLengthAdjust.SpacingAndGlyphs, every span is scaled horizontally from its start. Each text chunk (see SceneTextSpan.X) is then anchored with its new advance. On a path, the glyphs are not scaled: the spacing changes. A value that is negative or not finite is ignored, as SVG ignores it.

WordSpacing

SceneText.cs

Gets or sets the space added to each space (U+0020 and U+00A0), in pixels, as the CSS word-spacing; negative to tighten. The default is 0.

public double WordSpacing { get; set; }

Property value

double

Remarks

A value that is not finite is 0.

Gets the x coordinate of the anchor.

public double X { get; }

Property value

double

Gets the y coordinate of the baseline.

public double Y { get; }

Property value

double