Skip to content

Make Resources independent of scaling/zoom #3527

Description

@tmssngr

Currently, Resources like TextLayout or Font have a nativeZoom or zoom value set. This is inconsistent with recent SWT features on Windows of a) monitor-specific zoom (different shells might have different zoom factors) and b) some controls have disabled autoscaling. This causes serious rounding problem like reported in #3461 that can't be worked-around by the SWT user.

IMHO to avoid any zoom-related rounding errors it needs API change to define the Control or GC onto which these resources should work.

Example:

TextLayout textLayout = new TextLayout(gc); // <-- new constructor
textLayout.setFont(font);
textLayout.setText(text);
final Rectangle bounds = textLayout.getBounds();
textLayout.setWidth(bounds.width + widthCorrection);
textLayout.draw(gc, x, y);
textLayout.dispose();

or

TextLayout textLayout = new TextLayout(control); // <-- new constructor
textLayout.setFont(font);
textLayout.setText(text);
final Rectangle bounds = textLayout.getBounds();
textLayout.setWidth(bounds.width + widthCorrection);
textLayout.draw(gc, x, y);
textLayout.dispose();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions