From bf at abenteuerland.at Wed Jan 15 19:24:30 2025 From: bf at abenteuerland.at (Bernhard R. Fischer) Date: Wed, 15 Jan 2025 20:24:30 +0100 Subject: Resolution of recording surface In-Reply-To: <97288b42-0ed8-4886-aa14-0ad1580fb3ec@beexy.nl> References: <3d27ec92-00b6-4cc3-9ccc-438a97b55825@abenteuerland.at> <97288b42-0ed8-4886-aa14-0ad1580fb3ec@beexy.nl> Message-ID: <749076b4-bec7-4caf-93d4-ad1f98d02252@abenteuerland.at> Hi! Thanks for your hint. It solved the problem! I set the the font options to CAIRO_HINT_METRICS_OFF with cairo_font_options_set_hint_metrics(fo, CAIRO_HINT_METRICS_OFF); Thank you very much! Best regards, Bernhard On 15.12.2024 19:45, Theo Veenker wrote: > Hi Bernhard, > > Could it be it is caused by font hinting? Maybe try playing with the > hint style (see font options). Just a wild guess. > > Theo > > On 14/12/2024 10:34, Bernhard R. Fischer wrote: >> 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 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: