[cairo] font size change only in large steps

Alois Treindl alois at astro.ch
Fri Sep 28 12:13:39 UTC 2018


I send the same as pure text email:

We use cairo do draw and write on bitmap surfaces, or SVG, Postcript and 
pdf surfaces.

I noticed that cairo does not allow me to set a precise font size, like 
9.4 pt or 9.7 pt.
What I get is exactly the same font size, for a range of font sizes.

Example: I print the word Jupiter with font Arial in font sizes 10.7 pt 
down to 8.0 pt in steps of 0.1 pt.

I get
pt size    size in 1/00 mm    string length in 1/100 mm units
10.7 pts 377 cmm                 1588
10.6 pts 373 cmm                 1588
10.5 pts 370 cmm                 1588
10.4 pts 366 cmm                 1482
10.3 pts 363 cmm                 1482
10.2 pts 359 cmm                 1482
10.1 pts 356 cmm                 1482
10.0 pts 352 cmm                 1482
9.9 pts 349 cmm                 1482
9.8 pts 345 cmm                 1482
9.7 pts 342 cmm                 1376
9.6 pts 338 cmm                 1376
9.5 pts 335 cmm                 1376
9.4 pts 331 cmm                 1376
9.3 pts 328 cmm                 1376
9.2 pts 324 cmm                 1376
9.1 pts 321 cmm                 1376
9.0 pts 317 cmm                 1270
8.9 pts 313 cmm                 1270
8.8 pts 310 cmm                 1270
8.7 pts 306 cmm                 1270
8.6 pts 303 cmm                 1270
8.5 pts 299 cmm                 1270
8.4 pts 296 cmm                 1270
8.3 pts 292 cmm                 1270
8.2 pts 289 cmm                 1164
8.1 pts 285 cmm                 1164
8.0 pts 282 cmm                 1164

The font size I get is unchanged from 10.7 to 10.5 pt, from 10.4 to 9.8 
pt, from 9.7 to 9.1 pt, from 9.0 to 8.3 pt, from 8.2 to 7.6 pt and so on.

I kind of understand this result for a bitmap surface, where fonts are 
rendered in a way that they can only change their size by whole pixels.

But the result is exactly the same for PDF or Postscript surfaces.

There, the actual rendering does not happen in cairo, but on the target 
device which, for example, prints a PDF or postscript file.
The font rendering engine for Arial is inside the printer, and it may 
well be able to render Arial glyphs in many different sizes, depending 
on the printer resolution.

Why does this happen in Cairo, and is there a way to get around it, to 
get arbitrary font sizes at least for PDF, Postscript of SVG surfaces?

PS: I send a similar posting a few days ago but with png images 
attached. This did not make it to the mailing list. I hope this one does.



More information about the cairo mailing list