Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346915 - drawText() behaves incorrectly after initCairo() is invoked.
Summary: drawText() behaves incorrectly after initCairo() is invoked.
Status: CLOSED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-23 18:31 EDT by Dan Bourque CLA
Modified: 2016-04-11 11:26 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Bourque CLA 2011-05-23 18:31:03 EDT
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...
}
Comment 1 Felipe Heidrich CLA 2011-05-27 12:12:54 EDT
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.
Comment 2 Alexander Kurtakov CLA 2016-04-11 11:26:32 EDT
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.