Skip to content

Commit 71dce6f

Browse files
committed
fix: Draw terminal characters individually to prevent clipping with fractional DPI scaling
On Windows with fractional DPI scaling (125%, 150%), SWT/GDI accumulates sub-pixel rounding when drawing a whole string, causing glyphs to overflow their grid cells. Draw each character at its exact cell position instead.
1 parent a43ab52 commit 71dce6f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas

terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextLineRenderer.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,19 @@ private void drawText(GC gc, int x, int y, int colFirst, int col, String text) {
169169
}
170170
}
171171
} else {
172-
text = text.replace('\000', ' ');
173-
gc.drawString(text, x + offset, y, false);
172+
// Draw each character individually aligned to its grid cell.
173+
// Drawing a full string at once causes accumulated sub-pixel rounding
174+
// on Windows with fractional DPI scaling (e.g. 125%, 150%), making
175+
// characters appear wider than their grid cell and clipping the
176+
// rightmost 1-2 pixel columns of each glyph.
177+
int cellWidth = getCellWidth();
178+
for (int i = 0; i < text.length(); i++) {
179+
char c = text.charAt(i);
180+
if (c == '\000') {
181+
c = ' ';
182+
}
183+
gc.drawString(String.valueOf(c), x + offset + i * cellWidth, y, false);
184+
}
174185
}
175186
}
176187

0 commit comments

Comments
 (0)