[cairo] Always keep text in foreground?
dagoldman at yahoo.com
Sun Aug 15 18:06:20 PDT 2010
I make the path for polygon A, stroke it, fill with red, and apply "Long Label
A" using pango. Next, I stroke polygon B, fill with blue, and apply "Label B".
Everything is great, expect the polygon B fill overlaps and hides part of "Long
Label A" text.
| Long Label A |
| | Label B |
How do I always keep the text in the z-order foreground? I already know about
decreasing font size and making the labels appear on multiple lines to prevent
overlaps. I'm looking for something to use when overlap cannot be prevented. I
tried using alpha channel, so the label can show through, but I lose too much
intensity for both text and fill colors.
In other words, is there a way to tell cairo / pango "I want this text to always
be foreground", or "I want this fill to always be background".
If not, is it possible (or advisable) to write the polygons to one context (I
guess), write the text to another context (or whatever), and then overlay the
text over the polygons? If this is feasible, could someone sketch out the key
functions to use.
Perhaps I will end up doing all the polygons first, and then doing all the
labels. It's just inconvenient, since I get all the data for one polygon, its
label and the label positioning, then get all the data for the next polygon,
I'm not saying the default behavior (fill overlays previous text) is wrong. I'm
just hoping I can override it. I looked through the cairo and pango docs and
past postings and couldn't find the answer.
More information about the cairo