|
@@ -2246,11 +2246,18 @@ int DisplayServerOSX::screen_get_dpi(int p_screen) const {
|
|
|
NSArray *screenArray = [NSScreen screens];
|
|
|
if ((NSUInteger)p_screen < [screenArray count]) {
|
|
|
NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
|
|
|
- NSSize displayDPI = [[description objectForKey:NSDeviceResolution] sizeValue];
|
|
|
- return (displayDPI.width + displayDPI.height) / 2;
|
|
|
+
|
|
|
+ const NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
|
|
|
+ const CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
|
|
|
+ float scale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
|
|
|
+
|
|
|
+ float den2 = (displayPhysicalSize.width / 25.4f) * (displayPhysicalSize.width / 25.4f) + (displayPhysicalSize.height / 25.4f) * (displayPhysicalSize.height / 25.4f);
|
|
|
+ if (den2 > 0.0f) {
|
|
|
+ return ceil(sqrt(displayPixelSize.width * displayPixelSize.width + displayPixelSize.height * displayPixelSize.height) / sqrt(den2) * scale);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return 96;
|
|
|
+ return 72;
|
|
|
}
|
|
|
|
|
|
float DisplayServerOSX::screen_get_scale(int p_screen) const {
|