Get the style of the font file using QFont
-
Is there a command in QFont where I can get the style of the font. I figured out how to get the family name of the font file but not the specific style of the file. I found a command which returns the entire list of styles associated with the font family.
styleList = QtGui.QFontDatabase.styles(fontFamilyName)
I need the exact style of the specific font file. For example, if I give arialb.ttf as an input, I should be getting family name: Arial; style: Bold. Any ideas?
-
Hi and welcome to devnet,
Do you mean QFont::styleName ?
-
Hello Gaist,
Thanks for the quick response! I tried this but I am getting empty string. This is my code
fontFile = "C:\Users\Desktop\abc.otf" fontdb = QtGui.QFontDatabase() id = fontdb.addApplicationFont(fontFile) family = fontdb.applicationFontFamiles(id) font = QtGui.QFont(family[0]) print font.styleName()
What am I doing wrong?
-
Weight is an enumeration and theres a corresponding getter