Skip to content

[Win32] Poor text anti-alias when advanced mode is enabled #3203

@ptziegler

Description

@ptziegler

Describe the bug
Drawing a string when advanced mode is enabled looks very rough.

To Reproduce

package test;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.AutoscalingMode;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TextAntiAlias {

	public static void main(String[] args) {
		Shell shell = new Shell();
		shell.setLayout(new FillLayout());
		shell.setSize(600, 200);
		
		FontData fd = shell.getFont().getFontData()[0];
		fd.height = 80;
		Font f = new Font(shell.getDisplay(),  fd);
		
		Composite c1 = new Composite(shell, SWT.NONE);
		c1.addPaintListener(event -> {
			GC gc = event.gc;
			gc.setAdvanced(true);
			gc.setFont(f);
			gc.drawString("Paper", 0, 0);
		});
		
		Composite c2 = new Composite(shell, SWT.NONE);
		c2.addPaintListener(event -> {
			GC gc = event.gc;
			gc.setFont(f);
			gc.drawString("Paper", 0, 0);
		});

		Display d = shell.getDisplay();
		shell.open();
		while(!shell.isDisposed()) {
			while(!d.readAndDispatch()) {
				d.sleep();
			}
		}
		
		f.dispose();
	}
}

Expected behavior

The GC should produce a crisp string, regardless of whether advanced mode is enabled. As an additional note: calling setTextAntialias(SWT.ON) causes both strings to look the like the left one. Meaning that explicitly enabling text-antialias leads to a worse result.

Screenshots

Image

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions