-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for font ligatures #192
Comments
👍 |
+1 |
👍 I would really like this feature. |
I'm looking into this with the team and will keep you guys updated :). Thanks for the idea! |
+1 |
👍 coming from Atom... there's really no going back after getting used to beatiful code with Ligatures (Fira Code) |
Good NewsI got ligatures to work by changing my user settings in VS Code with
Temporary Bad NewsThere's a side-effect we need to work through. The problem I’m getting is that when I use this rule I get a glitch when clicking at the end of a line. Clicking at the end of a line past the last character normally would put the cursor after the last cursor on the line, but as you can see, it’s putting my cursor at the beginning of the line. However, when I enter text, it is appearing at the end of the line as it should (except the cursor is not in the right spot). Atom had a similar problem in September for a while, when they enabled ligatures. Apparently ligatures can cause problems with character spacing, even though they are still multiple ASCII characters, they render differently and this can affect spacing. Perhaps this anchor on the page is relevant. @alexandrudima could you help with this? By the way, this is only a problem if you click past the last character of any line (as if it is making the cursor position undefined???). Anywhere else it’s fine. |
How can I add this CSS rule permanently ? I can see the ligatures working :) but I have to add that in the temporary Developer Tools
yep,same here |
With that CSS style, the editing cursor renders in an incorrect position when the insertion point is at the end of a line. Moving the cursor to the end of a line makes it (visually) jump to an earlier point in the line. It remains at the incorrect point (or sometimes jumps back and forth) as you type characters. This happens regardless of whether it was placed there with the mouse or the keyboard. This is the result of a Chromium bug that has been fixed, so it should eventually make it into a release of VS Code (which is the proper solution to the problem). If you're like me, you want those sweet sweet ligatures right now! Let's get to it. I put up a hacky pull request with a workaround. If you build VS Code locally, you can include #1510 to use it. If you don't want to run a dev build, you can cram the workaround into existing versions of VS Code. For example, on OSX:
If all went well, you now have some lovely ligatures, with a functioning editing cursor. |
u.setStart(h,n),u.setEnd(p,r);var f=u.getClientRects(),m=null;return f.length>0&&(m=this._createRawVisibleRangesFromClientRects(f,o,s,a)),m Does anybody have an idea where this line (above) is in the unminified source code? |
The line of code you pasted is the minified version of the code here. The original workaround is implemented in #1510; you can refer to the files changed in #1510 to see the change in its un-minified form, and in its original context. The steps listed in my earlier comment are simply back-porting #1510 change to existing (compiled and minified) versions of VS Code. I haven't checked other versions (or even the current version on other platforms), but I wouldn't be surprised if the minified code differed in each build. That's the trouble with trying to patch minified code, heh. Side note: The reason you don't see it directly in
|
Will #1510 be compatible with the chromium version, which has fixed this ? |
BTW... I really don't want to bash Atom, it is a great editor. But... That same operation crashed Atom (V 1.3.2) unfortunately. |
The way I did it without having to fix the editor itself was to edit This works, and avoids the broken line-selection in the editor, but there's a small tokenizing bug in JS: |
@clojj Glad you're enjoying it 😄. I just discovered these ligature fonts recently, and had to have them as well, heh. I believe #1510 would continue to work with the newer Chromium as it does with the current version. It doesn't add an offset to correct the bad coordinate; it outright replaces it with a new value calculated via other means (so even if the value provided by Chromium changes, #1510 will continue to produce the same output). The workaround would be wasteful (and probably confusing, heh) with newer Chromium, but shouldn't behave differently. @jstclair That's an interesting approach as well: trying to select a subset of elements that need the style, but won't appear in locations that break the cursor. Unfortunately, even just applying it to operators can trigger the misplaced cursor, as operators can appear at the end of a line. e.g. in the following code, moving the cursor to the right side of the
Additionally, applying it only to the operator class limits the places the fancy symbols show up; ligatures won't be displayed in other JS elements (comments, hexadecimal prefixes, etc.), nor will they appear in other languages (HTML, C#, plaintext, etc.) |
Just wanted to update everyone. This feature will be supported soon in the main branch. We are planning a temporary fix (based on the one above) while we wait for the fixed Chromium v48 to trickle down through an Electron Shell update soon. |
IMHO the challenge here is that the implementation of
So while PR #1510 includes a workaround for Chromium 487028 that works for LTR text, I cannot deliver this change in its current form -- making I am looking into enabling |
Kudos to @mattblagden for his PR #1510 that I used as a great inspiration source. ❤️ |
@alexandrudima: You can use the |
@sanmai-NL We ended up with: .monaco-editor.enable-ligatures {
-webkit-font-feature-settings: "liga" on, "calt" on;
font-feature-settings: "liga" on, "calt" on;
} Let's revisit these and use |
An alternative to ligatures is to use prettify-symbols-mode, which I've implemented as a plugin for the insider's build of vscode (but note that it is of beta quality right now). |
I will just leave this here - enable font ligatures in settings with: "editor.fontLigatures": true (and also using appropriate font) |
tested in VS CODE 1.9.1
FiraCode is an example.. there are other fonts that support Ligatures now |
It's diferent on the current version. {
"editor.fontFamily": "Fira Code",
"editor.fontSize": 18,
"editor.fontLigatures": true
} |
Fira Code and others are monospaced fonts that use ligatures to combine multi-character symbols, e.g.
->
will result in an arrow symbol→
. This is quite nice and atom supports this font feature since1.2.0
, so it should work with vscode, too.The text was updated successfully, but these errors were encountered: