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

Font capitalization settings ignored when drawing text on QPrinter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P4: Low P4: Low
    • 5.6.0 Beta
    • 4.7.0
    • GUI: Font handling
    • None
    • d36a1dfb51af3f981262bc8e8fcd22b91aa890a6

      In the following small test program I attempt to draw some text string using font with capitalization set to AllUppercase. However, this text string appears in MixedCase in QPrintPreviewWidget and on the paper, whereas PDF contains correct results.

      MyPrinter.h:

      #ifndef MyPrinter_h
      #define MyPrinter_h
      
      #include <QtCore/QObject>
      #include <QtGui/QPrinter>
      
      class MyPrinter : public QObject {
      	Q_OBJECT
      public:
      	MyPrinter() { }
      	virtual ~MyPrinter() { }
      public slots:
      	void  onPaintRequested( QPrinter* );
      };
      
      #endif
      

      MyPrinter.cpp:

      void  MyPrinter::
      onPaintRequested( QPrinter*  printer )
      {
      	QPainter  p;
      	p.begin( printer );
      
      	QFont  fnt( "Arial", 24 );
      	fnt.setCapitalization( QFont::AllUppercase );
      
      	p.setFont( fnt );
      
      	p.drawText( 0, 0, "Sample Text" );
      
      	p.end();
      }
      
      int
      main(int argc, char* argv[])
      {
      	QApplication app( argc, argv );
      
      	QPrinter  printer;
      	printer.setOutputFileName( "print_test.pdf" );
      
      	QPrintPreviewWidget ppw( &printer );
      
      	MyPrinter  mp;
      	mp.connect( &ppw, SIGNAL( paintRequested( QPrinter* ) ), &mp, SLOT( onPaintRequested( QPrinter* ) ) );
      
      	QFrame  frm;
      	QVBoxLayout  vb( &frm );
      	vb.addWidget( &ppw );
      	QLabel  lbl( "Test String" );
      	QFont  fnt = lbl.font();
      	fnt.setCapitalization( QFont::AllUppercase );
      	lbl.setFont( fnt );
      	vb.addWidget( &lbl );
      
      	frm.show();
      
      	ppw.print();
      
      	return app.exec();
      }
      

        For Gerrit Dashboard: QTBUG-15214
        # Subject Branch Project Status CR V

            andysh Andy Shaw
            wlad Wladislaw Oganowski
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes