ligature.el
ligature.el copied to clipboard
Adding support for additional fonts
First of, fantastic package! Really looking forward to follow its development.
In the README
you request more font support, so I wanted to contribute with a list for Pragmata Pro. Do you want this in the README
, as a comment in the .el
or did you have anything more structured/automatic in mind?
To start with you can add it here as a comment. Thanks!
Cool!
Pragmata Pro
------------
'("[ERROR]" "[DEBUG]" "[INFO]" "[WARN]" "[WARNING]"
"[ERR]" "[FATAL]" "[TRACE]" "[FIXME]" "[TODO]"
"[BUG]" "[NOTE]" "[HACK]" "[MARK]"
"# ERROR" "# DEBUG" "# INFO" "# WARN" "# WARNING"
"# ERR" "# FATAL" "# TRACE" "# FIXME" "# TODO"
"# BUG" "# NOTE" "# HACK" "# MARK"
"// ERROR" "// DEBUG" "// INFO" "// WARN" "// WARNING"
"// ERR" "// FATAL" "// TRACE" "// FIXME" "// TODO"
"// BUG" "// NOTE" "// HACK" "// MARK"
"!!" "!=" "!==" "!!!" "!≡" "!≡≡" "!>" "!=<" "#("
"#_" "#{" "#?" "#>" "##" "#_(" "%=" "%>" "%>%" "%<%"
"&%" "&&" "&*" "&+" "&-" "&/" "&=" "&&&" "&>" "$>"
"***" "*=" "*/" "*>" "++" "+++" "+=" "+>" "++=" "--"
"-<" "-<<" "-=" "->" "->>" "---" "-->" "-+-" "-\\/"
"-|>" "-<|" ".." "..." "..<" ".>" ".~" ".=" "/*" "//"
"/>" "/=" "/==" "///" "/**" ":::" "::" ":=" ":≡" ":>"
":=>" ":(" ":-(" ":)" ":-)" ":/" ":\\" ":3" ":D" ":P"
":>:" ":<:" "<$>" "<*" "<*>" "<+>" "<-" "<<" "<<<" "<<="
"<=" "<=>" "<>" "<|>" "<<-" "<|" "<=<" "<~" "<~~" "<<~"
"<$" "<+" "<!>" "<@>" "<#>" "<%>" "<^>" "<&>" "<?>" "<.>"
"</>" "<\\>" "<\">" "<:>" "<~>" "<**>" "<<^" "<!" "<@"
"<#" "<%" "<^" "<&" "<?" "<." "</" "<\\" "<\"" "<:" "<->"
"<!--" "<--" "<~<" "<==>" "<|-" "<<|" "<-<" "<-->" "<<=="
"<==" "=<<" "==" "===" "==>" "=>" "=~" "=>>" "=/=" "=~="
"==>>" "≡≡" "≡≡≡" "≡:≡" ">-" ">=" ">>" ">>-" ">>=" ">>>"
">=>" ">>^" ">>|" ">!=" ">->" "??" "?~" "?=" "?>" "???"
"?." "^=" "^." "^?" "^.." "^<<" "^>>" "^>" "\\\\" "\\>"
"\\/-" "@>" "|=" "||" "|>" "|||" "|+|" "|->" "|-->" "|=>"
"|==>" "|>-" "|<<" "||>" "|>>" "|-" "||-" "~=" "~>" "~~>"
"~>>" "[[" "]]" "\">" "_|_")
@motform does the above actually work for you with PragmataPro? When I try that I get a seemingly-infinite loop of Attempt to shape unibyte text
error messages. If I trim the list down to just a few entries like "_|_" "/=" "/==" "!="
the errors cease, but the ligatures don't actually show up when the default face is set to PragmataPro Liga
or PragmataPro Mono Liga
. Changing the default face to Fira Code results in ligatures appearing as expected, so I'm pretty sure harfbuzz and cairo are working at least.
@benley I tried it yesterday and it worked for me at least in emacs-lisp-mode
. I set the font family to Pragmata Pro Mono Liga.
@benly could it have something to do with all the comment ligatures? I'm not sure why it should, but they are a bit of an outlier being so long.
The list is from the Pragmata Pro repository, should it should only contain compatible glyphs.
It might be worth checking if you meet the installation requirements and that it hangs in emacs -q
.
aha nevermind, I figured it out: I was still using version 0.827 of PragmataPro. Updating my font to 0.828 fixed it entirely.
correction: fixed it mostly. Some of the ligatures show up now, but emacs still falls into the same Attempt to shape unibyte text
error loop shortly after startup. Maybe there is something weird about my fontconfig setup?
It's possible. I've only tried Cascadia Code (can you try it with that one? The default sample config in the README works with Cascadia).
And could you confirm your Emacs build meets the install criteria in the README?
I run Ubuntu 20.04 and I've never had a crash, despite dogged attempts to mess up Emacs's char table internals.
@benley - can you reply with your comment in #10 instead?
Yup no problem.
One last comment on this thread: It seems that specifically the :3
ligature is what's triggering the aforementioned error loop for me. Removing just that one from the config results in a stable setup. Only remaining quirk that I've spotted is the // ...
comment ligatures don't seem to show up.
Great stuff, Ben. We'll clearly need to build up a knowledge base of broken ligations. I will consider how to build a "font profile" feature into the package so people can get some basic, functional defaults out of the box.
@benley I've had some problems with the comment ligatures before. They don't show up when using the CoreType rendering mode made available on MacOS in the MacPort Emacs distribution. I always assumed this is as it had problems handling spaces in ligatures, but it seems strange that only one of the sets are acting up.
The following works with Iosevka:
(ligature-set-ligatures
'prog-mode
'("<--" "<---" "<<-" "<-" "<->" "->" "->>" "-->" "--->"
"<!--" "-<<" "-<" "-<-" "->-" ">-" ">>-" "<-->" "<--->"
"<---->" "<==" "<===" "<<=" "<=" "<=>" "=>" "=>>" "==>"
"===>" "<!---" "=<<" "=<" "=<=" "=>=" ">=" ">>=" "<==>"
"<===>" "<====>" "<-------" "------->" "<======>" "<~~"
"<~" "~>" "~~>" "\\/" "/\\" "==" "!=" "/=" "~=" "<>"
"===" "!==" "=/=" "=!=" ":=" ":-" ":+" "<*" "<*>" "*>"
"<|" "<|>" "|>" "+:" "-:" "=:" "::" ":::" "<." "<.>"
".>" "(*" "*)" ":>" "++" "+++" "|-" "-|"))
Note that no all variants support all of these sets, but they work fine depending on the variant in use.
Here are the ligatures for Victor Mono:
(ligature-set-ligatures
't '("</" "</>" "/>" "~-" "-~" "~@" "<~" "<~>" "<~~" "~>" "~~"
"~~>" ">=" "<=" "<!--" "##" "###" "####" "|-" "-|" "|->"
"<-|" ">-|" "|-<" "|=" "|=>" ">-" "<-" "<--" "-->" "->" "-<"
">->" ">>-" "<<-" "<->" "->>" "-<<" "<-<" "==>" "=>" "=/="
"!==" "!=" "<==" ">>=" "=>>" ">=>" "<=>" "<=<" "<<=" "=<<"
".-" ".=" "=:=" "=!=" "==" "===" "::" ":=" ":>" ":<" ">:"
";;" "<|" "<|>" "|>" "<>" "<$" "<$>" "$>" "<+" "<+>" "+>"
"?=" "/=" "/==" "/\\" "\\/" "__" "&&" "++" "+++"))
(ligature-set-ligatures 'prog-mode '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" "{-" "::"
":::" ":=" "!!" "!=" "!==" "-}" "----" "-->" "->" "->>"
"-<" "-<<" "-~" "#{" "#[" "##" "###" "####" "#(" "#?" "#_"
"#_(" ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" "/**"
"/=" "/==" "/>" "//" "///" "&&" "||" "||=" "|=" "|>" "^=" "$>"
"++" "+++" "+>" "=:=" "==" "===" "==>" "=>" "=>>" "<="
"=<<" "=/=" ">-" ">=" ">=>" ">>" ">>-" ">>=" ">>>" "<*"
"<*>" "<|" "<|>" "<$" "<$>" "<!--" "<-" "<--" "<->" "<+"
"<+>" "<=" "<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<"
"<~" "<~~" "</" "</>" "~@" "~-" "~>" "~~" "~~>" "%%"))
(ligature-set-ligatures 'prog-mode '("-->" "->" "->>" "-<" "--<"
"-~" "]#" ".-" "!=" "!=="
"#(" "#{" "#[" "#_" "#_("
"/=" "/==" "|||" "||" ;; "|"
"==" "===" "==>" "=>" "=>>"
"=<<" "=/" ">-" ">->" ">="
">=>" "<-" "<--" "<->" "<-<"
"<!--" "<|" "<||" "<|||"
"<|>" "<=" "<==" "<==>" "<=>"
"<=<" "<<-" "<<=" "<~" "<~>"
"<~~" "~-" "~@" "~=" "~>"
"~~" "~~>" ".=" "..=" "---"
"{|" "[|" ".." "..." "..<"
".?" "::" ":::" "::=" ":="
":>" ":<" ";;" "!!" "!!."
"!!!" "?." "?:" "??" "?="
"**" "***" "*>" "*/" "#:"
"#!" "#?" "##" "###" "####"
"#=" "/*" "/>" "//" "///"
"&&" "|}" "|]" "$>" "++"
"+++" "+>" "=:=" "=!=" ">:"
">>" ">>>" "<:" "<*" "<*>"
"<$" "<$>" "<+" "<+>" "<>"
"<<" "<<<" "</" "</>" "^="
"%%" "'''" "\"\"\"" ))
No particular order on these beyond order they appear in the font specimen.
(setq monolisa-v2-ligatures
'(;; coding ligatures
"<!---" "--->" "|||>" "<!--" "<|||" "<==>" "-->" "->>" "-<<" "..=" "!=="
"#_(" "/==" "||>" "||=" "|->" "===" "==>" "=>>" "=<<" "=/=" ">->" ">=>"
">>-" ">>=" "<--" "<->" "<-<" "<||" "<|>" "<=" "<==" "<=>" "<=<" "<<-"
"<<=" "<~>" "<~~" "~~>" ">&-" "<&-" "&>>" "&>" "->" "-<" "-~" ".=" "!="
"#_" "/=" "|=" "|>" "==" "=>" ">-" ">=" "<-" "<|" "<~" "~-" "~@" "~="
"~>" "~~"
;; whitespace ligatures
"---" "'''" "\"\"\"" "..." "..<" "{|" "[|" ".?" "::" ":::" "::=" ":="
":>" ":<" "\;\;" "!!" "!!." "!!!" "?." "?:" "??" "?=" "**" "***" "*>"
"*/" "--" "#:" "#!" "#?" "##" "###" "####" "#=" "/*" "/>" "//" "/**"
"///" "$(" ">&" "<&" "&&" "|}" "|]" "$>" ".." "++" "+++" "+>" "=:="
"=!=" ">:" ">>" ">>>" "<:" "<*" "<*>" "<$" "<$>" "<+" "<+>" "<>" "<<"
"<<<" "</" "</>" "^=" "%%"))
(ligature-set-ligatures 'prog-mode monolisa-v2-ligatures)
Thanks, Byron!
Thanks—I hadn't even thought to look to see if there were any new ligatures!
'("<!--" "///" "..." "</>" "<<=" "<=<" "<=>" "<:<" "<::" "<||" "-->"
">=>" ">::" "!==" "=/=" "=<=" "=>>" "=>=" "=:=" ":<:" ":>:" "::<"
"::>" "://" ":::" "||>" "||=" "//" "/>" "/=" "/*" "??" ".." "</"
"<-" "<=" "<:" "->" ">:" "!!" "!=" "=>" ":<" ":>" ":=" "::" "|="
"||" "*/" "--")