Read font name from file?
-
Is there any way to read the font name from a font file?
I tried the below solution, but this only returns the font family so if the font is Arial Bold it will only return Arial.
int id = QFontDatabase::addApplicationFont(filePath); if (id != -1) { QStringList fontFamily = QFontDatabase::applicationFontFamilies(id); QFontDatabase::removeApplicationFont(id); }
Is there any way to get the full font name?
-
Hi
I could not see any public access.The path is stored in private class
https://code.woboq.org/qt5/qtbase/src/gui/text/qfontdatabase.cpp.html#QFontDatabasePrivate
in the structstruct ApplicationFont { QString fileName; QByteArray data; QStringList families; };
I did look around to see if it was surfaced but to no avail.
-
Thanks a lot for looking. It looks like there might not be an easy solution in Qt.
I'll have a look if there's a cross platform library that can read the full name.
-
Thanks a lot for looking. It looks like there might not be an easy solution in Qt.
I'll have a look if there's a cross platform library that can read the full name.
Hi
Looking around i tripped over this
https://www.qtcentre.org/threads/26924-Retrieve-the-filename-of-a-QFontbut its windows bound.
-
Hi
Looking around i tripped over this
https://www.qtcentre.org/threads/26924-Retrieve-the-filename-of-a-QFontbut its windows bound.
@mrjj Thanks a lot for looking, but unfortunately the application is for Windows, Mac and Linux so the solution would have to be cross-platform.