Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] TextLayout and GC advanced graphics on Windows (GDI+) buggy?

Hi all,

I am writing an SWT/JFace application involving styled text editing. It is based around a modified StyledText widget that supports page layout.

Now I want to add support for zooming the text. The StyledText widget may display hundreds of pages of text. The initial layout process is expensive and may take several seconds. After that, SpacedTextLayouts are cached as needed.

Zooming the text shall be very fast, for example in response to the widget becoming wider. The actual text layout (i.e. how words wrap) does not change because of zooming. That means I can't have the whole layout redone when the zoom changes.

I thought it would be a good idea to set a Transform on the GC used for drawing. On GTK, I am having trouble with the selection rendering. It simply stops working, even when an identity transform is set. On MacOS X, everything works correctly. Both GTK and MacOS versions show some expected bugs due to incorrect rounding on my part.

On Windows however, everything is completely garbled. Text is rendered at completely unexpected offsets, weirdly clipped, and even some unrelated parts of the widget suddenly appear at completely wrong places, even when those are drawn at totally different places in the code and even though I restore all previous settings of the GC (like setTransform(null) + setAdvanced(false)). I have tried to google for problems in this area. All I could find is that some bugs did exist for this use-case and that they have been fixed.

When digging into the code for TextLayout on Windows, I see that it has two pretty much separate code paths for when GDI+ is used versus not. Has this simply not been tested for a while and nobody noticed?

Are there any other ideas or recommendations for implementing the zooming without relayouting all the text?

Best regards,
-Stephan


Back to the top