HtmlViewer icon indicating copy to clipboard operation
HtmlViewer copied to clipboard

Unix QT5 incorrect text output.

Open bubus112 opened this issue 4 years ago • 0 comments

Hello,

there is some kind of issue in calculating available space for outputting text in THtmlViewer under Unix QT5.

It looks like THtmlViewer does not support QT5 by default, so to make it work I had to add lpQt5 platform in HtmlMisc file:

htExpectsUTF8 := WidgetSet.LCLPlatform in [lpCarbon, lpQt, lpQt5, lpGTK2, lpWin32];

The main problem that I have encountered is connected with GetTextExtentExPointW function and calculating text length. After loading THtmlViewer from string, function GetTextExtentExPointW produces 'External: SIGSEGV' (as calculated Length is often bigger than actual text length, Length(str) != count). To make it work I had to change original 'Length' text counting for the one provided in parameter:

original: Result := WidgetSet.GetTextExtentExPoint(DC, PChar(s), Length(str), p4, p5, p6, p7); modified: Result := WidgetSet.GetTextExtentExPoint(DC, PChar(s), count, p4, p5, p6, p7);

Concerning the bug, THtmlViewer requires only one more change to fully support QT5. Without the change text is overlapping images, other texts etc. The solution is to define manual double buffering mode in htmlcons.inc file:

{$IF DEFINED(LCLQt5)}
 {$define OwnPaintPanelDoubleBuffering}
{$ENDIF}

I would be grateful if above changes found place in next THtmlViewer releases.

bubus112 avatar Feb 09 '22 08:02 bubus112