Improve font style selection, enabling the proper styles to be selected.
This fixes #425312 . Made an MR because text is really hairy, and this will add another variable in how text is different between 5.0 and 4.4.
Apparently Qt will always synthesize the bold/italic if you don't set it on creation. This patch also tries to fix the handling of stretch, however it seems that all QFonts return 'anystretch' for the stretch, which makes me suspect there's a qt bug there. In any case, the changes ensure that at the least a coherent value is set ('0' is not a good default value). I am completely unsure if Qt is at all capable of selecting the appropriate stretch-style or whether it only synthesizes the stretch.
I also tried to figure out what was up with the small-caps setting, but while that shows up in the rich text editor, and I can trace it being present right in mergeIntoChunks
as well as KoSvgTextShape::relayout()
, but it just doesn't seem to get rendered, which makes me think QTextLayout is just ignoring that setting...
Test Plan
Make a text and try to style parts of it with a font that has multiple font families. Noto Sans/Serif has a wide array, and the thinner styles in particular are unambiguous, as there's no font-synthesis for those. Note: stretch doesn't work, so the condensed variations of this font don't work either.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.