[Lazarus] Mac Hi-DPI 2

Ondrej Pokorny lazarus at kluug.net
Sat Mar 11 21:37:27 CET 2017

On 11.03.2017 17:58, zeljko wrote:
> Qt4 - MacOSX 10.8.6 32 bit (qt4 library uses carbon for it's widgets)
> Qt5 - MacOSX 10.11 64 bit (qt5 library uses cocoa for it's widgets).
> When Application.Scaled = False fonts of some controls are resized to 
> smaller fonts (DesignTimePPI on both macs says 72 ) - so my question 
> are here:
> 1. is 96dpi hardcoded somewhere, so it underscales some fonts in case 
> when dpi is 72 - even with Application.Scaled := False. ?
> 2. Some forms eg. About lazarus is shown too small, seem that it's 
> scaled to the smaller size because of dpi 72. (ide have 
> application.scaled := True by default), also Find Dialog is reduced 
> but all child controls of FindDialog haven't scaled fonts ,so dialog 
> isn't sized well.
> Note that both cases were fine before HiDPI changes, also please keep 
> in mind that Lazarus OSX isn't carbon or cocoa only, but qt4 and qt5 too.
> On linux and windows everything works pretty nice (Application.Scaled 
> := true and Application.Scaled := false) with qt4 and qt5 widgetsets.

The LCL expects 100% scaling at 96 PPI. This is hard-coded now.

We have 2 possible solutions:

A.) Force Qt4 and Qt5 on Mac OSX to return 96 PPI instead of 72 PPI (the 
same to what I changed Carbon and Cocoa in 
http://mantis.freepascal.org/view.php?id=31037 ).

B.) Make the 100% scaling value OS-dependent. On Windows and Linux it 
would be 96 PPI and on Mac OSX 72 PPI. (This is what I suggested in the 
first email of the "Mac users: High-DPI" thread):

/[...] to create a relative DPI scaling to the default widgetset value - 
every DPI/PPI value will be compared to the WS DefaultPPI. So instead of 
DPI/PPI we'll have "ScaleFactor". E.g. it means that the property 
DesignTimePPI will be deleted and changed to DesignTimeScaleFactor. Also 
PixelsPerInch will have the ScaleFactor equivalent (I'll keep 
PixelsPerInch). Probably more changes will be needed. //
//On Windows: DesignTimePPI=96 -> DesignTimeScaleFactor=100 <- On Mac: 
DesignTimePPI=72. The same goes for PixelsPerInch/ScaleFactor. //
(A) is easier to implement so maybe we could test it first. Zeljko, 
could you please try with the attached patch (I am not sure about the 
DARWIN define - maybe you need another one for MacOSX).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170311/433d5608/attachment.html>
-------------- next part --------------
Index: lcl/interfaces/qt/qtwinapi.inc
--- lcl/interfaces/qt/qtwinapi.inc	(revision 54381)
+++ lcl/interfaces/qt/qtwinapi.inc	(working copy)
@@ -2958,9 +2958,17 @@
       Result := QPaintDevice_numColors(PaintDevice);
+      Result := 96;
+    {$ELSE}
       Result := QPaintDevice_logicalDpiX(PaintDevice);
+    {$ENDIF}
+      Result := 96;
+    {$ELSE}
       Result := QPaintDevice_logicalDpiY(PaintDevice);
+    {$ENDIF}
       Result := QPaintDevice_height(PaintDevice);

More information about the Lazarus mailing list