andlabs / ui

Platform-native GUI library for Go.
Other
8.33k stars 651 forks source link

High DPI support on macOS .app bundles requires extra Info.plist metadata (command-line launching Just Works, apparently) #65

Open tmaiaroto opened 9 years ago

tmaiaroto commented 9 years ago

Is this supported? Maybe it's just some option I need to pass? The application window bar titles contain blurry text. The text within the app is sharper, but not the best (maybe a font choice?). Can this be changed?

tmaiaroto commented 9 years ago

Something to do with this? https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW1

andlabs commented 9 years ago

Uhhh... I don't know how the standard Cocoa controls don't have sharp text by default :S All I'm doing is

[control setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSze:NSControlSizeRegular]]];

and I don't know how that isn't sufficient to get controls drawing correctly. As for windows, I'm not sure; probably also a missing NSFont assignment; will look into it. There are no other DPI-dependent calculations in package ui that I am ware of; control spacing is decided using pixels, but I don't know how that's different from what Interface Builder does already (and controls themselves provide their preferred sizes).

Is there something I'm missing to get the standard Cocoa controls to recognize high-DPI environments?

Area is different; I need to add a DPI() method to get the current DPI used by the Area (or some other approach).

Does OS X require a "secret handshake" to enable high-DPI, like on Windows?

tmaiaroto commented 9 years ago

I'm not sure, I've been trying to search around a bit. It seems like there may be new APIs to use based on that link above. Though I'm new to all this so I just don't know and they don't make it super clear with a "this is how you used to do it, here's how you do it now"

andlabs commented 9 years ago

update: I don't see anything either in Interface Builder or in the docs about customizing window titlebar fonts

tmaiaroto commented 9 years ago

K for fonts... but what about relative resolution? https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW8

Would this be here? https://github.com/andlabs/ui/blob/master/window_darwin.m#L30

The NSWindow using convertRectToScreen ? Then the backing store with convertRectToBacking ?

landaire commented 9 years ago

For what it's worth I just looked into this lib for the first time and the examples look fine or are you guys talking about something else? screen shot 2014-12-27 at 20 02 06

tmaiaroto commented 9 years ago

For me things were blurry on Macbook Pro Retina machines due to the high resolution. I believe the way windows and sized and items positioned, there's an API to use that makes things relative to the display resolution (and supports retina). I'm just not familiar enough to figure it out, but I was looking through the code.

andlabs commented 9 years ago

Can you provide a picture similar to @landaire's? Being on the same page can help.

tmaiaroto commented 9 years ago

Well this is really strange. It's no longer blurry for me when I'm testing now. I wonder if it was because I had an external monitor plugged in...Though I tried at home with a different external monitor and it was still sharp. This is strange. I'll take a screenshot and re-open later if I see it again I guess.

alaingilbert commented 6 years ago

I still have this issue if I open the app with a launcher (.app)

The first image is when I open the binary normally. The second one is when I open it through a .app launcher.

test
alaingilbert commented 6 years ago

Ok, I solved it by adding:

<key>NSHighResolutionCapable</key>
<string>True</string>

In my Info.plist

Solution from: https://apple.stackexchange.com/questions/69038/open-in-low-resolution-checkbox-on-retina-macbook-pro-checked-and-disabled

andlabs commented 6 years ago

That will need to be noted somewhere then... (Keep open for now.)

andlabs commented 6 years ago

I still need to get an external high-DPI monitor so I can test this myself (Quartz Debugger shows no simulated High DPI options for me).

oimyounis commented 4 years ago

Ok, I solved it by adding:

<key>NSHighResolutionCapable</key>
<string>True</string>

In my Info.plist

Solution from: https://apple.stackexchange.com/questions/69038/open-in-low-resolution-checkbox-on-retina-macbook-pro-checked-and-disabled

This worked for me perfectly.. Also if the app is already in the "Applications" folder, you will need to move it out of there and then move it back in.