[cairo] Always keep text in foreground?
Daniel Goldman
dagoldman at yahoo.com
Mon Aug 16 10:07:11 PDT 2010
Thanks for the replies. I ended up reading the data file twice, stroking and
filling the polygons first pass, and applying the labels the second pass, as
shown in a simplified form by Arjen. It was somewhat inconvenient, but not a
big deal. I already knew that was a possible solution.
It's a big data file, which I would rather not read twice. But it's still fast
enough. It would even be possible to split the data file into two data files:
one with the points, the other with the labels. But I'll only do that if ever a
speed problem.
The reason I posted was to understand cairo better, to clarify if cairo has the
luxury of automatically keeping the text in the foreground. I appreciate
Benjamin explaining why this is not the case. I can live without the luxury.
Daniel
>
>If you code is like this:
>
>
>for (x = something with A and B)
>{
> my_draw_polygon(x);
> my_draw_label(x);
>}
>
>
>Change it to:
>
>
>for (x = something with A and B)
>{
> my_draw_polygon(x);
>}
>
>
>for (x = something with A and B)
>{
> my_draw_label(x);
>}
>
>
>Groeten, Arjen
>
>
>Hi,
>>
>>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 |
>>-----------------------
>> A 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,
>>etc.
>>
>>
>>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.
>>
>>
>>Thanks,
>>Daniel
>>--
>>cairo mailing list
>>cairo at cairographics.org
>>http://lists.cairographics.org/mailman/listinfo/cairo
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100816/50efb830/attachment-0001.htm>
More information about the cairo
mailing list