ligature.el icon indicating copy to clipboard operation
ligature.el copied to clipboard

Adding support for additional fonts

Open motform opened this issue 4 years ago • 21 comments

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?

motform avatar Sep 01 '20 08:09 motform

To start with you can add it here as a comment. Thanks!

mickeynp avatar Sep 01 '20 16:09 mickeynp

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 avatar Sep 01 '20 17:09 motform

@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 avatar Sep 02 '20 03:09 benley

@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.

cit avatar Sep 02 '20 06:09 cit

@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.

motform avatar Sep 02 '20 08:09 motform

It might be worth checking if you meet the installation requirements and that it hangs in emacs -q.

mickeynp avatar Sep 02 '20 19:09 mickeynp

aha nevermind, I figured it out: I was still using version 0.827 of PragmataPro. Updating my font to 0.828 fixed it entirely.

benley avatar Sep 02 '20 20:09 benley

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?

benley avatar Sep 02 '20 20:09 benley

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.

mickeynp avatar Sep 02 '20 20:09 mickeynp

@benley - can you reply with your comment in #10 instead?

mickeynp avatar Sep 02 '20 20:09 mickeynp

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.

Screenshot from 2020-09-02 16-51-22

benley avatar Sep 02 '20 20:09 benley

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.

mickeynp avatar Sep 02 '20 20:09 mickeynp

@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.

motform avatar Sep 03 '20 08:09 motform

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.

omidmnz avatar Oct 03 '20 15:10 omidmnz

Here are the ligatures for Victor Mono:

(ligature-set-ligatures
   't '("</" "</>" "/>" "~-" "-~" "~@" "<~" "<~>" "<~~" "~>" "~~"
        "~~>" ">=" "<=" "<!--" "##" "###" "####" "|-" "-|" "|->"
        "<-|" ">-|" "|-<" "|=" "|=>" ">-" "<-" "<--" "-->" "->" "-<"
        ">->" ">>-" "<<-" "<->" "->>" "-<<" "<-<" "==>" "=>" "=/="
        "!==" "!=" "<==" ">>=" "=>>" ">=>" "<=>" "<=<" "<<=" "=<<"
        ".-" ".=" "=:=" "=!=" "==" "===" "::" ":=" ":>" ":<" ">:"
        ";;" "<|" "<|>" "|>" "<>" "<$" "<$>" "$>" "<+" "<+>" "+>"
        "?=" "/=" "/==" "/\\" "\\/" "__" "&&" "++" "+++"))

smsegal avatar Jan 10 '21 17:01 smsegal

Fira Code

(ligature-set-ligatures 'prog-mode '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" "{-" "::"
                                     ":::" ":=" "!!" "!=" "!==" "-}" "----" "-->" "->" "->>"
                                     "-<" "-<<" "-~" "#{" "#[" "##" "###" "####" "#(" "#?" "#_"
                                     "#_(" ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" "/**"
                                     "/=" "/==" "/>" "//" "///" "&&" "||" "||=" "|=" "|>" "^=" "$>"
                                     "++" "+++" "+>" "=:=" "==" "===" "==>" "=>" "=>>" "<="
                                     "=<<" "=/=" ">-" ">=" ">=>" ">>" ">>-" ">>=" ">>>" "<*"
                                     "<*>" "<|" "<|>" "<$" "<$>" "<!--" "<-" "<--" "<->" "<+"
                                     "<+>" "<=" "<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<"
                                     "<~" "<~~" "</" "</>" "~@" "~-" "~>" "~~" "~~>" "%%"))

blablablerg avatar Feb 22 '21 07:02 blablablerg

MonoLisa

    (ligature-set-ligatures 'prog-mode '("-->" "->" "->>" "-<" "--<"
                                         "-~" "]#" ".-" "!=" "!=="
                                         "#(" "#{" "#[" "#_" "#_("
                                         "/=" "/==" "|||" "||" ;; "|"
                                         "==" "===" "==>" "=>" "=>>"
                                         "=<<" "=/" ">-" ">->" ">="
                                         ">=>" "<-" "<--" "<->" "<-<"
                                         "<!--" "<|" "<||" "<|||"
                                         "<|>" "<=" "<==" "<==>" "<=>"
                                         "<=<" "<<-" "<<=" "<~" "<~>"
                                         "<~~" "~-" "~@" "~=" "~>"
                                         "~~" "~~>" ".=" "..=" "---"
                                         "{|" "[|" ".."  "..."  "..<"
                                         ".?"  "::" ":::" "::=" ":="
                                         ":>" ":<" ";;" "!!"  "!!."
                                         "!!!"  "?."  "?:" "??"  "?="
                                         "**" "***" "*>" "*/" "#:"
                                         "#!"  "#?"  "##" "###" "####"
                                         "#=" "/*" "/>" "//" "///"
                                         "&&" "|}" "|]" "$>" "++"
                                         "+++" "+>" "=:=" "=!=" ">:"
                                         ">>" ">>>" "<:" "<*" "<*>"
                                         "<$" "<$>" "<+" "<+>" "<>"
                                         "<<" "<<<" "</" "</>" "^="
                                         "%%" "'''" "\"\"\"" ))

cmconnelly avatar Mar 03 '21 23:03 cmconnelly

MonoLisa v2

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)

byronclark avatar Jan 03 '23 04:01 byronclark

Thanks, Byron!

mickeynp avatar Jan 03 '23 08:01 mickeynp

Thanks—I hadn't even thought to look to see if there were any new ligatures!

cmconnelly avatar Jan 11 '23 19:01 cmconnelly

MD IO

'("<!--" "///" "..." "</>" "<<=" "<=<" "<=>" "<:<" "<::" "<||" "-->"
  ">=>" ">::" "!==" "=/=" "=<=" "=>>" "=>=" "=:=" ":<:" ":>:" "::<"
  "::>" "://" ":::" "||>" "||=" "//" "/>" "/=" "/*" "??" ".." "</"
  "<-" "<=" "<:" "->" ">:" "!!" "!=" "=>" ":<" ":>" ":=" "::" "|="
  "||" "*/" "--")

motform avatar Aug 30 '23 06:08 motform