[cairo] Trouble using scaled fonts with Xlib backend

Johann Lermer johann.lermer at elvin.eu
Fri Jan 31 18:18:28 UTC 2020


I have a question about scaled fonts and the matrices used in
creating a scaled font:

2 matrixes are used, the font matrix and the ctm matrix. When do
something like that:

cairo_matrix_t fm, cm;
cairo_matrix_init_scale (&fm, 18, 18);
cairo_matrix_init_scale (&cm, 1.5, 1.5);
cairo_scaled_font_t* sf = cairo_scaled_font_create (ff, &fm, &cm, op);
cairo_set_scaled_font (cr, sf);

and now when I ask for all the matrices (using e.g.
cairo_scaled_font_get_font_matrix) then I get:

font matrix is (18, 0, 0, 18, 0, 0)
ctm matrix is (1.5, 0, 0, 1.5, 0, 0)
scale matrix is (27, 0, 0, 27, 0, 0)

Somwhere later in my program I want to retreive the previously set
font with cairo_get_scaled_font - and obviously I expect to get the
same font metrics than before when I call
cairo_scaled_font_text_to_glyphs. But they are different. And when I
check the matrices again I get:

font matrix is (18, 0, 0, 18, 0, 0)
ctm matrix is (1.0, 0, 0, 1.0, 0, 0)
scale matrix is (18, 0, 0, 18, 0, 0)

See the difference in the ctm and scale matrices?

Now, of course, I could always use the identity matrix for ctm, but
then, what would it be good for?

Am I using it wrong - or is it a bug? 


PS: The library is libcairo.so.2.11600.0 on Gentoo Linux

More information about the cairo mailing list