Minor improvements to ellipsis handling when MaxLines set

This commit is contained in:
Brad Robinson 2021-07-15 14:26:50 +10:00
Родитель 112c71526e
Коммит 7f47ae82ef
4 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -12,7 +12,7 @@ namespace SandboxDriver
}
public int ContentModeCount = 14;
public int ContentMode = 13;
public int ContentMode = 0;
public TextDirection BaseDirection = TextDirection.LTR;
public TextAlignment TextAlignment = TextAlignment.Auto;
public float Scale = 1.0f;
@ -20,7 +20,10 @@ namespace SandboxDriver
public bool UseMaxHeight = false;
public bool ShowMeasuredSize = false;
TextBlock _textBlock = new TextBlock();
TextBlock _textBlock = new TextBlock()
{
//MaxLines = 2
};
public void Render(SKCanvas canvas, float canvasWidth, float canvasHeight)
{

Просмотреть файл

@ -105,6 +105,9 @@ namespace Topten.RichTextKit
/// <returns>The x-coord relative to the entire text block</returns>
public float GetXCoordOfCodePointIndex(int codePointIndex)
{
if (this.RunKind == FontRunKind.Ellipsis)
codePointIndex = 0;
// Check in range
if (codePointIndex < Start || codePointIndex > End)
throw new ArgumentOutOfRangeException(nameof(codePointIndex));

Просмотреть файл

@ -1390,8 +1390,8 @@ namespace Topten.RichTextKit
}
// If there wasn't a line break anywhere in the line, then we need to force one
// on a character boundary
if (frSplitIndex < 0)
// on a character boundary. Also do this is we know we're on the last available line.
if (frSplitIndex < 0 || (_maxLines.HasValue && _lines.Count == _maxLines.Value - 1))
{
// Get the last run that partially fitted
frIndex = frIndexStartOfLine;
@ -1930,7 +1930,7 @@ namespace Topten.RichTextKit
if (!postLayout)
{
_fontRuns.Insert(_fontRuns.IndexOf(fr) + 1, remaining);
_fontRuns.Remove(fr);
// _fontRuns.Remove(fr);
}
}

Просмотреть файл

@ -17,10 +17,6 @@
<Description>Easy to use rich text rendering for SkiaSharp, including font-fallback, bi-directional text support and more...</Description>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="2.80.2" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.80.2" />