Bug 1061 - All text in MD on Mac is heavily antialiased; it looks bold
Summary: All text in MD on Mac is heavily antialiased; it looks bold
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 2.8 beta 3
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2011-09-26 17:54 UTC by Nat Friedman
Modified: 2011-09-27 05:35 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Nat Friedman 2011-09-26 17:54:02 UTC
MD seems to antialias the heck out of text.

MonoDevelop: http://nat.org/x/6ce5a74b.png
TextMate: http://nat.org/x/5a9e3384.png
Comment 1 Nat Friedman 2011-09-26 18:02:17 UTC
Even better, Xcode: http://nat.org/x/867d33d6.png
Comment 2 Mikayla Hutchinson [MSFT] 2011-09-26 18:26:47 UTC
It's not a fair comparison, OS X renders text bolder when it's light-on-dark. If you try a light MD theme, I strongly doubt it looks any different to Xcode.

TextMate appears to have disabled antialiasing completely, or is using a bitmap font.
Comment 3 Mikayla Hutchinson [MSFT] 2011-09-26 18:27:47 UTC
To clarify, MD isn't explicitly doing any antialiasing. MD is using Pango, Pango is using the MacOS ATSUI API, ATSUI is antialiasing text.
Comment 5 Nat Friedman 2011-09-26 18:37:01 UTC
Oh wow. You're totally right. That's amazing.

Xcode dark: http://nat.org/x/90025a0a.png


It would still be nice if we could turn off antialiasing in MD, with an option.
Comment 6 Nat Friedman 2011-09-26 18:56:24 UTC
Michael Hutchinson also provided this command to change the antialiasing settings: 

defaults write com.ximian.monodevelop AppleAntiAliasingThreshold 24
Comment 7 Mikayla Hutchinson [MSFT] 2011-09-26 19:07:37 UTC
That command basically lets you override system settings per app, in this case for apps matching the MD app bundle's ID. That setting is the same "don't smooth fonts smaller than point size X" setting you find in the system preferences UI.

Instead of altering the rendering for the whole MD UI, it would be best to have a setting to disable antialiasing in the MD source editor. There appears to be an API we can use to toggle smoothing on a rendering context: CGContextSetShouldSmoothFonts . However, I'm not sure how we'd access this given the gtk/pango/cairo abstractions. Maybe we could add an API to GTK to get the CGContext from a Cairo context or something.
Comment 8 Mikayla Hutchinson [MSFT] 2011-09-26 19:12:12 UTC
See: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/c/func/CGContextSetShouldSmoothFonts

It may be that we can get to it by P/Invoking our way to [[NSGraphicsContext currentContext]
graphicsPort] in the MD text editor's Expose function. I'll take a look next time I'm on MacOS.
Comment 9 Kristian Rietveld (inactive) 2011-09-27 02:41:46 UTC
> To clarify, MD isn't explicitly doing any antialiasing. MD is using Pango,
> Pango is using the MacOS ATSUI API, ATSUI is antialiasing text.

For the record, if you are compiling a recent Pango on 10.5 or higher, it should be compiling the CoreText backend instead of the ATSUI one.  ATSUI is deprecated in 10.6 and higher and not fully supported in 64-bit.


I'll look where the AA option is being toggled in Pango or Cairo, since I am debugging the font rendering for the font fallbacks bugs anyway.
Comment 10 Mike Krüger 2011-09-27 02:58:14 UTC
I already said that this is not only anti aliasing - it's a different font as well.
Anti aliasing doesn't add serifes when there are none - look at the 'i'.

It seems that the fonts have a different version for anti aliasing modes. I don't think that we can do much about that, when turning THAT off by a p/invoke the locations won't be correct anymore - pango needs to do it.

I've added an option for the anti aliasing font rendering to be turned off - but I don't think/know a way to use the other font. But at least it's not aliased anymore.

btw. apples solution is very good - it's not really possible to have a good font with and without anti aliasing looking very good both ways. Having another font version for either display option is a nice solution, but unfortunately it makes things difficult for us.

I set it to fixed - because we can now turn off the anti aliasing, which was the original problem.
Comment 11 Mike Krüger 2011-09-27 03:01:02 UTC
@Kristian Rietveld: Turning off the AA option in cairo basically works - now pango just needs a way to get the non anti aliased font version and this is done.

Any help there would be appreciated. I think it needs to be added to the pango API (mac specific extension).
Comment 12 Mikayla Hutchinson [MSFT] 2011-09-27 05:35:10 UTC
The reason I said ATSUI was that we're using Pango 1.28.4, which I don't believe has Core Text support by default. I briefly tried 1.29.x back in June but ran into some rendering glitches and didn't have time to follow it up.