tonsky / FiraCode

Free monospaced font with programming ligatures
SIL Open Font License 1.1
77.3k stars 3.1k forks source link

Add glyphs to unicode reserved plane #211

Open driusan opened 8 years ago

driusan commented 8 years ago

I'm trying to use FiraCode w/ ligatures in a text editor I'm writing (where I'm currently using Deja Vu Sans Mono), but there doesn't seem to be any way to access the ligatures from Go, where the standard font drawing methods are based on converting unicode runes to glyphs and have no knowledge of ligatures.

The Unicode private use area planes is designed for this purpose, according to wikipedia, but doesn't seem to be used by Firacode (at least as far as I can tell by printing runes starting at 0x100000 or 0x0f0000 and visually scanning). Would it be possible to map the ligatures to the supplementary plan? If they were accessible as runes in a private use area with a documented mapping, I could manually do the context-sensitive mapping when rendering.

It's possible that I'm missing something, because all the "how to use the font" documentation seems to be user documentation, and I can't find any developer documentation..

clembu commented 4 years ago

thankfully!

xieve commented 4 years ago

@rohit507

How can we generate the fira-symbol font from the current version of fira-code?

I updated the Gist by @reiver-dev to work with the latest version. All you'll have to do is patch the font installed in the system and enable the fira-code-mode provided by the elisp sniippet. Using Arch, it's

# ./fira_code_patch.py -o /usr/share/fonts/OTF /usr/share/fonts/OTF/Fira-*.otf
AllanZyne commented 4 years ago

@rohit507

How can we generate the fira-symbol font from the current version of fira-code?

I updated the Gist by @reiver-dev to work with the latest version. All you'll have to do is patch the font installed in the system and enable the fira-code-mode provided by the elisp sniippet. Using Arch, it's

# ./fira_code_patch.py -o /usr/share/fonts/OTF /usr/share/fonts/OTF/Fira-*.otf

I have tested this command and it doesn't work. After I read script code, I guess you can't override write font while it's opening. I use this command and it works:

./fira_code_patch.py -o ~/.local/share/fonts/ /usr/share/fonts/OTF/FiraCode*.otf
xieve commented 4 years ago

The invocation of the script itself may be different across different installations. I only provided mine as an example of usage. Your suggestion will only work for making a local font to override the system one, but not all programs even look in the user-specific fonts folder.

Also, note how your wildcard differs from mine: Yours will match FiraCode-Regular.otf and FiraCode-Bold.otf, while mine has an extra hyphen in it, so it'll match Fira-Code-Regular.otf and the likes.

As to the "error" that you found: that is simply not the case, at least on my system. I overrode my fonts without a problem, fontforge doesn't seem to lock a file opened for reading.

It might be interesting to submit the error message you got (if you got one) as a comment of my Gist, so that we don't spam this issue.

lazy notifications@github.com schrieb am Do., 12. Dez. 2019, 05:38:

@rohit507 https://github.com/rohit507

How can we generate the fira-symbol font from the current version of fira-code?

I updated the Gist https://gist.github.com/xieve/d5a01cc59896c3973cb16df9ba8d30d4 by @reiver-dev https://github.com/reiver-dev to work with the latest version. All you'll have to do is patch the font installed in the system and enable the fira-code-mode provided by the elisp sniippet. Using Arch, it's

./fira_code_patch.py -o /usr/share/fonts/OTF /usr/share/fonts/OTF/Fira-*.otf

I have tested this command and it doesn't work. After I read script code, I guess you can't override write font while it's opening. I suggest

./fira_code_patch.py -o ~/.local/share/fonts/ /usr/share/fonts/OTF/FiraCode*.otf

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tonsky/FiraCode/issues/211?email_source=notifications&email_token=AE2JI5NBLVWWIARQJQKCZZTQYG53VA5CNFSM4CJTMHP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGVN4NQ#issuecomment-564846134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2JI5ME275UOL2SKFR7WWLQYG53VANCNFSM4CJTMHPQ .

AllanZyne commented 4 years ago

The invocation of the script itself may be different across different installations. I only provided mine as an example of usage. Your suggestion will only work for making a local font to override the system one, but not all programs even look in the user-specific fonts folder. Also, note how your wildcard differs from mine: Yours will match FiraCode-Regular.otf and FiraCode-Bold.otf, while mine has an extra hyphen in it, so it'll match Fira-Code-Regular.otf and the likes. As to the "error" that you found: that is simply not the case, at least on my system. I overrode my fonts without a problem, fontforge doesn't seem to lock a file opened for reading. It might be interesting to submit the error message you got (if you got one) as a comment of my Gist, so that we don't spam this issue. lazy notifications@github.com schrieb am Do., 12. Dez. 2019, 05:38: @rohit507 https://github.com/rohit507 How can we generate the fira-symbol font from the current version of fira-code? I updated the Gist https://gist.github.com/xieve/d5a01cc59896c3973cb16df9ba8d30d4 by @reiver-dev https://github.com/reiver-dev to work with the latest version. All you'll have to do is patch the font installed in the system and enable the fira-code-mode provided by the elisp sniippet. Using Arch, it's # ./fira_code_patch.py -o /usr/share/fonts/OTF /usr/share/fonts/OTF/Fira-.otf I have tested this command and it doesn't work. After I read script code, I guess you can't override write font while it's opening. I suggest ./fira_code_patch.py -o ~/.local/share/fonts/ /usr/share/fonts/OTF/FiraCode.otf — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#211?email_source=notifications&email_token=AE2JI5NBLVWWIARQJQKCZZTQYG53VA5CNFSM4CJTMHP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGVN4NQ#issuecomment-564846134>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2JI5ME275UOL2SKFR7WWLQYG53VANCNFSM4CJTMHPQ .

Oh, now maybe this is my system font cache issue.

I changed wildcard because I didn't know "Fira-Code-*.otf" this naming style. In fact I can't match anything by "Fira-*" because my font files are "FiraCode-*.otf".

Anyway, thanks for your script and it really works!

MonsieurPi commented 4 years ago

@xieve I tried your solution but I didn't manage to make it work on my configuration. Here are all the infos I can provide in case you have an answer to my problem:


The fonts are properly installed (I hope)

❯ fc-list | grep -i "fira"
/usr/local/share/fonts/f/FiraCode_Regular_Symbol.otf: Fira Code Symbol:style=Symbol-Regular
/usr/share/fonts/opentype/firacode/FiraCode-Retina.otf: Fira Code,Fira Code Retina:style=Retina,Regular
/usr/share/fonts/opentype/firacode/FiraCode-Bold.otf: Fira Code:style=Bold
/usr/share/fonts/opentype/firacode/FiraCode-Regular.otf: Fira Code:style=Regular
/usr/share/fonts/opentype/firacode/FiraCode-Medium.otf: Fira Code,Fira Code Medium:style=Medium,Regular
/usr/share/fonts/opentype/firacode/FiraCode-Light.otf: Fira Code,Fira Code Light:style=Light,Regular

ligatures.el is in .emacs.d/custom/

In my .emacs I have the following lines:

(custom-set-faces
 '(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight normal :height 113 :width normal :inverse-video nil :box nil :strike-through nil :overline nil :underline nil)))))

(use-package fira-code-mode
  :load-path "~/.emacs.d/custom/"
  :hook prog-mode)

I tried applying your script only to Fira Code Symbol:

❯ sudo ./fira_code_patch.py -o /usr/local/share/fonts/f/ /usr/local/share/fonts/f/Fira*.otf

And to the rest of the FiraCode fonts:

❯ sudo ./fira_code_patch.py -o /usr/share/fonts/opentype/firacode/ /usr/share/fonts/opentype/firacode/Fira*.otf
The glyph named triangleright is mapped to U+25BA.
But its name indicates it should be mapped to U+22B2.
The glyph named triangleright is mapped to U+25BA.
But its name indicates it should be mapped to U+22B2.
The glyph named triangleright is mapped to U+25BA.
But its name indicates it should be mapped to U+22B2.
The glyph named triangleright is mapped to U+25BA.
But its name indicates it should be mapped to U+22B2.
The glyph named triangleright is mapped to U+25BA.
But its name indicates it should be mapped to U+22B2.

But it's still all messed up (example below showing ==)

image

Thing is, I don't even know if it's using the fonts since when I delete them and reload the font cache (fc-cache -vs) I still have the same display so it looks like I'm missing something.

As a sidenote, would it be easier if I just installed emacs 27 since it looks like it should be able to use ligatures? And if so, how am I supposed to use it? Set FiraCode as the default font?

xieve commented 4 years ago

@MonsieurPi Have you restarted Emacs since reinstalling them? If so, please confirm that your fonts are actually patched by looking at them using FontForge and going to character U+E100 (Ctrl+Shift+>, U+E100). If it contains the www ligature, your font is patched. Next, please confirm that you are actually using Fira Code as your main font, or at least for the range U+E100 through U+E187 (although I doubt this would look visually pleasing). The two digits visible on your screenshot don't seem to be in Fira Code, if I'm not mistaken. There also was a function that would display all characters (and, if available, corresponding glyphs) in a certain range for easier debugging, but I can't find it anymore. Maybe someone else can help out.

In other news, I updated my snippet to include the changes that have been made since I wrote the ligature list, it should now be working again, even with newly patched and updated versions.

Edit: About Emacs 27, I genuinely don't know. If you can get it working, throw me a hint.