private TextFormatter out(String text, Color fg, Color bg, Color cursor) {
		Graphics2D g = image.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
			RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		g.setFont(font);
		metrics = g.getFontMetrics(font);
		int stringWidth = metrics.stringWidth(text);
		if (bg != null) {
			g.setColor(bg);
			g.fillRect(x, y + linePadding, stringWidth, lineHeight - 2 * linePadding);
		}

		g.setColor(fg);
		g.drawString(text, x, y + baselineOffset);

		if (cursor != null) {
			g.setColor(cursor);
			g.setStroke(new BasicStroke(2f));
			g.drawLine(x, y + linePadding, x, y + baselineOffset);
		}
		g.dispose();
		x += stringWidth;
		return this;
	}
Each line is sized based on the font height and line padding on the top and bottom of the line.
The y coordinate tracks the top of the line, so a lines baseline (position to draw the text) 
is y + line padding + font accent.
Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/TextFormatter.java