Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66382

Provide a way to access application font by id.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • GUI: Font handling
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            geometer Nikolay Pultsin
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes