please include function renderText. static BufferedImage renderText_multiLine(S fontName, float fontSize, S text) { ret renderText_multiLine(loadFont_cached(fontName), fontSize, text); } static BufferedImage renderText_multiLine(Font font, float fontSize, S text) { Color background = optPar(renderText_bg, Color.white); Color foreground = optPar(renderText_fg, Color.black); font = font.deriveFont(fontSize); L lines = toLines(text); // for font metrics BufferedImage dummyImg = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics g = antiAliasGraphics(dummyImg); g.setFont(font); FontMetrics fm = g.getFontMetrics(); int width = 0; for (S line : lines) width = max(width, fm.stringWidth(line)); if (width <= 0) null; int lineHeight = fm.getHeight(); int height = lineHeight*l(lines); int y = fm.getAscent(); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); g = antiAliasGraphics(img); g.setColor(background); g.fillRect(0, 0, width, height); g.setColor(foreground); g.setFont(font); for i over lines: g.drawString(lines.get(i), 0, lineHeight*i+y); g.dispose(); return img; }