public static void Draw(Cairo.Context ctx, object backend, double x, double y) { var la = (LayoutBackend)backend; var text = la.Text; var h = ctx.FontExtents.Ascent; y += h; ctx.MoveTo(x, y); if (la.Font != null) { ctx.SelectFont(la.Font); ctx.SetFontSize(la.Font.Size); } if (la.Width == -1) { ctx.ShowText(text); return; } if (!la.Measured) { Measure(backend); } // Render word by word int lastStart = 0; for (int i = 0; i < la.LineBreaks.Count; i++) { if (la.Heigth != -1 && h > la.Heigth) { break; } var n = la.LineBreaks [i]; string s = text.Substring(lastStart, n - lastStart).TrimEnd('\n', '\r'); ctx.ShowText(s); var lh = la.LineHeights [i]; h += lh; y += lh; ctx.MoveTo(x, y); lastStart = n; } }