You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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..
Reacted by CJ Bell, Eugene Medvedev, David A Roberts, Carl Henrik Lunde, George Thomas, Ollie Charles, Tesla Zhang, Christian Kellner, jilen, Xerz and 7 more
@mordocai Here's a workaround: I've extracted the glyphs that Fira Code adds into a separate font, and assigned each a Unicode ID in the private character area. Download the symbols font: FiraCode-Regular-Symbol.zip
This symbols font should be assigned as a fallback font for either Fira Code or Fira Mono because it does not define the regular characters.
Reacted by jakha, Abhijit Navale, Yosef Weissmann, andrea denisse, Ivan Kuznetsov, Shozo Hatta, Thomas Wu, me-mariosteve, drZoid, Skyler Grey and 2 more
Reacted by emmanueltouzery, SjoerdPennings, Aleksandar Topuzović, Ollie Charles, Alex Silva, Anton Ilin, John Hamelink, Vlad M., Tesla Zhang, Xerz and 26 more
Reacted by Abhijit Navale, andrea denisse, Gary Klimowicz, T-Yuuna, me-mariosteve and drZoid
And if you're using the prettify-symbols-mode extension for vscode, you can use the following substitution settings. (prettify-symbols-mode for Emacs should look similar-ish, but you'll combine the pre, ugly, and post into the same regex and \ue00a0 maybe can be replaced with a normal space.)
@mordocai FYI in Fira symbols visually take multiple character places but marked as taking just one (rightmost) single place:
So in fact when I do ligature substitution in font code, I replace e.g. hyphenhyphengreater with spacespacehyphen_hyphen_greater.liga (CR stands for space):
sub CR CR greater' by hyphen_hyphen_greater.liga;
sub CR hyphen' greater by CR;
sub hyphen' hyphen greater by CR;
The reason for that is that editors will still see result of substitution as three single-width characters, and will allow to “step inside” the ligature glyph. Without that, ligature will act as it’s a single character, which changes editing behaviour which we want to avoid. We want to keep feeling that substitution is purely visual and underlying code is there unchanged.
The downside of that is that glyphs span outside their container. This is usually perfectly fine with all known editors, but might surprise anyone who tries to use them directly without knowing about that gotcha.
@mordocai thanks for the work! I tried the gist but I get mostly garbage. See the picture. Maybe I'm using the wrong version of the font or something? I'm pretty sure I'm using 0.200 although I did install older versions in the past.
EDIT OK SORRY IT WORKS. Need to install the Fira code symbol font additionnally. The "x" does look weird, in "Text" for instance. It's replaced by a cross. Also the ligature for =<< doesn't work while fira code appears to support it.
hmm actually the 'x' just bothers me :-)
in haskell we often use the 'x' variable (x:xs) and that triggers it. I'll keep that line commented for my use.
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
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
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:
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>
.
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: … @rohit507https://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-devhttps://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!
@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:
(custom-set-faces
'(default ((t (:family"DejaVu Sans Mono":foundry"unknown":slant normal :weight normal :height113:width normal :inverse-videonil:boxnil:strike-throughnil:overlinenil:underlinenil)))))
(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/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 ==)
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?
@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.
Activity
siegebell commentedon Aug 9, 2016
Providing the fancy glyphs via private use area (PUA) codes would resolve #42 via prettify-symbols-mode.
siegebell commentedon Aug 9, 2016
@mordocai I believe this is what you're looking for.
siegebell commentedon Aug 11, 2016
@mordocai Here's a workaround: I've extracted the glyphs that Fira Code adds into a separate font, and assigned each a Unicode ID in the private character area. Download the symbols font: FiraCode-Regular-Symbol.zip
This symbols font should be assigned as a fallback font for either Fira Code or Fira Mono because it does not define the regular characters.
Character map:
siegebell commentedon Aug 11, 2016
And if you're using the prettify-symbols-mode extension for vscode, you can use the following substitution settings. (prettify-symbols-mode for Emacs should look similar-ish, but you'll combine the
pre,ugly, andpostinto the same regex and\ue00a0maybe can be replaced with a normal space.)tonsky commentedon Aug 11, 2016
@mordocai FYI in Fira symbols visually take multiple character places but marked as taking just one (rightmost) single place:
So in fact when I do ligature substitution in font code, I replace e.g.
hyphenhyphengreaterwithspacespacehyphen_hyphen_greater.liga(CRstands forspace):The reason for that is that editors will still see result of substitution as three single-width characters, and will allow to “step inside” the ligature glyph. Without that, ligature will act as it’s a single character, which changes editing behaviour which we want to avoid. We want to keep feeling that substitution is purely visual and underlying code is there unchanged.
The downside of that is that glyphs span outside their container. This is usually perfectly fine with all known editors, but might surprise anyone who tries to use them directly without knowing about that gotcha.
Hope that helps.
emmanueltouzery commentedon Aug 13, 2016
@mordocai thanks for the work! I tried the gist but I get mostly garbage. See the picture. Maybe I'm using the wrong version of the font or something? I'm pretty sure I'm using 0.200 although I did install older versions in the past.
EDIT OK SORRY IT WORKS. Need to install the Fira code symbol font additionnally. The "x" does look weird, in "Text" for instance. It's replaced by a cross. Also the ligature for
=<<doesn't work while fira code appears to support it.emmanueltouzery commentedon Aug 13, 2016
to fix the =<< in the gist =>
this is for the overzealous cross:
would need to require non-word characters before & after but my emacs regex-fu is weak for that, so I just commented that locally.
siegebell commentedon Aug 13, 2016
For example, this should only match 'x' if the preceding character is a number and the subsequent character is either a number or letter:
edit: changed
a-Ftoa-femmanueltouzery commentedon Aug 13, 2016
@siegebell i think the ideal would be a "word boundary" regex before & after the x. I was a bit lazy earlier, but this seems to work great =>
support for fira code ligatures through a hack, see tonsky/FiraCode#2…
emmanueltouzery commentedon Aug 13, 2016
hmm actually the 'x' just bothers me :-)
in haskell we often use the 'x' variable (x:xs) and that triggers it. I'll keep that line commented for my use.
39 remaining items
clembu commentedon Nov 26, 2019
thankfully!
xieve commentedon Dec 1, 2019
@rohit507
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-modeprovided by the elisp sniippet. Using Arch, it'sAllanZyne commentedon Dec 12, 2019
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:
xieve commentedon Dec 12, 2019
AllanZyne commentedon Dec 12, 2019
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 commentedon Jul 16, 2020
@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:
ligatures.elis in.emacs.d/custom/In my .emacs I have the following lines:
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*.otfAnd to the rest of the FiraCode fonts:
But it's still all messed up (example below showing ==)
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 commentedon Jul 16, 2020
@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 thewwwligature, 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.