private static int findWordWrapPosition(FieldElement element, int width) {

		String text = element.getText();
		int wrapPosition = element.getMaxCharactersForWidth(width);
		if (wrapPosition == element.length() || wrapPosition == 0) {
			return 0;
		}

		// inclusive
		int whiteSpacePosition = text.lastIndexOf(" ", wrapPosition - 1);
		if (whiteSpacePosition >= 0) {
			return whiteSpacePosition + 1; // exclusive
		}

		return wrapPosition;
	}
Finds the position within the given element at which to split the line for word wrapping.
This method finds the last whitespace character that completely fits within the given width.
If there is no whitespace character before the width break point, it finds the first
whitespace character after the width.  If no whitespace can be found, then 0 will be returned
to signal that there is no spot to break the line.

@param element the element to split
@param width the max width to allow before looking for a word wrap positions
@return 0 if the element cannot be split, else the character position of the string
to be split, exclusive
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldUtils.java