Skip to content

Add glyphs to unicode reserved plane #211

Open

Description

@driusan

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

Activity

  1. siegebell commented on Aug 9, 2016

    @siegebell

    Providing the fancy glyphs via private use area (PUA) codes would resolve #42 via prettify-symbols-mode.

  2. siegebell commented on Aug 9, 2016

    @siegebell

    @mordocai I believe this is what you're looking for.

  3. siegebell commented on Aug 11, 2016

    @siegebell

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

     www  \ue100     **   \ue101    ***  \ue102    **/  \ue103
      *>  \ue104     */   \ue105     \\  \ue106    \\\  \ue107
      {-  \ue108     []   \ue109     ::  \ue10a    :::  \ue10b
      :=  \ue10c     !!   \ue10d     !=  \ue10e    !==  \ue10f
      -}  \ue110     --   \ue111    ---  \ue112    -->  \ue113
      ->  \ue114    ->>   \ue115     -<  \ue116    -<<  \ue117
      -~  \ue118     #{   \ue119     #[  \ue11a     ##  \ue11b
     ###  \ue11c   ####   \ue11d     #(  \ue11e     #?  \ue11f
      #_  \ue120    #_(   \ue121     .-  \ue122     .=  \ue123
      ..  \ue124    ..<   \ue125    ...  \ue126     ?=  \ue127
      ??  \ue128     ;;   \ue129     /*  \ue12a    /**  \ue12b
      /=  \ue12c    /==   \ue12d     />  \ue12e     //  \ue12f
     ///  \ue130     &&   \ue131     ||  \ue132    ||=  \ue133
      |=  \ue134     |>   \ue135     ^=  \ue136     $>  \ue137
      ++  \ue138    +++   \ue139     +>  \ue13a     +>  \ue13a
     =:=  \ue13b     ==   \ue13c    ===  \ue13d    ==>  \ue13e
      =>  \ue13f    =>>   \ue140     <=  \ue141    =<<  \ue142
     =/=  \ue143     >-   \ue144     >=  \ue145    >=>  \ue146
      >>  \ue147    >>-   \ue148    >>=  \ue149    >>>  \ue14a
      <*  \ue14b    <*>   \ue14c     <|  \ue14d    <|>  \ue14e
      <$  \ue14f    <$>   \ue150   <!--  \ue151     <-  \ue152
     <--  \ue153    <->   \ue154     <+  \ue155    <+>  \ue156
      <=  \ue157    <==   \ue158    <=>  \ue159    <=<  \ue15a
      <>  \ue15b     <<   \ue15c    <<-  \ue15d    <<=  \ue15e
     <<<  \ue15f     <~   \ue160    <~~  \ue161     </  \ue162
     </>  \ue163     ~@   \ue164     ~-  \ue165     ~=  \ue166
      ~>  \ue167     ~~   \ue168    ~~>  \ue169     %%  \ue16a
       x  \ue16b      :   \ue16c      +  \ue16d      *  \ue16f
    
  4. siegebell commented on Aug 11, 2016

    @siegebell

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

    "prettifySymbolsMode.substitutions": [
      {
        "language": "*",
        "substitutions": [
          { "ugly": "\\{2}", "pretty": "\u03bb", "post": "\\s*(?:\\w|_).*?\\s*->" },
          { "ugly": "\\.=", "pretty": " \ue123", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "\\.-", "pretty": " \ue122", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": ":=", "pretty": " \ue10c", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "=:=", "pretty": "\u00a0  \ue13b", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "==", "pretty": " \ue13c", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "!=", "pretty": " \ue10e", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "===", "pretty": "\u00a0  \ue13d", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "!==", "pretty": "\u00a0  \ue10f", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "=/=", "pretty": "\u00a0  \ue143", "pre": "[^.=:!/<>]|^", "post": "[^.=:!/<>]|$" },
          { "ugly": "<-", "pretty": " \ue152", "pre": "[^<\\->=]|^", "post": "[^<\\-=>]|$" },
          { "ugly": "->", "pretty": " \ue114", "pre": "[^<\\->=]|^", "post": "[^<\\-=>]|$" },
          { "ugly": "<--", "pretty": "\u00a0  \ue153", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "-->", "pretty": "\u00a0  \ue113", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<->", "pretty": "\u00a0  \ue154", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<<-", "pretty": "\u00a0  \ue15d", "pre": "[^<\\->=]|^", "post": "[^<\\-=>]|$" },
          { "ugly": "->>", "pretty": "\u00a0  \ue115", "pre": "[^<\\->=]|^", "post": "[^<\\-=>]|$" },
          { "ugly": "=>", "pretty": " \ue13f", "pre": "[^<\\->=]|^", "post": "[^<\\-=>]|$" },
          { "ugly": "<==", "pretty": "\u00a0  \ue158", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "==>", "pretty": "\u00a0  \ue13e", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<=>", "pretty": "\u00a0  \ue159", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<=<", "pretty": "\u00a0  \ue15a", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<<=", "pretty": "\u00a0  \ue15e", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "=>>", "pretty": "\u00a0  \ue140", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">=>", "pretty": "\u00a0  \ue146", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">>=", "pretty": "\u00a0  \ue149", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">>-", "pretty": "\u00a0  \ue148", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">-", "pretty": " \ue144", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "-<", "pretty": " \ue116", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "-<<", "pretty": "\u00a0  \ue117", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "=<<", "pretty": "\u00a0  \ue142", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<~~", "pretty": "\u00a0  \ue161", "pre": "[^<\\->=~]|^", "post": "[^<\\->=~]|$" },
          { "ugly": "<~", "pretty": " \ue160", "pre": "[^<\\->=~]|^", "post": "[^<\\->=~]|$" },
          { "ugly": "~~", "pretty": " \ue168", "pre": "[^<\\->=~]|^", "post": "[^<\\->=~]|$" },
          { "ugly": "~>", "pretty": " \ue167", "pre": "[^<\\->=~]|^", "post": "[^<\\->=~]|$" },
          { "ugly": "~~>", "pretty": "\u00a0  \ue169", "pre": "[^<\\->=~]|^", "post": "[^<\\->=~]|$" },
          { "ugly": "<<<", "pretty": "\u00a0  \ue15f", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<<", "pretty": " \ue15c", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<=", "pretty": " \ue141", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<>", "pretty": " \ue15b", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">=", "pretty": " \ue145", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">>", "pretty": " \ue147", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": ">>>", "pretty": "\u00a0  \ue14a", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<\\|", "pretty": " \ue14d", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "<\\|>", "pretty": "\u00a0  \ue14e", "pre": "[^<\\->=|]|^", "post": "[^<\\->=|]|$" },
          { "ugly": "\\|>", "pretty": " \ue135", "pre": "[^<\\->=|]|^", "post": "[^<\\->=|]|$" },
          { "ugly": "<\\$", "pretty": " \ue14f", "pre": "[^<\\->=$]|^", "post": "[^<\\->=$]|$" },
          { "ugly": "<\\$>", "pretty": "\u00a0  \ue150", "pre": "[^<\\->=$]|^", "post": "[^<\\->=$]|$" },
          { "ugly": "\\$>", "pretty": " \ue137", "pre": "[^<\\->=$]|^", "post": "[^<\\->=$]|$" },
          { "ugly": "<\\+", "pretty": " \ue155", "pre": "[^<\\->=+]|^", "post": "[^<\\->=+]|$" },
          { "ugly": "<\\+>", "pretty": "\u00a0  \ue156", "pre": "[^<\\->=+]|^", "post": "[^<\\->=+]|$" },
          { "ugly": "\\+>", "pretty": " \ue13a", "pre": "[^<\\->=+]|^", "post": "[^<\\->=+]|$" },
          { "ugly": "<\\*", "pretty": " \ue14b", "pre": "[^<\\->=*]|^", "post": "[^<\\->=*]|$" },
          { "ugly": "<\\*>", "pretty": "\u00a0  \ue14c", "pre": "[^<\\->=*]|^", "post": "[^<\\->=*]|$" },
          { "ugly": "\\*>", "pretty": " \ue104", "pre": "[^<\\->=*]|^", "post": "[^<\\->=*]|$" },
          { "ugly": "\\\\\\\\", "pretty": " \ue106", "pre": "[^<\\\\\\->=]|^", "post": "[^<\\\\\\->=]|$" },
          { "ugly": "\\\\\\\\\\\\", "pretty": "\u00a0  \ue107", "pre": "[^<\\\\\\->=]|^", "post": "[^<\\\\\\->=]|$" },
          { "ugly": "\\{-", "pretty": " \ue108", "pre": "[^<\\\\\\->={}]|^", "post": "[^<\\\\\\->={}]|$" },
          { "ugly": "-}", "pretty": " \ue110", "pre": "[^<\\->={}]|^", "post": "[^<\\->={}]|$" },
          { "ugly": "//", "pretty": " \ue12f", "pre": "[^<\\->=/]|^", "post": "[^<\\->=/]|$" },
          { "ugly": "///", "pretty": "\u00a0  \ue130", "pre": "[^<\\->=/]|^", "post": "[^<\\->=/]|$" },
          { "ugly": "/\\*", "pretty": " \ue12a", "pre": "[^<\\->=/*]|^", "post": "[^<\\->=/*]|$" },
          { "ugly": "/\\*\\*", "pretty": "\u00a0  \ue12b", "pre": "[^<\\->=/*]|^", "post": "[^<\\->=/*]|$" },
          { "ugly": "\\*\\*/", "pretty": "\u00a0  \ue103", "pre": "[^<\\->=/*]|^", "post": "[^<\\->=/*]|$" },
          { "ugly": "\\*/", "pretty": " \ue105", "pre": "[^<\\->=/*]|^", "post": "[^<\\->=/*]|$" },
          { "ugly": "</", "pretty": " \ue162", "pre": "[^<\\->=/]|^", "post": "[^<\\->=/]|$" },
          { "ugly": "<\\!--", "pretty": "\u00a0 \u00a0\ue151", "pre": "[^<\\->=!]|^", "post": "[^<\\->=!]|$" },
          { "ugly": "</>", "pretty": "\u00a0  \ue163", "pre": "[^<\\->=]|^", "post": "[^<\\->=]|$" },
          { "ugly": "/>", "pretty": " \ue12e", "pre": "[^<\\->=/]|^", "post": "[^<\\->=/]|$" },
          { "ugly": "x", "pretty": "\ue16b", "pre": "[0-9a-fA-F]", "post": "[0-9a-fA-F]" },
          { "ugly": ":", "pretty": "\ue16c", "pre": "[0-9]{1,2}", "post": "[0-9]{1,2}" },
          { "ugly": "\\+", "pretty": "\ue16d", "pre": "[0-9a-zA-Z]", "post": "[0-9a-zA-Z]" },
          { "ugly": "-", "pretty": "-", "pre": "[0-9a-zA-Z]", "post": "[0-9a-zA-Z]" },
          { "ugly": "\\*", "pretty": "*", "pre": "", "post": "" },
          { "ugly": "www", "pretty": "\u00a0  \ue100", "pre": "\\b", "post": "\\b" },
          { "ugly": ";;", "pretty": " \ue129", "pre": "[^;]|^", "post": "[^;]|$" },
          { "ugly": "::", "pretty": " \ue10a", "pre": "[^:]|^", "post": "[^:]|$" },
          { "ugly": ":::", "pretty": "\u00a0  \ue10b", "pre": "[^:]|^", "post": "[^:]|$" },
          { "ugly": "!!", "pretty": " \ue10d", "pre": "[^!]|^", "post": "[^!]|$" },
          { "ugly": "\\?{2}", "pretty": " \ue128", "pre": "[^?]|^", "post": "[^?]|$" },
          { "ugly": "%%", "pretty": " \ue16a", "pre": "[^%]|^", "post": "[^%]|$" },
          { "ugly": "&&", "pretty": " \ue131", "pre": "[^&]|^", "post": "[^&]|$" },
          { "ugly": "\\|{2}", "pretty": " \ue132", "pre": "[^|=]|^", "post": "[^|=]|$" },
          { "ugly": "\\.{2}", "pretty": " \ue124", "pre": "[^.<]|^", "post": "[^.<]|$" },
          { "ugly": "\\.{3}", "pretty": "\u00a0  \ue126", "pre": "[^.<]|^", "post": "[^.<]|$" },
          { "ugly": "\\.\\.<", "pretty": "\u00a0  \ue125", "pre": "[^.<]|^", "post": "[^.<]|$" },
          { "ugly": "\\[\\]", "pretty": " \ue109", "pre": "[^[\\]]|^", "post": "[^[\\]]|$" },
          { "ugly": "--", "pretty": " \ue111", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "---", "pretty": "\u00a0 \ue112", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "\\+{2}", "pretty": " \ue138", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "\\+{3}", "pretty": "\u00a0  \ue139", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "\\*{2}", "pretty": " \ue101", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "\\*{3}", "pretty": "\u00a0  \ue102", "pre": "[^\\-+*=<>~]|^", "post": "[^\\-+*=<>~]|$" },
          { "ugly": "~=", "pretty": " \ue166", "pre": "[^~=\\-]|^", "post": "[^~=\\-]|$" },
          { "ugly": "~-", "pretty": " \ue165", "pre": "[^~=\\-<>]|^", "post": "[^~=\\-<>]|$" },
          { "ugly": "-~", "pretty": " \ue118", "pre": "[^~=\\-<>]|^", "post": "[^~=\\-<>]|$" },
          { "ugly": "~@", "pretty": " \ue164", "pre": "[^~=\\-@~]|^", "post": "[^~=\\-@~]|$" },
          { "ugly": "\\^=", "pretty": " \ue136", "pre": "[^~=\\-^]|^", "post": "[^~=\\-^]|$" },
          { "ugly": "\\?=", "pretty": " \ue127", "pre": "[^~=\\-/?]|^", "post": "[^~=\\-/?]|$" },
          { "ugly": "/=", "pretty": " \ue12c", "pre": "[^~=\\-/]|^", "post": "[^~=\\-/]|$" },
          { "ugly": "/==", "pretty": "\u00a0  \ue12d", "pre": "[^~=\\-/]|^", "post": "[^~=\\-/]|$" },
          { "ugly": "\\|=", "pretty": " \ue134", "pre": "[^~=\\-/|]|^", "post": "[^~=\\-/|]|$" },
          { "ugly": "\\|{2}=", "pretty": "\u00a0  \ue133", "pre": "[^~=\\-/|]|^", "post": "[^~=\\-/|]|$" },
          { "ugly": "##", "pretty": " \ue11b", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "###", "pretty": "\u00a0  \ue11c", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "####", "pretty": "\u00a0\u00a0 \ue11d", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#{", "pretty": " \ue119", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#\\[", "pretty": " \ue11a", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#\\(", "pretty": " \ue11e", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#\\?", "pretty": " \ue11f", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#_", "pretty": " \ue120", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" },
          { "ugly": "#_\\(", "pretty": "\u00a0  \ue121", "pre": "[^#_?({[\\]]|^", "post": "[^#_?({[\\]]|$" }
        ]
      }
    ]
  5. tonsky commented on Aug 11, 2016

    @tonsky
    Owner

    @mordocai FYI in Fira symbols visually take multiple character places but marked as taking just one (rightmost) single place:

    screen shot 2016-08-11 at 13 14 42

    So in fact when I do ligature substitution in font code, I replace e.g. hyphen hyphen greater with space space hyphen_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.

    Hope that helps.

  6. emmanueltouzery commented on Aug 13, 2016

    @emmanueltouzery

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

  7. emmanueltouzery commented on Aug 13, 2016

    @emmanueltouzery

    to fix the =<< in the gist =>

              ("\\(=<<\\)"                   #Xe142)    (changed from ==<)
              ("[^-=]\\(<<\\)"               #Xe15c)    (excluded the = before the << as well)
    

    this is for the overzealous cross:

              ;; ("\\(x\\)"                     #Xe16b)
    

    would need to require non-word characters before & after but my emacs regex-fu is weak for that, so I just commented that locally.

  8. siegebell commented on Aug 13, 2016

    @siegebell

    For example, this should only match 'x' if the preceding character is a number and the subsequent character is either a number or letter:

              ("[0-9]\\(x\\)[0-9a-fA-F]"                     #Xe16b)

    edit: changed a-F to a-f

  9. emmanueltouzery commented on Aug 13, 2016

    @emmanueltouzery

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

              ("\\b\\(x\\)\\b"               #Xe16b)
    
  10. emmanueltouzery commented on Aug 13, 2016

    @emmanueltouzery

    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.

  11. 39 remaining items

  12. clembu commented on Nov 26, 2019

    @clembu

    thankfully!

  13. xieve commented on Dec 1, 2019

    @xieve

    @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
    
  14. AllanZyne commented on Dec 12, 2019

    @AllanZyne

    @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
    
  15. xieve commented on Dec 12, 2019

    @xieve
  16. AllanZyne commented on Dec 12, 2019

    @AllanZyne

    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!

  17. modified the milestones: 3, 4 on Apr 9, 2020
  18. modified the milestones: 4, 5 on May 16, 2020
  19. modified the milestones: 5, 6 on Jun 9, 2020
  20. MonsieurPi commented on Jul 16, 2020

    @MonsieurPi

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

    • Ubuntu 20.04 LTS
    • emacs 26.3
    
    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?

  21. xieve commented on Jul 16, 2020

    @xieve

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

  22. removed this from the 6 milestone on Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions