private TextShaperLine createLine(String currentText, LineBreakMeasurer measurer) {

		// nextOffset() finds the end of the text that fits into the max width
		int position = measurer.getPosition();
		int wrappingWidth = displaySize.width;
		int nextEnd = measurer.nextOffset(wrappingWidth);

		// special case: look for newlines in the current line and split the text on that 
		// newline instead so that user-requested newlines are painted
		int limit = updateLimitForNewline(currentText, position, nextEnd);

		TextShaperLine line = null;
		if (limit == 0) {
			// A limit of 0 implies the first character of the text is a newline.  Add a full blank
			// line to handle that case.  This can happen with consecutive newlines or if a line
			// happened to break with a leading newline.
			Font font = g2d.getFont();
			FontRenderContext frc = g2d.getFontRenderContext();
			LineMetrics lm = font.getLineMetrics("W", frc);
			line = new BlankLine(lm.getHeight());

			// advance the measurer to move past the single newline
			measurer.nextLayout(wrappingWidth, position + 1, false);
		}
		else {
			// create a layout with the given limit (either restricted by width or by a newline)
			TextLayout layout = measurer.nextLayout(wrappingWidth, position + limit, false);
			int nextPosition = measurer.getPosition();
			String lineText = currentText.substring(position, nextPosition);
			line = new TextLayoutLine(lineText, layout);
		}

		// If we limited the current line to break on the newline, then move past that newline so it
		// is not in the next line we process.  Since we have broken the line already, we do not 
		// need that newline character.
		movePastTrailingNewline(currentText, measurer);

		return line;
	}
Creates a text shaper with the given text, display size and graphics context.
@param text the text
@param displaySize the size
@param g2d the graphics
Ghidra/Framework/Docking/src/main/java/docking/util/TextShaper.java