fonts: preserve the font matrix when specializing a descriptor

specialize_font_descriptor() re-resolves a descriptor by file, index,
size and dpi to pick up size dependent fields. The re-match carries no
slant request, so fontconfig cannot re-derive a synthetic italic matrix,
and only index, named_style and axes were copied back from the base
descriptor. Any FC_MATRIX on the descriptor was therefore lost on every
sized face build, so the face was constructed without it and
FT_Set_Transform was never called, rendering the glyphs upright.

Descriptors can carry FC_MATRIX since b3e7c3e ("Read FC_MATRIX from
fontconfig"). Copy the matrix back like the other selection derived
fields the re-match cannot reproduce.
This commit is contained in:
Strykar 2026-06-10 13:57:30 +05:30
parent 79a768ed55
commit 779a49acde
No known key found for this signature in database
GPG key ID: E4A8486E91D492EA

View file

@ -458,6 +458,10 @@ specialize_font_descriptor(PyObject *base_descriptor, double font_sz_in_pts, dou
if (axes) {
if (PyDict_SetItemString(ans, "axes", axes) != 0) return NULL;
}
PyObject *matrix = PyDict_GetItemString(base_descriptor, "matrix");
if (matrix) {
if (PyDict_SetItemString(ans, "matrix", matrix) != 0) return NULL;
}
PyObject *ff = PyDict_GetItemString(ans, "fontfeatures");
if (ff && PyList_GET_SIZE(ff)) {
for (Py_ssize_t i = 0; i < PyList_GET_SIZE(ff); i++) {