Leading support
This commit is contained in:
Родитель
a2733e43ba
Коммит
3434f1d173
|
@ -128,6 +128,12 @@ namespace Topten.RichTextKit
|
|||
public float Descent;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The leading of the font used in this run
|
||||
/// </summary>
|
||||
public float Leading;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The height of text in this run (ascent + descent)
|
||||
/// </summary>
|
||||
|
@ -136,7 +142,7 @@ namespace Topten.RichTextKit
|
|||
/// <summary>
|
||||
/// Calculate the half leading height for text in this run
|
||||
/// </summary>
|
||||
public float HalfLeading => (TextHeight * Style.LineHeight - TextHeight) / 2;
|
||||
public float HalfLeading => (TextHeight * (Style.LineHeight - 1) + Leading) / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Width of this typeface run
|
||||
|
@ -337,6 +343,7 @@ namespace Topten.RichTextKit
|
|||
newRun.Direction = this.Direction;
|
||||
newRun.Ascent = this.Ascent;
|
||||
newRun.Descent = this.Descent;
|
||||
newRun.Leading = this.Leading;
|
||||
newRun.Style = this.Style;
|
||||
newRun.Typeface = this.Typeface;
|
||||
newRun.Start = splitAtCodePoint;
|
||||
|
@ -408,6 +415,7 @@ namespace Topten.RichTextKit
|
|||
newRun.Direction = this.Direction;
|
||||
newRun.Ascent = this.Ascent;
|
||||
newRun.Descent = this.Descent;
|
||||
newRun.Leading = this.Leading;
|
||||
newRun.Style = this.Style;
|
||||
newRun.Typeface = this.Typeface;
|
||||
newRun.Start = splitAtCodePoint;
|
||||
|
|
|
@ -1302,6 +1302,7 @@ namespace Topten.RichTextKit
|
|||
fontRun.Clusters = shaped.Clusters;
|
||||
fontRun.Ascent = shaped.Ascent;
|
||||
fontRun.Descent = shaped.Descent;
|
||||
fontRun.Leading = shaped.Leading;
|
||||
fontRun.Width = shaped.EndXCoord.X;
|
||||
return fontRun;
|
||||
}
|
||||
|
|
|
@ -190,6 +190,11 @@ namespace Topten.RichTextKit
|
|||
/// </summary>
|
||||
public float Descent;
|
||||
|
||||
/// <summary>
|
||||
/// The leading of the font
|
||||
/// </summary>
|
||||
public float Leading;
|
||||
|
||||
/// <summary>
|
||||
/// The XMin for the font
|
||||
/// </summary>
|
||||
|
@ -247,11 +252,8 @@ namespace Topten.RichTextKit
|
|||
|
||||
// Also return the end cursor position
|
||||
r.EndXCoord = new SKPoint(xCoord * glyphScale, 0);
|
||||
|
||||
// And some other useful metrics
|
||||
r.Ascent = _fontMetrics.Ascent * style.FontSize / overScale;
|
||||
r.Descent = _fontMetrics.Descent * style.FontSize / overScale;
|
||||
r.XMin = _fontMetrics.XMin * style.FontSize / overScale;
|
||||
|
||||
ApplyFontMetrics(ref r, style.FontSize);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -467,15 +469,22 @@ namespace Topten.RichTextKit
|
|||
r.EndXCoord = new SKPoint(cursorX, cursorY);
|
||||
|
||||
// And some other useful metrics
|
||||
r.Ascent = _fontMetrics.Ascent * style.FontSize / overScale;
|
||||
r.Descent = _fontMetrics.Descent * style.FontSize / overScale;
|
||||
r.XMin = _fontMetrics.XMin * style.FontSize / overScale;
|
||||
ApplyFontMetrics(ref r, style.FontSize);
|
||||
|
||||
// Done
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyFontMetrics(ref Result result, float fontSize)
|
||||
{
|
||||
// And some other useful metrics
|
||||
result.Ascent = _fontMetrics.Ascent * fontSize / overScale;
|
||||
result.Descent = _fontMetrics.Descent * fontSize / overScale;
|
||||
result.Leading = _fontMetrics.Leading * fontSize / overScale;
|
||||
result.XMin = _fontMetrics.XMin * fontSize / overScale;
|
||||
}
|
||||
|
||||
private static Blob GetHarfBuzzBlob(SKStreamAsset asset)
|
||||
{
|
||||
if (asset == null)
|
||||
|
|
Загрузка…
Ссылка в новой задаче