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

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.
  • BartoszPajB Offline
    BartoszPajB Offline
    BartoszPaj
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      • BartoszPajB Offline
        BartoszPajB Offline
        BartoszPaj
        wrote on 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

        • Login

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