EditorCustomElementRenderer (final String suffix) { return new EditorCustomElementRenderer() { @Override public int calcWidthInPixels(@NotNull Inlay inlay) { Editor editor = inlay.getEditor(); return editor.getContentComponent().getFontMetrics(getFont(editor)).stringWidth(suffix); } @Override public void paint(@NotNull Inlay inlay, @NotNull Graphics g, @NotNull Rectangle r, @NotNull TextAttributes textAttributes) { Editor editor = inlay.getEditor(); g.setColor(JBColor.GRAY); g.setFont(getFont(editor)); g.drawString(suffix, r.x, r.y + editor.getAscent()); } private static Font getFont(@NotNull Editor editor) { return editor.getColorsScheme().getFont(EditorFontType.PLAIN); } }; }