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. QPrinter recommended font
QtWS25 Last Chance

QPrinter recommended font

Scheduled Pinned Locked Moved Unsolved General and Desktop
font familyfont matchfont sizeprint problemqt 5.12.3
3 Posts 2 Posters 1.1k Views
  • 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.
  • B Offline
    B Offline
    BartoszPaj
    wrote on 30 Jun 2019, 13:30 last edited by
    #1

    Hi,
    I would ask you to tell me, which font is the best for QPrinter?
    I have all the time problems with space between letters in word.
    Currently I'm using Calibri.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 30 Jun 2019, 13:35 last edited by
      #2

      Hi
      Most fonts should work fine.
      Can you show an image of your issue and maybe some code?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BartoszPaj
        wrote on 30 Jun 2019, 14:05 last edited by
        #3

        Settings for printer:

            _printer.setResolution(QPrinter::PrinterResolution);
        
            QPageSize pageSize(QPageSize::A4);
            _printer.setPageSize(pageSize);
        
            QPagedPaintDevice::Margins margins;
            margins.top = 11.5;
            margins.left = 12.6;
            margins.right = 11.5;
            margins.bottom = 11.8;
            _printer.setMargins (margins);
        
            _printer.setOutputFileName("output.pdf");
            _printer.setOutputFormat(QPrinter::PdfFormat);
        

        Text Document

        QFont font;
                font.setPointSize(5);
                font.setFamily("Calibri");
                font.setLetterSpacing(QFont::PercentageSpacing,100);
                doc.setDefaultFont(font);
                doc.setPageSize(_printer.pageSizeMM());
        
        QTextCursor cursor(&doc);
                QTextBlockFormat block_format_title;
                block_format_title.setAlignment(Qt::AlignCenter);
                cursor.insertBlock(block_format_title);
                cursor.insertHtml(QString("<p><b>%1</b></p><br><br>").arg(file_theme.title));
                QTextBlockFormat block_format;
                block_format.setAlignment(Qt::AlignLeft);
                cursor.insertBlock(block_format);
        
        cursor.insertHtml(QString("<p><b>Imię i nazwisko:</b> %1<br>").arg(file_theme.childName));
                cursor.insertHtml(QString("<p><b>Terapeuta prowadzący:</b> %1<br>").arg(file_theme.therapistName));
                cursor.insertHtml("<br>");
                cursor.insertHtml(QString(HTML Text));
        doc.print(&_printer);
        

        On yellow incorrect spaces between letters in word.

        0_1561903468245_Przechwytywanie.JPG

        1 Reply Last reply
        0

        1/3

        30 Jun 2019, 13:30

        • Login

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