Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
That would be nice to have a way to do something like
int fontId = QFontDatabase::addApplicationFont[FromData](...);
QFont font = QFont::fromFontId(fontId);
Currently there is no way to do this: we can obtain font family by fontId, but cannot know the loaded font style.
Below is the use-case:
We write own ePub reader, with own ePub content parser. ePub file is just a zip archive that contains book text as well as CSS-defined styles and (optionally) embedded fonts. The description of a font in CSS can differ from the description in the font file. E.g., the ePub https://github.com/IDPF/epub3-samples/releases/download/20170606/cc-shared-culture.epub contains the description
@font-face { font-family: 'QuicksandLight'; src: url('../fonts/Quicksand_Bold_Oblique.otf') format('truetype'); font-weight: bold; font-style: normal; }
If the file Quicksand_Bold_Oblique.otf loaded in our Qt app, the added QFont has family name 'Quicksand', and has bold AND italic attributes set. However, the app does not know these details and cannot use the font as it expects it is not italic according the CSS.
Some more discussion is here: https://forum.qt.io/topic/87683/possible-qfontdatabase-missing-feature