Community
Participate
Working Groups
Build Identifier: 20110301-1815 I added a custom PaintListener to a Canvas, and in the paintControl() method, I call drawText() on a string that contains carriage returns, and everything seems fine. However, I then call drawPath(), which calls initCairo(). After that point, all calls to drawText() will not process carriage returns. This is because in GC.java, at line 1621, the data.cairo will no longer be 0, and the if statement causes Cairo.cairo_show_text() to be used (which doesn't perform carriage return processing, another bug) instead of OS.gdk_draw_layout_with_colors(), which does. I believe initCairo() should be called from drawText() so that all calls are consistent, but more importantly, Cairo.cairo_show_text() should perform carriage return processing. Reproducible: Always Steps to Reproduce: Add a custom PaintListener to a Canvas, and in paintControl(), do: public void paintControl( PaintEvent event ){ String text = "Line1\nLine2"; event.gc.drawText( text, 0, 0, true ); // This will appear correctly... event.gc.drawPath( somePath ); event.gc.drawText( text, 0, 50, true ); // This will ignore the newline character... }
What version of GTK are you running ? This problem only happens to GTK older than 2.8, as cairo_show_text() does not handle line delimiters. On new version of GTK we use pango_cairo_show_layout() and line delimiters work fine.
No reply from reporter for almost 5 years to clarify which version of GTK he experienced the issue on. As per Felipe's comment closing the bug. If you still experience the issue on supported SWT version please reopen.