Reputation: 2030
When using Xcode, there doesn't seem to be a way to set code editor fonts to be sharp (i.e. with no 'font smoothing). Despite what you might see in the preview area of Preferences > Fonts & Colors, inside the actual code view it’s always smoothed/anti-aliased.
There are some older questions that address previous versions of Xcode. They suggest changing various settings using defaults write com.apple.dt.Xcode <etc>
, but these do not seem to affect the code view for me in Xcode 5 on Mac OS X 10.8.5. I am using a dual-display setup with one Retina and one non-Retina screen.
I've tried turning off the font smoothing checkbox in System Preferences > General > "Use LCD font smoothing where available", but that only affects sub pixel rendering...
Update (2014-11-25): The problem still occurs with Mac OS X 10.10.1 and Xcode 6.1.1. Here is a screenshot showing the editor view (smoothed) and preferences window (unsmoothed) after using these Terminal commands:
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES
defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold 16
Upvotes: 14
Views: 5325
Reputation: 7631
From Xcode9.3, text anti-aliasing can be disabled in the source editor by running the following command and restart Xcode:
defaults write com.apple.dt.Xcode SourceEditorDisableAntialiasing -bool YES
To turn anti-aliasing on again -
defaults write com.apple.dt.Xcode SourceEditorDisableAntialiasing -bool NO
Upvotes: 12
Reputation: 2030
Mike Ash says that he was able to build an Xcode plug-in to tell the text view to use screen fonts. It looks like this would be straightforward to do, although I have not tried it yet.
The general strategy would be (from his tweet) would be to "patch -[NSTextView drawRect:]
and do [[self layoutManager] setUsesScreenFonts: YES];
."
Update (2015-08-14): Here is an explanatory blog post from Ash and the Xcode project for his plug-in. It works for me with Xcode 6.4 if I add 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90
to the DVTPlugInCompatibilityUUIDs
. I consider this problem solved!
Update (2016-06-20): As of Xcode 8, you cannot use Xcode plug-ins, but this user default works:
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES
Upvotes: 7
Reputation: 79
If you use a non-retina display, try
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YESand restart XCode.
UPDATE:
Also invoke this:
defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold 24
Upvotes: 7
Reputation: 597
I'm not sure about prior versions, but with Xcode 6.1 and Yosemite (OS X 10.10) two commands are actually required to disable anti-aliasing locally in Xcode.
First, as has already been stated, you need to enter the following at a terminal console:
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES
Then, secondly:
defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold <some integer value>
This is preferable to disabling font smoothing or antialiasing throughout the entire operating system. It should really be an option to check/uncheck inside the program itself, but at least this works.
Upvotes: 2