Skip to content

Commit

Permalink
[win32] Scale up bounds as rectangle in canvas
Browse files Browse the repository at this point in the history
This commit adresses render artifacts visible in StyledText with
monitor-specific scaling enabled e.g. on 175%. Reason is that scaling
up all attributes of bounds separately can lead to rounding errors e.g.
between y and height (one being scaled up, the other one not). Scaling
them together as a rectangle solves this limitation.
  • Loading branch information
akoch-yatta committed Jan 24, 2025
1 parent 413426e commit a8d8084
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,8 @@ public Canvas (Composite parent, int style) {
*/
public void drawBackground (GC gc, int x, int y, int width, int height) {
int zoom = getZoom();
x = DPIUtil.scaleUp(x, zoom);
y = DPIUtil.scaleUp(y, zoom);
width = DPIUtil.scaleUp(width, zoom);
height = DPIUtil.scaleUp(height, zoom);
drawBackgroundInPixels(gc, x, y, width, height, 0, 0);
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, 0, 0);
}

/**
Expand Down

0 comments on commit a8d8084

Please sign in to comment.