The common integration pattern is:
MeasureOverrideprivate PreparedTextWithSegments? _prepared;
void UpdateText(string text, string font)
{
_prepared = PretextLayout.PrepareWithSegments(text, font);
}
Size MeasureBubble(double maxWidth, double lineHeight, Thickness padding)
{
if (_prepared is null)
{
return Size.Empty;
}
var layout = PretextLayout.Layout(_prepared, maxWidth, lineHeight);
return new Size(maxWidth + padding.Left + padding.Right, layout.Height + padding.Top + padding.Bottom);
}
The Pretext.Uno package in this repository adds reusable helpers around the core engine:
StretchScrollHost for page-like scrollable samples and viewport calculationsUiRenderScheduler for coalesced redraw scheduling on DispatcherQueuePreparedTextMetrics for wrap metrics and tight-width calculationsColumnFlowLayout and ObstacleLayoutHelper for flowing lines into constrained regionsUse them when they match your layout model, but keep the core Pretext API as the main dependency.
SizeChanged or MeasureOverride passes.font string.Layout in measurement passes and LayoutWithLines or LayoutNextLine only when rendering needs richer output.For broader Uno renderer context, see How Uno Platform Works.