Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT 6 PDF printer not embedding font properly
Forum Updated to NodeBB v4.3 + New Features

QT 6 PDF printer not embedding font properly

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtguy07
    wrote on last edited by qtguy07
    #1

    Hi together.
    I've recently switched to Qt 6 and experiencing some problems with QPdfWriter and QPrinter (printing pdf). The Font is always not embedded properly, even it is installed. To test that, I tried following Code:

    (Added in .pro file) QT += printsupport
    
    QPdfWriter writer("C:/Users/GGG/Desktop/lol.pdf");
    writer.setResolution(300);
    writer.setPageSize(QPageSize(QPageSize::A4));
    writer.newPage();
    QPainter painter;
    painter.begin(&writer);
    painter.drawText(600,600,"Hello, this is a test");
    painter.end();
    

    -> Font is embedded fine with Qt 5.15.2, but no more with Qt 6.0.0 :(
    Can one of you test my Code (Run with Qt 6 and open the .pdf file) and give your feedback? I checked everything on my System... I fear it's a Qt 6 specific problem.




    Or does someone have any advice? I tested following things:

    • Check the doc's and internet -> didn't found anything useful

    • read out the font (there is one embedded, but faulty)

    • Change font of QPainter to "Calibri"

    • check if the font is aviable with db.hasFamily("Calibri"); (return value = true)

    • Check graphics card driver -> installed rightly, no updates aviable.

    • Rebuild with Qt 5.15.2 (in both cases MinGW64) -> Font is embedded correctly. But gone if I turn back to Qt version 6.0.0

    • Checked my QT components -> I have installed for Qt 6.0.0: MinGW 8.1.0 64Bit, Sources, Qt 5 compatibility Module, Qt Shader Tools, Qt Debug Information Files.

    • list itemtried the same with QPrinter wich prints Pdf files - same behaviour.

    My Setup:
    Windows 10, 64bit - used fonts are installed.
    Qt creator 4.14.0 - MinGW64 with Qt 6.0.0

    1 Reply Last reply
    0
    • Q qtguy07

      Ok, thank you a lot for your effort. It looks like you had the same problem. If I open your file with Adobe reader, the Font isn't embedded properly. According to that, I guess it's not a problem caused by my system.

      Are there any faults in my code or could the problem be in Qt6? And if so, does anyone know the best way to report the bug?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @qtguy07

      Hi
      Looks like something in Qt6.

      Open bug report here
      https://bugreports.qt.io/secure/Dashboard.jspa
      please attach a small runnable example app and
      all information possible. maybe screenshot of the text in the pdf when right and when not.

      Also maybe short info on how you check in Adobe Reader.
      (i don't have that installed so could not check)

      but just from the fact, the same code on the same system produces different looking PDF
      depending on Qt5 or Qt6. then I would say something is up.

      Please post the bug ticket link here so other can vote on the issue.

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi
        resulting pdf. win 10. qt6 mingw
        https://www.dropbox.com/s/jxamlp1ub2dd9ak/lol2.pdf?dl=0

        1 Reply Last reply
        1
        • Q Offline
          Q Offline
          qtguy07
          wrote on last edited by
          #3

          Ok, thank you a lot for your effort. It looks like you had the same problem. If I open your file with Adobe reader, the Font isn't embedded properly. According to that, I guess it's not a problem caused by my system.

          Are there any faults in my code or could the problem be in Qt6? And if so, does anyone know the best way to report the bug?

          mrjjM 1 Reply Last reply
          0
          • Q qtguy07

            Ok, thank you a lot for your effort. It looks like you had the same problem. If I open your file with Adobe reader, the Font isn't embedded properly. According to that, I guess it's not a problem caused by my system.

            Are there any faults in my code or could the problem be in Qt6? And if so, does anyone know the best way to report the bug?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @qtguy07

            Hi
            Looks like something in Qt6.

            Open bug report here
            https://bugreports.qt.io/secure/Dashboard.jspa
            please attach a small runnable example app and
            all information possible. maybe screenshot of the text in the pdf when right and when not.

            Also maybe short info on how you check in Adobe Reader.
            (i don't have that installed so could not check)

            but just from the fact, the same code on the same system produces different looking PDF
            depending on Qt5 or Qt6. then I would say something is up.

            Please post the bug ticket link here so other can vote on the issue.

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              qtguy07
              wrote on last edited by
              #5

              @mrjj said in QT 6 PDF printer not embedding font properly:

              Please post the bug ticket link here so other can vote on the issue.

              Perfect. Thanks for your answer and help. I searched on the bugreports page. Someone posted this bug alredy.
              See here for more details: https://bugreports.qt.io/browse/QTBUG-89727

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Very nice and subtle bug - the container size was changed from int32_t to int64_t and the font serialization simply used QByteArray::size() without a cast.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                Q 1 Reply Last reply
                3
                • Christian EhrlicherC Christian Ehrlicher

                  Very nice and subtle bug - the container size was changed from int32_t to int64_t and the font serialization simply used QByteArray::size() without a cast.

                  Q Offline
                  Q Offline
                  qtguy07
                  wrote on last edited by
                  #7

                  @Christian-Ehrlicher Thanks for researching and fixing the error.

                  That will allow me to continue using Qt 6.0 without revert my code to 5.15.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by Christian Ehrlicher
                    #8

                    It was just luck - and the easy testcase. :)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    2

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved