Resolution of recording surface
Bernhard R. Fischer
bf at abenteuerland.at
Sat Dec 14 09:34:54 UTC 2024
Dear list,
It has been a long time since I posted here for the last time. Sorry for
the long text but it's to so easy to explain.
I'm using Cairographics extensively for an OSM data rendering software
since many years (https://github.com/rahra/smrender), so I'm not new to it.
What I regularly do is to use a recording surface internally and finally
paint it to a PDF, SVG, or whatever surface is required.
In respect to the units I always assumed that 1 unit within the
recording surface is to be 1 millimeter in the final result. To
accomplish this I create the recording surface with the size of the
final page (e.g. create_recording_surface(210, 297) for an A4 page have
210x297mm), then I draw on it and finally at the cairo_paint to the PDF
surface I scale the paint operation to meet the points unit of the PDF.
This concept works fine but unfortunately recently within a different
project (where I use the same drawing concept) I made the discovery that
the resolution of the recording surface seems to be limited at least
with the toy text API. I use the get_text_extents and similar functions
to place some text at specific positions and with some debugging I found
out that it does not use any fractional part of the extents member
variables.
E.g. the text_extents.width always returns e.g. 3.0, 4.0, 8.0, but never
something like 3.17, 4.28 and so on. The final result is that the text
(obviously) is not placed on exact positions (where it should be).
With further experiments I found out that if I make the recording
surface width/height e.g. 100 times bigger (21000x29700) and then scale
it by factor 100 the text_extents will work with higher resolution as
expected. But if I further increase the recording surface to a factor of
e.g. 1000, it will internally hang somewhere within an endless loop
(within libcairo). So there seems to be some upper limit.
So my question is: is there a limit in the resolution of the recording
surface? Or is this a limitation of the toy text API? Or did I stumble
on something else? Or is my drawing concept somehow incorrect?
Best regards,
Bernhard
More information about the cairo
mailing list