public ShapedTextCharacters(ShapedBuffer shapedBuffer, TextRunProperties properties) { ShapedBuffer = shapedBuffer; Text = shapedBuffer.Text; Properties = properties; TextSourceLength = Text.Length; FontMetrics = new FontMetrics(properties.Typeface, properties.FontRenderingEmSize); }
/// <summary> /// Splits the <see cref="TextRun"/> at specified length. /// </summary> /// <param name="length">The length.</param> /// <returns>The split result.</returns> internal SplitResult <ShapedBuffer> Split(int length) { if (Text.Length == length) { return(new SplitResult <ShapedBuffer>(this, null)); } var glyphCount = FindGlyphIndex(Text.Start + length); var first = new ShapedBuffer(Text.Take(length), GlyphInfos.Take(glyphCount), GlyphTypeface, FontRenderingEmSize, BidiLevel); var second = new ShapedBuffer(Text.Skip(length), GlyphInfos.Skip(glyphCount), GlyphTypeface, FontRenderingEmSize, BidiLevel); return(new SplitResult <ShapedBuffer>(first, second)); }
/// <summary> /// Creates an empty text line. /// </summary> /// <returns>The empty text line.</returns> public static TextLineImpl CreateEmptyTextLine(int firstTextSourceIndex, double paragraphWidth, TextParagraphProperties paragraphProperties) { var flowDirection = paragraphProperties.FlowDirection; var properties = paragraphProperties.DefaultTextRunProperties; var glyphTypeface = properties.Typeface.GlyphTypeface; var text = new ReadOnlySlice <char>(s_empty, firstTextSourceIndex, 1); var glyph = glyphTypeface.GetGlyph(s_empty[0]); var glyphInfos = new[] { new GlyphInfo(glyph, firstTextSourceIndex) }; var shapedBuffer = new ShapedBuffer(text, glyphInfos, glyphTypeface, properties.FontRenderingEmSize, (sbyte)flowDirection); var textRuns = new List <DrawableTextRun> { new ShapedTextCharacters(shapedBuffer, properties) }; return(new TextLineImpl(textRuns, firstTextSourceIndex, 0, paragraphWidth, paragraphProperties, flowDirection).FinalizeLine()); }