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

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

    XMLWordPrintable

Details

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

    Description

      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.

       

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes