[Lazarus] TCanvas, Qt, device context, TextOut(), anti-aliasing

Bernd Kreuss prof7bit at googlemail.com
Sat Mar 31 15:35:32 CEST 2012

Hello widgetset and Qt experts, I need some explanations to better
understand what is going on. I recently posted a thread
"TCanvas.TextRect, subpixel antialiasing with Qt4" that also included a
small demo application and screenshots to demonstrate my problem.

I have tried to step through the LCL and widgetset code to see what is
actually going on, the problem is when outputting text to some offscreen
TCanvas, like for example the TCanvas of the bitmap of a TImage then it
will use different text anti-aliasing settings than when doing the same
for the TCanvas of the form during the paint event. I have observed this
with Qt on Linux.

When painting to the canvas of the form during paint it will respect the
subpixel antialiasing settings from my .fonts.conf file and text will be
subpixel-antialiased but when outputting text to the canvas of a bitmap
it will only use "normal" antialiasing (which looks quite ugly and
inconsistent when you see such text appearing right next to the other
properly antialiased text in the same application).

I have tried to step through it and it seems it will ask Qt to create a
bitmap(?) and a device context for the bitmap and then use Qt to paint
on this bitmap and I tried to patch some of the Qt units trying to
change font settings and dc settings and renderhints immediately before
QPainter_drawText() is called but nothing has the desired effect but I
also did not see any obvious flags or constants whose names would
suggest that they have anything to do with it.

What is going on here and is it even *possible* to solve this problem?
The main reason for me is to use the html panel from turbopower_ipro
which seems to be rendering its content to such an offscreen canvas and
is producing really really ugly font rendering compared to the rest of
the application.

The problem does *not* occur with GTK2. I have not tried Windows yet.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x3945A21D.asc
Type: application/pgp-keys
Size: 16637 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120331/88e76669/attachment.key>

More information about the Lazarus mailing list