[Interest] Text rendering problem.
william.crocker at analog.com
william.crocker at analog.com
Thu Jul 23 14:46:56 CEST 2015
On 07/21/2015 01:31 PM, william.crocker at analog.com wrote:
> On 07/18/2015 08:02 PM, william.crocker at analog.com wrote:
>>
>>>>>
>>>>> I am having a text rendering problem.
>>>>
>>>> What you can do in your example is
>>>>
>>>> scene_font.setHintingPreference(QFont::PreferNoHinting);
>>>>
>
> It appears that one needs to use the DirectWrite text rendering
> system on Windows.
>
I have this working with DirectWrite on Windows,
but it only appears to work when my app is built with debug mode.
If I build it in release mode then it does *not* work
and the text appears badly kerned.
In debug mode I see Visual Studio loading DWrite.dll
I do not see that when built and run in release mode.
I tried copying DWrite.dll to the Qt.../bin dir (where
the app finds all of the Qt DLLs) but that did not help.
In all cases I have the font hinting preference
set to QFont::PreferNoHinting and a scan of the Qt source
shows that as the condition under which direct write is used.
Bill
When I say it does not work, I mean that
text is badly kerned at the smaller point sizes.
I can see this by zooming in on a QGraphicsScene
with text items.
>
>>> 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
>>>
>>>
>> _______________________________________________
>> 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