LCL, Darwin (MacOSX): fix DPI values on LCL-level. Keep WidgetSet-DPI value original. Issue #31037

git-svn-id: trunk@54453 -
This commit is contained in:
ondrej 2017-03-21 19:29:26 +00:00
parent 431b58c609
commit 20a9ecf1d5
3 changed files with 14 additions and 6 deletions

View File

@ -437,6 +437,14 @@ begin
raise Exception.Create(rsNoWidgetSet); raise Exception.Create(rsNoWidgetSet);
end; end;
WidgetSet.AppInit(ScreenInfo); WidgetSet.AppInit(ScreenInfo);
{$IFDEF DARWIN}
// Mac OSX (all WS) return 72 PPI for 100% scaling.
// The LCL needs 96 PPI for correct
// a) font size scaling (Height/Size ratio)
// b) High-DPI scaling (Application.Scaled)
ScreenInfo.PixelsPerInchX := MulDiv(ScreenInfo.PixelsPerInchX, 96, 72);
ScreenInfo.PixelsPerInchY := MulDiv(ScreenInfo.PixelsPerInchY, 96, 72);
{$ENDIF}
ScreenInfo.Initialized := True; ScreenInfo.Initialized := True;
Screen.UpdateScreen; Screen.UpdateScreen;
// set that we are initialized => all exceptions will be handled by our HandleException // set that we are initialized => all exceptions will be handled by our HandleException

View File

@ -1455,8 +1455,8 @@ begin
case Index of case Index of
LOGPIXELSX, LOGPIXELSX,
LOGPIXELSY: LOGPIXELSY:
// logical is always 96 dpi (to correspond with 100% scaling on Windows), although physical can differ // logical is allways 72 dpi, although physical can differ
Result := 96; Result := 72; // TODO: test scaling and magnification
BITSPIXEL: Result := CGDisplayBitsPerPixel(CGMainDisplayID); BITSPIXEL: Result := CGDisplayBitsPerPixel(CGMainDisplayID);
else else
DebugLn('TCarbonWidgetSet.GetDeviceCaps TODO Index: ' + DbgS(Index)); DebugLn('TCarbonWidgetSet.GetDeviceCaps TODO Index: ' + DbgS(Index));

View File

@ -1875,9 +1875,9 @@ begin
// todo: change implementation for printers // todo: change implementation for printers
case Index of case Index of
HORZSIZE: HORZSIZE:
Result := Round(NSScreen.mainScreen.frame.size.width / 96 * 25.4); Result := Round(NSScreen.mainScreen.frame.size.width / 72 * 25.4);
VERTSIZE: VERTSIZE:
Result := Round(NSScreen.mainScreen.frame.size.height / 96 * 25.4); Result := Round(NSScreen.mainScreen.frame.size.height / 72 * 25.4);
HORZRES: HORZRES:
Result := Round(NSScreen.mainScreen.frame.size.width); Result := Round(NSScreen.mainScreen.frame.size.width);
BITSPIXEL: BITSPIXEL:
@ -1887,9 +1887,9 @@ begin
SIZEPALETTE: SIZEPALETTE:
Result := 0; Result := 0;
LOGPIXELSX: LOGPIXELSX:
Result := 96; Result := 72;
LOGPIXELSY: LOGPIXELSY:
Result := 96; Result := 72;
VERTRES: VERTRES:
Result := Round(NSScreen.mainScreen.frame.size.height); Result := Round(NSScreen.mainScreen.frame.size.height);
NUMRESERVED: NUMRESERVED: