Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't text anti-aliasing working, while using a SWT GC to draw text?
    text
    copied!<p>Right now my goal is to have anti-aliased text on my Labels. If my research was correct, SWT Labels do not natively support anti-aliasing on text, so my current workaround attempt is to create an image, turn text anti-aliasing on, draw my text to that image, then give that image to the Label.</p> <p>My current image drawing code is as follows:</p> <pre><code>Image image = new Image(Display.getDefault(), width, height); GC gc = new GC(image); gc.setAntialias(SWT.ON); gc.setTextAntialias(SWT.ON); gc.setBackground(background); gc.fillRectangle(0, 0, width, height); gc.setFont(font); gc.setForeground(foreground); int yPos = offset.y; for (String rawLine : lines) { String line = rawLine.trim(); Point lineSize = gc.textExtent(line); int xPos = offset.x; switch (alignment) { case SWT.RIGHT: xPos += width - lineSize.x; break; case SWT.CENTER: xPos += width / 2 - lineSize.x / 2; break; case SWT.LEFT: default: xPos += 0; } gc.drawText(line, xPos, yPos, true); yPos += lineSize.y; } gc.dispose(); return image; </code></pre> <p>I have had inconsistent results on two different computers: At work, the text in the resulting images appears as choppy as ever- as if text anti-aliasing wasn't even on. But at home, connected to my work computer via remote desktop, I saw exactly the results I wanted.</p> <p>Obviously I'd like things to work correctly on both computers, but I am currently stumped as to why they aren't. Each computer is running Windows 7, Eclipse v3.6.</p> <p>What could be the problem that is causing this inconsistency? And if my workaround is just absurd and I am completely missing an easier way, what is that way? Thank you for any help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload