How to fix blurry text in macOS applications
macOS is my operating system of choice, so when I’m working on projects that use a GUI I like to build macOS application bundles. This allows me to have some flexibility when it comes to running the app. However, every time I run these bundles for the first time the text in the app is blurry, and I keep forgetting why that happens.
This problem will inevitably come up again, so I’m documenting the solution here. I can’t say I’m very interested in spending hours searching for a solution. Again. Sigh.
Solution: support high resolution displays
Add the following to your Info.plist
<key>NSHighResolutionCapable</key>
<true/>
such that the file will look something like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
There will be other items in the file, but that’s where you want the key-value pair to be;
in the dict
object.
If you’re using PyInstaller like I
currently am, you can add this to the info_plist
dict in the specification
file:
app = BUNDLE(
info_plist={
"NSHighResolutionCapable": True
}
)
Why is this necessary?
macOS uses the
Information Property List
(Info.plist
) to identify various capabilities of the app in question, including
whether your app supports high resolution displays via the
NSHighResolutionCapable property
.
I imagine the text looks blurry because macOS renders the app at low resolutions when the
property is not defined or is set to False
.
So by setting the property to True
you’re letting macOS know that “hey it’s ok
to render this app at higher resolutions”. Once the app is rendered at a higher resolution
the text will no longer be blurry! Success!