[Interest] Text rendering problem.
william.crocker at analog.com
william.crocker at analog.com
Sun Jul 19 02:02:31 CEST 2015
>>>
>>> I am having a text rendering problem.
>>
>>> From some googling, I think it's because the hinting values are
>> obtained when unscaled, and then used even when scaled.
>>
>> What you can do in your example is
>>
>> scene_font.setHintingPreference(QFont::PreferNoHinting);
>>
>
> Elvis:
>
> You are the mam. That fixed it.
>
Just shoot me.
That fixed the problem on Linux,
but I still see the problem on Windows.
It's off to Google I go.
> I forgot the most import rule of software engineering in the 21st century:
>
> "No matter how obscure the problem, you are not the first to encounter it.
> Others have come before you, solved the problem and those solutions are
> there for all to see if you Google the right subject."
>
> Bill
>
>>> Bill
>>>
>>> -------------------------
>>> int
>>> main( int argc, char **argv ) {
>>> QApplication app(argc,argv);
>>>
>>> int sz = 6, scale = 10;
>>> QString text = QString("Impedance");
>>>
>>> // Text size is 60.
>>> // This text renders well.
>>> QFont label_font = QFont("Arial",scale*sz,QFont::Bold);
>>> QLabel *label = new QLabel(text);
>>> label->setFont(label_font);
>>>
>>> // Text size is 6, then the view is zoomed in x10.
>>> // This text is not properly kerned.
>>> QFont scene_font = QFont("Arial",sz,QFont::Bold);
>>> QTextDocument *html = new QTextDocument;
>>> html->setDefaultFont(scene_font);
>>> html->setHtml(text);
>>> QGraphicsTextItem *gi = new QGraphicsTextItem;
>>> gi->setDocument(html);
>>> QGraphicsScene *sp = new QGraphicsScene;
>>> sp->addItem(gi);
>>> QGraphicsView *view = new QGraphicsView;
>>> view->setScene(sp);
>>> view->scale(scale,scale);
>>>
>>> QHBoxLayout *hbox = new QHBoxLayout;
>>> hbox->addWidget(label);
>>> hbox->addWidget(view);
>>>
>>> QWidget *wp = new QWidget;
>>> wp->setLayout(hbox);
>>> wp->show();
>>>
>>> app.exec();
>>> }
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
More information about the Interest
mailing list