csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
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.
56 lines
1.6 KiB
56 lines
1.6 KiB
using System.Diagnostics;
|
|
|
|
namespace Avalonia.Media.TextFormatting
|
|
{
|
|
/// <summary>
|
|
/// Represents a portion of a <see cref="TextLine"/> object.
|
|
/// </summary>
|
|
[DebuggerTypeProxy(typeof(TextRunDebuggerProxy))]
|
|
public abstract class TextRun
|
|
{
|
|
public const int DefaultTextSourceLength = 1;
|
|
|
|
/// <summary>
|
|
/// Gets the text source length.
|
|
/// </summary>
|
|
public virtual int Length => DefaultTextSourceLength;
|
|
|
|
/// <summary>
|
|
/// Gets the text run's text.
|
|
/// </summary>
|
|
public virtual CharacterBufferReference CharacterBufferReference => 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
|
|
{
|
|
var characterBuffer = _textRun.CharacterBufferReference.CharacterBuffer;
|
|
|
|
fixed (char* charsPtr = characterBuffer.Span)
|
|
{
|
|
return new string(charsPtr, _textRun.CharacterBufferReference.OffsetToFirstChar, _textRun.Length);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public TextRunProperties? Properties => _textRun.Properties;
|
|
}
|
|
}
|
|
}
|
|
|