Eto Graphics.DrawText - Multiline?

Hello everyone,

I think this is a simple one hopefully… (famous last words right)

For long single line text such as names I have been truncating the text if it exceeds a certain character length but for multi-line text such as a description how can I ensure that the text wraps/creates a new line automatically/or stacks without getting hacky and splitting the text into segments, looping, and then drawing each segment at a different height…

Given a bit of code like this:

e.Graphics.DrawText(self.body_font, text_color, Eto.Drawing.PointF(0, 0), f"description: {self.description}")

How can I ensure that the text wraps if it exceeds a certain width or character length or alternatively is there a property I can set to have text “wrap” automatically on e.Graphics.DrawText?

I can’t find anything in the API docs for this method, I see wraptext for annotation base objects but nothing for the Eto DrawText

I found this but it seems overkill?

This is just for an OnPaint text display, I don’t need to interact with the text so I wasn’t planning to need to create a label or text box control.

Thanks for your help!

Okay… sorry I found it:

This has arguments for a rectangle bounds and wrapping method.

Updated Code:

# Create Text Formatting Variables        
self.text_rect = Eto.Drawing.Rectangle(0, 0, 300, 60)
self.text_brush = Eto.Drawing.SolidBrush(text_color)
self.text_wrap = Eto.Drawing.FormattedTextWrapMode.Word
e.Graphics.DrawText(self.body_font, self.text_brush, self.text_rect, self.description, self.text_wrap)