BerndGabriel / HtmlViewer

The well-known Delphi/Lazarus HtmlViewer/FrameViewer
Other
394 stars 147 forks source link

DPI inconsistency #255

Open trichview opened 5 years ago

trichview commented 5 years ago

When reading CSS sizes specified in pt, in, cm, mm, pc, THTMLViewer uses Screen.PixelsPerInch to convert sizes to pixels. But when reading CSS sizes specified in px, Screen.PixelsPerInch is ignored, pixels are read as they are. So, if Screen.PixelsPerInch <> 96, sizes are inconsistent.

But HTML assumes that pixels have 96 dpi.

Suggested change in function LengthConv:

...
else if U = 'px' then 
 V := V * Screen.PixelsPerInch / 96
...

However, this is not a complete fix. HTML may contain pixel sizes not only here, but also in other places (table CellPadding, Border, etc.)

BerndGabriel commented 1 year ago

Does commit [https://github.com/BerndGabriel/HtmlViewer/commit/6e78be76882a2ec6fc28a03564d15bffefa285a2] fix this issue in master branch?