A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
1.5 KiB

using System.Diagnostics;
using Avalonia.Utilities;
namespace Avalonia.Media.TextFormatting
{
/// <summary>
/// Represents a portion of a <see cref="TextLine"/> object.
/// </summary>
[DebuggerTypeProxy(typeof(TextRunDebuggerProxy))]
public abstract class TextRun
{
public static readonly int DefaultTextSourceLength = 1;
/// <summary>
/// Gets the text source length.
/// </summary>
public virtual int TextSourceLength => DefaultTextSourceLength;
/// <summary>
/// Gets the text run's text.
/// </summary>
public virtual ReadOnlySlice<char> Text => default;
/// <summary>
/// A set of properties shared by every characters in the run
/// </summary>
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;
}
}
}