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

QPdfWriter: embed font issue: generates very big pdf file on windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.4.1
    • GUI: Printing
    • None
    • Windows

      Put a TTF font in the Resources of the Qt app.

      Load this font in the Qt app like this:

      QFontDatabase::addApplicationFont(":/Resources/myfont.ttf");

       

      Now use QPdfWriter to generate a PDF using painter.setFont(myfont) and painter.DrawText(...).

      Result : the generated PDF file will be very large (probably because the font is not embedded in the PDF and this makes all text to be vectorized). Also the text won't be selectable in the pdf.

       

      It's on Windows only (MacOS and Android are fine) with qt6.4.1 but it's there since sometime (maybe even in qt5).

       

      This doesn't happen if the font is installed on the PC.

       

      This doesn't happen if you load the font directly on the hard drive:

       QFontDatabase::addApplicationFont("c:/myfont.ttf");

       

      Workaround: copy the file from the Resources to the temp folder, and use QFontDatabase::addApplicationFont(...) with this copy.

      WARNING: the workaround doesn't work anymore starting qt 6.8, please check attached bugreport.

       

        1. Courier Prime.ttf
          96 kB
          Martial Reynes
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            vgt Eirik Aavitsland
            mkdotcom2 Martial Reynes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes