Enum VerticalAlign
Where DrawText(string, RectF, ParagraphStyle, VerticalAlign) puts a paragraph across its lines, in a rectangle taller (or, for vertical lines, wider) than the lines.
public enum VerticalAlign
Fields
Bottom = 2At the end of the block: the bottom, or the far side for vertical lines.
Center = 1In the middle.
Top = 0At the start of the block: the top, or for vertical lines the right side (VerticalRl) or the left (VerticalLr).
Examples
ParagraphStyle style = new()
{
DefaultStyle = new TextStyle
{
FontFamilies = [family],
Size = 18,
Color = new Rgba8(30, 30, 60, 255),
Shadows = [new TextShadow(new System.Numerics.Vector2(1, 1), 2, new Rgba8(0, 0, 0, 80))],
},
Align = TextAlign.Justify,
};
// One call: wrap into a box, centred across the lines.
TextLayout boxed = canvas.DrawText("Paragraphs wrap, justify and drop shadows.", new RectF(10, 10, 300, 80), style, VerticalAlign.Center);
// Or lay out once and draw where needed, skipping lines outside the visible part.
TextLayout layout = Paragraph.Create("Laid out once, drawn many times.", style).Layout(300);
canvas.DrawTextLayout(layout, new System.Numerics.Vector2(10, 110), visibleRect: new RectF(0, 0, 320, 200));
// Inline placeholders (an icon, a badge) are drawn by a painter called with each one's box.
canvas.DrawTextLayout(layout, new System.Numerics.Vector2(10, 130), placeholderPainter: (c, index, box) => c.FillRoundRect(new RoundRect(box, 3), new Rgba8(200, 60, 40, 255)));
// The same text as one path: glyphs and decorations.
Egami.Drawing.Path outline = layout.ToPath(new System.Numerics.Vector2(10, 150));