Cairomm/Pangomm transform confusion

Note: I see that most of the traffic on this list is for the C versions of these libraries, and I hope that the fact I'm using the C++ wrapped versions is not an issue. I believe the issue I face is language-independent. Please accept my apologies in advance if this is out of bounds.

I am using cairomm for a program that basically plots certain curves in XY space. My transform matrix in this app scales by a negative number on the Y axis. Nothing unusual here, and everything works as expected.

Now, I want to label various points on the curves (via the scaled coordinates) with text. I create a Pango::Layout, populate it with text, add its contents to the Cairo::Context, and call stroke().

Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

// ... plot the curves, etc. No problem.

cr->move_to(x, y);   // x,y are in user coordinates
Glib::RefPtr<Pango::Layout> pango = Pango::Layout::create(cr);

The text appears at the right place but upside-down. I assume this has to do with the negative scale factor in Cairo's transform matrix. But what I'm not clear on, specifically, is how to fix it. I've tried resetting and modifying the Cairo transform matrix at various points prior to and among the code above, but the text ends up rendering somewhere outside my window. Can anyone offer guidance here?

Maybe more generally: it seems to me that putting unscaled Pango text on a scaled Cairo context would be a fairly common thing to want to do. Can someone offer a general strategy for this, or a pointer to an example?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]