QFont::setStyleName() has begun introducing side-effects in recent Qt versions. It now overrides the other font properties, which are also no longer updated. Calling setStyleName("Bold Italic") on a regular font will thus result in a QFont instance which
- renders correctly (= Bold Italic)
- has inconsistent toString() and key() representations
- will ignore setBold(false) and setItalic(false)
QtCurve doesn't use the style name itself, but works with fonts set by the user and can thus have to deal with fonts that do have a style name set. The QFontDialog does this systematically (in this case the internal representation will be correct and complete though).
This patch introduces a workaround that strips the style name in a reliable manner, i.e. by recreating the input QFont instance:
- if no style name is set (or an empty stylename), a quick copy is made
- if the stylename equals the styleString() returned by the font database the font most likely has a consistent and complete internal representation, so a new font can be created from the traditional attributes
- otherwise, a database lookup is performed to find the most appropriate match.
The fontStripStyleName() method and the font database instance are provided in a new helper class into which I have also moved the setBold(Widget*) and unSetBold(Widget*) functions.
See QTBUG-65037 (among others)