[cairo] How to get extents of transformed graphics

Andreas Falkenhahn andreas at falkenhahn.com
Fri Sep 9 19:09:32 UTC 2022


On 09.09.2022 at 20:55 Michal Sudolsky wrote:

> It looks like more than just one row. Also there is a lot of free
> space above "C".

Yes, I've seen that as well but I don't understand where that comes from. I'm translating the shape by -y1 so that should remove all blank space from the top, shouldn't it?

> Did you try it without that scaling factor 4.6 for
> example 1.0? Would it work well with that?

Absolutely. I've just tested it with 1.0 instead of 4.6 and it works flawlessly in that case. Nothing is cut off.

> Also why to complicate
> everything with that for loop and mutate various variables? It seems
> that it unnecessarily complicates the whole logic and could hide the
> source of the problem. 

I apologize, the example was quickly thrown together but I still think it's just a few lines and very readable so I don't really think that the for loop and variable mutation hides the source of the problem. It's just very few lines, after all.

> It is also possible that cairo will do some
> pixel rounding when placing text to a position that is not a whole
> number in pixels or maybe it could do it with text size so actual
> text size could scale slightly nonlinearly.

Yes, that sounds plausible but then the question remains: How to compute the *exact* extents of the shape Cairo is going to draw? Is that even possible?

-- 
Best regards,
 Andreas Falkenhahn                            mailto:andreas at falkenhahn.com



More information about the cairo mailing list