I have a GUI application based on Qt (PyQt) running on Mac OS X (and other platforms). It allows the user to select fonts and has check boxes for bold and italic options.
On updating to the new Cocoa-based Qt, a user found the QFontComboBox
no longer displays the different font styles (e.g. condensed, oblique, bold...) and just displays the font family name. Under Carbon it showed both. The user also cannot enter the name with the style in the combo box. Furthermore, I cannot construct the same font passing the name into the QFont
constructor.
QFont
doesn't seem to know anything about these missing styles. Confusingly it has another different notion of style. It looks like QFontDatabase
has the information about the style variants. It can also construct fonts based on a family, style and point size.
So, are the following changes the correct approach?
Rather than have bold and italic buttons, have a combobox filled with the styles from
QFontDatabase
for the font selected in theQFontComboBox
.Store the style in saved documents (as text), rather than bold or italic.
So
Can I rely on the style being the same on systems with different languages? Can I include it in saved documents?
Is a style "Bold Italic" as robust a way of making a
QFont
with the desired properties, than setting the bold and italic properties of thatQFont
?If I want to retain bold and italic checkboxes, how can I convert these attributes into the correct style? Can I just guess "Bold", "Italic" or "Bold Italic"?