-
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 6 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,7 @@ define(function (require, exports, module) { | |
|
||
// read URL params | ||
params.parse(); | ||
|
||
|
||
/** | ||
* Setup test object | ||
|
@@ -358,8 +358,8 @@ define(function (require, exports, module) { | |
} | ||
|
||
// Localize MainViewHTML and inject into <BODY> tag | ||
$("body").html(Mustache.render(MainViewHTML, Strings)); | ||
$("body").html(Mustache.render(MainViewHTML, { shouldAddAA: (brackets.platform === "mac"), Strings: Strings })); | ||
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 doesn't work right now, you need to add the 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 is an real good catch Marcel 👏 |
||
|
||
// Update title | ||
$("title").text(brackets.config.app_title); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -743,5 +743,6 @@ define({ | |
"DESCRIPTION_USE_THEME_SCROLLBARS" : "True to allow custom scroll bars", | ||
"DESCRIPTION_LINTING_COLLAPSED" : "True to collapse linting panel", | ||
"DESCRIPTION_FONT_FAMILY" : "Change font family", | ||
"DESCRIPTION_FONT_SIZE" : "Change font size; e.g, 13px" | ||
"DESCRIPTION_FONT_SIZE" : "Change font size; e.g, 13px", | ||
"DESCRIPTION_FONT_SMOOTHING" : "\"subpixel-antialiased\" to enable sub-pixel antialiasing and \"antialiased\" for gray scale antialiasing on Mac" | ||
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. "Mac-only: " should probably be the first words of the description ("on Mac" at the end could be removed then). Also use of and conjunction is confusing. It should be "or" instead. |
||
}); |
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, | ||
|
@@ -73,7 +69,9 @@ html, body { | |
} | ||
} | ||
|
||
|
||
.subpixel-aa{ | ||
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. Why don't we just make it 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. Oh, I see now. Disregard that. |
||
-webkit-font-smoothing: subpixel-antialiased; | ||
} | ||
|
||
.resizing-container { | ||
position: absolute; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
*/ | ||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global define, $ */ | ||
/*global define, brackets: true, $ */ | ||
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.
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! I will make the change. |
||
|
||
/** | ||
* The ViewCommandHandlers object dispatches the following event(s): | ||
|
@@ -266,6 +266,24 @@ define(function (require, exports, module) { | |
} | ||
} | ||
|
||
|
||
/** | ||
* Font smoothing setter to set the anti-aliasing type for the code area on Mac. | ||
* @param {string} aaType The antialiasing type to be set.It can take either "subpixel-antialiased" or "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. nit: Add a space: set. It |
||
*/ | ||
function setMacFontSmoothingType(aaType) { | ||
var $editor_holder = $("#editor-holder"), | ||
hasClass = $editor_holder.hasClass("subpixel-aa"); | ||
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 really need this 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! I will change this. |
||
|
||
// Add/Remove the class based on the preference. Also | ||
// default to subpixel AA in case of invalid entries. | ||
if (aaType === "antialiased" && hasClass) { | ||
$editor_holder.removeClass("subpixel-aa"); | ||
} else if ((aaType === "subpixel-antialiased" || aaType !== "antialiased") && !hasClass) { | ||
$editor_holder.addClass("subpixel-aa"); | ||
} | ||
} | ||
|
||
/** | ||
* Font family getter to get the currently configured font family for the document editor | ||
* @return {string} The font family for the document editor | ||
|
@@ -515,6 +533,20 @@ define(function (require, exports, module) { | |
setFontFamily(prefs.get("fontFamily")); | ||
}); | ||
|
||
// 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") { | ||
prefs.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. Still, make it default 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. My bad. I had changed it at one place but forgot to change it here. I will make the changes here. Thanks! |
||
description: Strings.DESCRIPTION_FONT_SMOOTHING, | ||
values: ["subpixel-antialiased", "antialiased"] | ||
}).on("change", function () { | ||
setMacFontSmoothingType(prefs.get("fontSmoothing")); | ||
}); | ||
} | ||
|
||
// Update UI when opening or closing a document | ||
MainViewManager.on("currentFileChange", _updateUI); | ||
|
||
|
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.