The core Pretext package does not depend on Uno or a specific renderer. In a generic SkiaSharp host, add Pretext.SkiaSharp so the engine can discover the first-party SkiaSharp measurement backend automatically.
dotnet add package Pretext
dotnet add package Pretext.SkiaSharp
If the same application also references native backends, call PretextLayout.SetTextMeasurerFactory(new SkiaSharpTextMeasurerFactory()) when the SkiaSharp backend should remain the source of truth.
using Pretext;
using SkiaSharp;
var prepared = PretextLayout.PrepareWithSegments(
"Hello soft\u00ADwrapped world",
"16px Inter");
var lines = PretextLayout.LayoutWithLines(prepared, maxWidth: 220, lineHeight: 22);
using var paint = new SKPaint
{
Typeface = SKTypeface.FromFamilyName("Inter"),
TextSize = 16,
IsAntialias = true
};
var y = 24f;
foreach (var line in lines.Lines)
{
canvas.DrawText(line.Text, 0, y, paint);
y += 22f;
}
Pretext gives you line text and widths, but your host still decides:
lineHeightUse LayoutNextLine instead of LayoutWithLines when:
SKCanvasView or SKGLView controls