CanvasShapedText Class
- Experimental (WEBPLATEXP0025)
A text shaped by CanvasRenderingContext2DBase.ShapeText with the font, the text styles, the direction, the alignment and the baseline of the context: its glyph runs and clusters, the caret positions and the selection rectangles. The distances are in CSS px, relative to the alignment point and to the baseline of the text.
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public sealed class CanvasShapedTextProperties
| Name | Description |
|---|---|
| Width | Gets the advance width of the text. |
Gets the advance width of the text.
public double Width { get; }Methods
| Name | Description |
|---|---|
| ActualBoundingBox(uint, uint) | Returns the bounding box of the glyphs of a range of the text: see TextMetrics.GetActualBoundingBox. |
| AdvanceToPosition(double) | Returns the index (in UTF-16 code units) of the caret position closest to a horizontal offset from the alignment point: see TextMetrics.GetIndexFromOffset. |
| GlyphClusters() | Returns the clusters of the text, in logical order, as glyph runs: its grapheme clusters, merged when a glyph spans several of them. |
| GlyphClusters(uint, uint) | Returns the clusters of the text that have characters in a range, in logical order, as glyph runs. |
| GlyphRuns() | Returns the glyph runs of the text, from left to right: the glyphs of a bidi run with the same font. |
| PositionToAdvance(uint) | Returns the horizontal offset from the alignment point of the caret position before a character (or at the end of the text). |
| SelectionRects(uint, uint) | Returns the rectangles of the selection of a range of the text: see TextMetrics.GetSelectionRects. |
ActualBoundingBox(uint, uint)
CanvasRenderingContext2DBase.TextClusters.csReturns the bounding box of the glyphs of a range of the text: see TextMetrics.GetActualBoundingBox.
public DomRectReadOnly ActualBoundingBox(uint start, uint end)Parameters
startuint- The index (in UTF-16 code units) of the start of the range.
enduint- The index (in UTF-16 code units) of the end of the range.
Returns
Exceptions
DomException- An
IndexSizeErrorwhen the start is not the index of a character, or the end is after the end of the text.
See also
AdvanceToPosition(double)
CanvasRenderingContext2DBase.TextClusters.csReturns the index (in UTF-16 code units) of the caret position closest to a horizontal offset from the alignment point: see TextMetrics.GetIndexFromOffset.
GlyphClusters overloads
GlyphClusters()
CanvasRenderingContext2DBase.TextClusters.csReturns the clusters of the text, in logical order, as glyph runs: its grapheme clusters, merged when a glyph spans several of them.
public IReadOnlyList<CanvasGlyphRun> GlyphClusters()GlyphClusters(uint, uint)
CanvasRenderingContext2DBase.TextClusters.csReturns the clusters of the text that have characters in a range, in logical order, as glyph runs.
public IReadOnlyList<CanvasGlyphRun> GlyphClusters(uint start, uint end)Parameters
startuint- The index (in UTF-16 code units) of the start of the range.
enduint- The index (in UTF-16 code units) of the end of the range.
Returns
Exceptions
DomException- An
IndexSizeErrorwhen the start is not the index of a character, or the end is after the end of the text.
See also
GlyphRuns()
CanvasRenderingContext2DBase.TextClusters.csReturns the glyph runs of the text, from left to right: the glyphs of a bidi run with the same font.
public IReadOnlyList<CanvasGlyphRun> GlyphRuns()PositionToAdvance(uint)
CanvasRenderingContext2DBase.TextClusters.csReturns the horizontal offset from the alignment point of the caret position before a character (or at the end of the text).
Parameters
positionuint- The index (in UTF-16 code units) of the caret position.
Returns
Exceptions
DomException- An
IndexSizeErrorwhen the index is after the end of the text.
See also
SelectionRects(uint, uint)
CanvasRenderingContext2DBase.TextClusters.csReturns the rectangles of the selection of a range of the text: see TextMetrics.GetSelectionRects.
public IReadOnlyList<DomRectReadOnly> SelectionRects(uint start, uint end)Parameters
startuint- The index (in UTF-16 code units) of the start of the range.
enduint- The index (in UTF-16 code units) of the end of the range.
Returns
IReadOnlyList<DomRectReadOnly>
Exceptions
DomException- An
IndexSizeErrorwhen an index is after the end of the text.