in ui/src/com/jediterm/terminal/ui/TerminalPanel.java [1366:1409]
private void drawChars(int x, int y, @NotNull CharBuffer buf, @NotNull TextStyle style, @NotNull Graphics2D gfx) {
// workaround to fix Swing bad rendering of bold special chars on Linux
// TODO required for italic?
CharBuffer renderingBuffer;
if (mySettingsProvider.DECCompatibilityMode() && style.hasOption(TextStyle.Option.BOLD)) {
renderingBuffer = CharUtils.heavyDecCompatibleBuffer(buf);
} else {
renderingBuffer = buf;
}
BreakIterator iterator = BreakIterator.getCharacterInstance();
char[] text = renderingBuffer.clone().getBuf();
iterator.setText(new String(text));
int endOffset;
int startOffset = 0;
while ((endOffset = iterator.next()) != BreakIterator.DONE) {
endOffset = extendEndOffset(text, iterator, startOffset, endOffset);
int effectiveEndOffset = shiftDwcToEnd(text, startOffset, endOffset);
if (effectiveEndOffset == startOffset) {
startOffset = endOffset;
continue; // nothing to draw
}
Font font = getFontToDisplay(text, startOffset, effectiveEndOffset, style);
gfx.setFont(font);
int descent = gfx.getFontMetrics(font).getDescent();
int baseLine = (y + 1) * myCharSize.height - mySpaceBetweenLines / 2 - descent;
int charWidth = myCharSize.width;
int xCoord = (x + startOffset) * charWidth + getInsetX();
int yCoord = y * myCharSize.height + mySpaceBetweenLines / 2;
gfx.setClip(xCoord, yCoord, getWidth() - xCoord, getHeight() - yCoord);
int emptyCells = endOffset - startOffset;
if (emptyCells >= 2) {
int drawnWidth = gfx.getFontMetrics(font).charsWidth(text, startOffset, effectiveEndOffset - startOffset);
int emptySpace = Math.max(0, emptyCells * charWidth - drawnWidth);
// paint a Unicode symbol closer to the center
xCoord += emptySpace / 2;
}
gfx.drawChars(text, startOffset, effectiveEndOffset - startOffset, xCoord, baseLine);
startOffset = endOffset;
}
gfx.setClip(null);
}