TextFlag WordWrap

book_4_sparkGenerated
code_blocksInput

Description

The WordWrap field is a member of the TextFlag enumeration in the Sandbox namespace. It is used to specify that text should automatically wrap to the next line when it reaches the end of its container's width. This is particularly useful in scenarios where text needs to fit within a constrained space without being cut off or overflowing.

Usage

Use the WordWrap flag when you want text to automatically wrap within its container. This can be combined with other TextFlag values to achieve the desired text alignment and wrapping behavior. Be cautious when combining flags, as conflicting values may lead to undefined behavior.

Example

// Example of using TextFlag.WordWrap
Graphics.DrawText("This is a long text that needs to wrap.", new Vector2(100, 100), TextFlag.WordWrap | TextFlag.Left);

// This will draw the text starting at position (100, 100) and will wrap the text within the container's width.