using System.Diagnostics; using Avalonia.Utilities; namespace Avalonia.Media.TextFormatting { /// /// Represents a portion of a object. /// [DebuggerTypeProxy(typeof(TextRunDebuggerProxy))] public abstract class TextRun { public static readonly int DefaultTextSourceLength = 1; /// /// Gets the text source length. /// public virtual int TextSourceLength => DefaultTextSourceLength; /// /// Gets the text run's text. /// public virtual ReadOnlySlice Text => default; /// /// A set of properties shared by every characters in the run /// public virtual TextRunProperties Properties => null; private class TextRunDebuggerProxy { private readonly TextRun _textRun; public TextRunDebuggerProxy(TextRun textRun) { _textRun = textRun; } public string Text { get { unsafe { fixed (char* charsPtr = _textRun.Text.Buffer.Span) { return new string(charsPtr, 0, _textRun.Text.Length); } } } } public TextRunProperties Properties => _textRun.Properties; } } }