Substituting keywords with symbols

I recently came across and love how you can substitue a string (keyword) with a symbol. I got this to work by using the liga feature and simply substituting a chain of characters with a unicode character:

def k e y w o r d by E001;

Is there a better way of doing this? Any idea how the Symbolset guys might be approaching this?

You mean: sub k e y w o r d by uniE001;

A few thoughts:

  1. If you actually use a Unicode, e.g. uniE000 or uniE001, you don’t really need such a replacement. You can type, copy and paste encoded characters, also in the Private Use Area (uniE000 - uniF8FF), or in HTML, you just type & # x E000 ; (without the spaces).

1.1. Many of these symbols actually already have their own Unicode. So, you don’t need to put them into the PUA and your font will be more compatible. You can find the respective code points easily with UnicodeChecker or websites such as Codepoints.

  1. If you want them just as ligatures, you’d be better off calling them h_o_m_e.liga, then Glyphs can build the liga feature for you automatically.

  2. Ask yourself if you really want them in the Standard Ligatures (liga), since this can be pretty annoying for the user. Imagine trying to write ‘homer’ or ‘homey’, and every time, the ‘home’ part gets replaced by the home symbol. If OTOH you just call it h_o_m_e (without the ending), Glyphs will automatically place your substitutions in the discretionary ligatures (dlig) which are off by default and need to be activated by the user.

  3. Since what you want to do is language specific, the localization feature (locl) might be a better place for these substitutions. Alternatively, you can put something like script latn; followed language ENG; or language DEU; before your substitutions. This way, you can even add support for more than one language.

Thank you for the detailed response. I did mean sub (guilty Rubyist here).

Do you have an example on how to use locl? The reason behind this is I would like to be able to write markup like this keyword instead of having a glyph that might or might not degrade gracefully (it won’t if it’s in PUA).

Is this for a website? Then substitutions won’t work anyway except for IE10, the latest Firefox and a recent Webkit nightly, I think.

The closest thing you can get with features, is solution 2 from above and then activate standard ligatures (different for every browser) in the element’s CSS. It will work in those few browsers that support it and just not replace in the other browsers.