最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is ≤ a legit less than equals char? - Stack Overflow

programmeradmin0浏览0评论

I was reading the release notes of Visual Studio Code and a particular caught my eye.

As you can see, there is a javascript file with the ≤ symbol. I can't figure out how it works, if I try to use it in my code I get a "Invalid or unexpected token" error (which I was expecting), and I can't find if it's only a VSCode configuration that shrinks <= into ≤ for aesthetic purposes.

How does it work?

I was reading the release notes of Visual Studio Code and a particular caught my eye.

As you can see, there is a javascript file with the ≤ symbol. I can't figure out how it works, if I try to use it in my code I get a "Invalid or unexpected token" error (which I was expecting), and I can't find if it's only a VSCode configuration that shrinks <= into ≤ for aesthetic purposes.

How does it work?

Share Improve this question edited Apr 13, 2018 at 8:16 Nisarg Shah 14.6k6 gold badges38 silver badges57 bronze badges asked Apr 13, 2018 at 8:16 bimbo1989bimbo1989 8221 gold badge10 silver badges22 bronze badges 3
  • 2 Might be github./tonsky/FiraCode – tkausl Commented Apr 13, 2018 at 8:17
  • 1 it IS only a VSCode configuration that shrinks <= into ≤ for aesthetic purposes. – Kajbo Commented Apr 13, 2018 at 8:19
  • Going to check out FiraCode, looks like it's the answer :) – bimbo1989 Commented Apr 13, 2018 at 8:20
Add a ment  | 

4 Answers 4

Reset to default 3

It looks like a monospaced font with ligatures, which makes <= looking as one sign.

Some sources:

  • https://github./tonsky/FiraCode
  • https://github./i-tu/Hasklig
  • https://github./be5invis/Iosevka

This is just due to the font ligature. The actual characters are 2: <= but the ligature renders them as one.

Some fonts support ligatures such as Fira Code and most likely you need to enable ligatures on your IDE if you want to use them.

I have worked with Ligatures for a while. These are called Monospaced Programming Fonts with Ligatures and it's just not FiraCode, there are several others out there. For example -

Monoid


Hasklig

Also these are supported by a LOT of editors and not just VS Code.

Perhaps worth to mention that for working ligatures in VSC you need:

  • Locally installed font with ligatures support (Monoid / Iosevka / Fira Code)
  • editor.fontFamily set to given font,
  • editor.fontLigatures set to true.
发布评论

评论列表(0)

  1. 暂无评论