-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[MAC] Enabling back sub pixel antialiasing for code view #11235
Changes from 5 commits
1015223
698f52b
c7cafae
7a95c0a
74e7ff9
7e769b4
0582f1c
5efe7a8
faad138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,42 @@ define(function (require, exports, module) { | |
|
||
// read URL params | ||
params.parse(); | ||
|
||
|
||
// Define a preference for font smoothing mode on Mac. | ||
// By default fontSmoothing is set to subpixel-antialiased | ||
// for the text inside code editor. It can be overridden | ||
// to "antialiased", that would set text rendering AA to use | ||
// gray scale antialiasing. | ||
|
||
if (brackets.platform === "mac") { | ||
|
||
PreferencesManager.definePreference("fontSmoothing", "string", "subpixel_antialiased", { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please replace the underscore in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marcelgerber Good catch! Will do that. |
||
description: Strings.DESCRIPTION_FONT_SMOOTHING, | ||
values: ["subpixel-antialiased", "antialiased"] | ||
}); | ||
|
||
PreferencesManager.on("change", "fontSmoothing", function () { | ||
|
||
var aaType = PreferencesManager.get("fontSmoothing"); | ||
|
||
// For any other value, set this to subpixel-antialiased | ||
if (aaType !== "subpixel-antialiased" && aaType !== "antialiased") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking another look at this line, I think we could also make it a Boolean pref, as we only really have two values (and I don't think there will be more in the future) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! we could do this to be a bool variable. I only went this approach as I had earlier plans to add |
||
aaType = "subpixel-antialiased"; | ||
} | ||
|
||
$("#editor-holder").css("-webkit-font-smoothing", aaType); | ||
|
||
}); | ||
|
||
AppInit.htmlReady(function () { | ||
// The code editor's text anti-aliasing should be defaulted to sub pixel | ||
// antialiasing on mac | ||
if (brackets.platform === "mac") { | ||
$("#editor-holder").css("-webkit-font-smoothing", "subpixel-antialiased"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably, it's easier (and more semantically correct) to just add this as an extra There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marcelgerber I could do a I am thinking of creating another selector and attach/unattach it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd be nicer, I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this line set the pref value instead of presumed default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have access to the prefs at this early point, IIRC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, only view state is ready by then. My point, though, that it probably should be done when the prefs are ready. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @busykai I evaluated setting the value when the prefs are ready. But I am thinking that experience would then be the user first sees the gray antialised text and then sub pixel AA text. The might give a feeling of a flicker effect. And that is why I did not go with that approach. Correct me if I am wrong. |
||
} | ||
|
||
}); | ||
} | ||
|
||
/** | ||
* Setup test object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,18 +53,14 @@ html, body { | |
|
||
/* And make sure we get a pointer cursor even over text */ | ||
cursor: default; | ||
|
||
/* Turn off subpixel antialiasing on Mac since it flickers during animations. */ | ||
-webkit-font-smoothing: antialiased; | ||
|
||
// This is a hack to avoid flicker when animations (like inline editors) that use the GPU complete. | ||
// It seems that we have to put it here rather than on the animated element in order to prevent the | ||
// entire window from flashing. | ||
// See: http://stackoverflow.com/questions/3461441/prevent-flicker-on-webkit-transition-of-webkit-transform | ||
// Mac-only though, since this would turn off subpixel antialiasing (ClearType) on Windows | ||
|
||
&.platform-mac { | ||
-webkit-backface-visibility: hidden; | ||
backface-visibility: hidden; | ||
// Use gray scale antialiasing for UI. Code view editor-holder | ||
// overrides this to use subpixel antialiasing, which then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add: to use subpixel antialiasing on Mac |
||
// can be overridden by setting "fontSmoothing" preference to | ||
// "antialiased". Gray scale AA is used for UI has SourceSansPro | ||
// font does not look good with subpixel AA well on low res monitors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gray scale AA is used for the UI parts which use SourceSansPro font, which doesn't look good with subpixel AA |
||
-webkit-font-smoothing: antialiased; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This setting applies to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that is correct. The entire UI would have gray scale anti aliasing except for the code editor. Subpixel AA for the UI was not looking good. It exposed some artifacts which was making the entire editor look out of place. I will update the PR with my findings and PR, that will help understand the scenario. Thanks! |
||
} | ||
|
||
.dark, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you undo these changes to the whitespace lines? Brackets by default does not trim whitespaces. There's no reason to introduce a change to this. If you have a trim extension, it should probably be disabled for brackets project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@busykai There was some piece of code here in the earlier commits and i just deleted that piece of code based on the code review comments and that is why it is showing as
blank space removal
change. I could revert this, but I think it is a good idea to remove the extra spaces wherever possible.