SceneText Class
A line of text, positioned by its baseline.
public sealed class SceneText : SceneElement- Inheritance
SceneElementSceneText
Constructors
| Name | Description |
|---|---|
| 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.csInitializes 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
xdouble- The x coordinate of the anchor.
ydouble- The y coordinate of the baseline.
spansIEnumerable<SceneTextSpan>- The parts of the text, drawn one after the other.
fontSceneFont- The font of the spans that set none.
colorSceneColor- The color of the spans that set none.
Exceptions
ArgumentExceptionspanscontainsnull.
SceneText(double, double, string, SceneFont, SceneColor)
SceneText.csA line of text, positioned by its baseline.
public SceneText(double x, double y, string text, SceneFont font, SceneColor color)Parameters
xdouble- The x coordinate of the anchor.
ydouble- The y coordinate of the baseline.
textstring- The text.
fontSceneFont- The size and the weight of the font.
colorSceneColor- The color of the text.
Properties
| Name | Description |
|---|---|
| Anchor | Gets or sets where the text is anchored horizontally. |
| Baseline | 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. |
| Color | Gets the color of the text. |
| DecorationFill | 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. |
| Decorations | 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. |
| Direction | Gets or sets the direction the text is written in, as the SVG direction property. The default is from left to right. |
| Fill | 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. |
| Font | Gets the size and the weight of the font. |
| LengthAdjust | Gets or sets how the text is fitted to SceneText.TextLength. The default changes the spacing only. |
| LetterSpacing | Gets or sets the space added after each character, in pixels, as the CSS letter-spacing; negative to tighten. The default is 0. |
| LineCap | Gets or sets the shape of the ends of the open outlines of the glyphs. |
| LineJoin | Gets or sets the shape of the corners of the outline of the glyphs. |
| MeasuredWidth | Gets or sets the advance width of the text, as the layout measured it. |
| MiterLimit | 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. |
| PaintOrder | 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. |
| Path | 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. |
| PathStartOffset | Gets or sets the distance along SceneText.Path at which the text is anchored, in pixels. The default is 0. |
| Rotation | Gets or sets the rotation of the text around its anchor, in degrees, clockwise. |
| Spans | 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. |
| Stroke | Gets or sets how the outline of the glyphs is painted, or null (the default) for no outline. |
| StrokeDashArray | Gets or sets the lengths of the dashes and gaps of the outline of the glyphs, or null for a solid outline. |
| StrokeDashOffset | 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. |
| StrokeWidth | Gets or sets the width of the outline of the glyphs. The default is 1. |
| Text | Gets the text. |
| TextLength | 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. |
| WordSpacing | 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. |
| X | Gets the x coordinate of the anchor. |
| Y | Gets the y coordinate of the baseline. |
Anchor
SceneText.csGets or sets where the text is anchored horizontally.
public SceneTextAnchor Anchor { get; set; }Property value
Baseline
SceneText.csGets 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
Color
SceneText.csDecorationFill
SceneText.csGets 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
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.csGets 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
Direction
SceneText.csGets 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
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.
Fill
SceneText.csGets 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
Remarks
To draw the outline of the glyphs only, set a SceneText.Stroke and a transparent fill.
Font
SceneText.csLengthAdjust
SceneText.csGets or sets how the text is fitted to SceneText.TextLength. The default changes the spacing only.
public SceneTextLengthAdjust LengthAdjust { get; set; }Property value
LetterSpacing
SceneText.csGets 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
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.
LineCap
SceneText.csGets or sets the shape of the ends of the open outlines of the glyphs.
public SceneLineCap LineCap { get; set; }Property value
LineJoin
SceneText.csGets or sets the shape of the corners of the outline of the glyphs.
public SceneLineJoin LineJoin { get; set; }Property value
MeasuredWidth
SceneText.csMiterLimit
SceneText.csGets 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
PaintOrder
SceneText.csGets 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
Path
SceneText.csGets 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
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.csGets 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
Rotation
SceneText.csSpans
SceneText.csGets 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; }Property value
Stroke
SceneText.csGets or sets how the outline of the glyphs is painted, or null (the default) for no outline.
public ScenePaint? Stroke { get; set; }Property value
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.csGets 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; }Property value
StrokeDashOffset
SceneText.csGets 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
StrokeWidth
SceneText.csText
SceneText.csTextLength
SceneText.csGets 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
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.