Get QFont type issue
Solved
General and Desktop
-
Hello!
I want to extract the font type information from a file. For example, I have 2 font files:
.ttf
and.otf
.
How to get theOpenType
orTrueType
font type usingQt API
? Is there anyQFont
methods to get such information? Thank you. -
Ok. I have got the font type information by font file mime type. Here is my solution.
Code:
QString getFontType(const QString &fileName) { QString fontType = ""; QMimeDatabase mimeDB; QMimeType mimeType = mimeDB.mimeTypeForFile(fileName, QMimeDatabase::MatchContent); if (mimeType.name().contains("application/x-font-ttf")) { fontType = "TrueType"; } else if (mimeType.name().contains("application/x-font-otf")) { fontType = "OpenType"; } else { fontType = "OtherType"; } return fontType; }
So, the issue is resolved.