Qt font families and styles on Mac OS X

淺唱寂寞╮ 提交于 2019-12-24 00:39:25

问题


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?

  1. Rather than have bold and italic buttons, have a combobox filled with the styles from QFontDatabase for the font selected in the QFontComboBox.

  2. 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 that QFont?

  • 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"?

来源:https://stackoverflow.com/questions/15852418/qt-font-families-and-styles-on-mac-os-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!