Font Features Land in Inkscape Trunk

I’ve just landed basic font features support in the development version of Inkscape. What are font features and why should you be excited? (And maybe why should you not be too excited.)
The letter combination 'st' shown without a ligature and with a 'historical' ligature.

Font Features

Font features support allows one to enable (or disable) the OpenType tables within a given font, allowing you to select alternative glyphs for rendering text.
A series of examples showing the same text with and without applying various OpenType tables.

A sample of font features in action. The font is Linux Biolinum which has reasonable OpenType tables. Try the SVG (with WOFF).

The new CSS Fonts Module Level 3 adds a variety of CSS properties for defining which OpenType tables to enable/disable (as well as having nice examples of each property’s use — this is one of the more readable W3C specifications). Inkscape trunk supports the ‘font-variants-liguatures’, ‘font-variant-caps’, ‘font-variant-numeric’, ‘font-variant-position’, and ‘font-feature-settings’ properties. The properties can be set under the Variants tab in the Text and Font dialog.
The 'Variants' Tab in the 'Text and Fonts' dialog showing a series of buttons to select which font features are enabled.

The Variants tab in the Text and Font dialog.

Why you shouldn’t be too excited

Being able to enable various font features within a font is quite exciting but there are quite a few caveats at the moment:
  • One must use a trunk build of Inkscape linked with the latest unstable version of Pango (1.37.1 or greater).
  • Font feature support in fonts is usually minimal and often buggy. It’s hard to know what OpenType tables are available in which fonts.
  • Browser support is sparse. Firefox has rather good support. Chrome support seems limited to ligatures. UPDATE: As of Chrome 52, Chrome supports font features.
  • Correct display of alternative glyphs requires that the same font as used in content creation is used for rendering. On the Web the best way to do this is to use WOFF but Inkscape has no support for using User fonts (this is a future goal of Inkscape but will require considerable work).

Thanks

I would like to thank: Behdad Esfahbod, maintainer of Pango for adding the code to Pango to make accessing the OpenType tables possible. Thanks as well to Matthias Clasen and Akira Togoh who are the source of the patch to Pango. Thanks also to all the people that supported the Inkscape Hackfest in Toronto where I was able to meet and discuss Pango issues with Behdad in person and also where the idea of adding font feature support to Inkscape germinated.

9 thoughts on “Font Features Land in Inkscape Trunk”

  1. Would it make sense to grey out font features if the selected font didn’t have them? There’s obviously a computational cost to that, unfortunately.

    1. Yes, it would make sense to grey out features unsupported by the selected font. I plan on eventually implementing this. I will also look into giving a list of possible stylistic alternatives (with previews). Unfortunately, getting this information out of the fonts through Pango is not straight forward.

      1. I’ve checked in code that greys out unsupported features. This code may not be perfect as there may be different versions of the same table for different scripts and languages. A feature is grayed out only if the corresponding table doesn’t appear anywhere in the font.

        Even if a table is present it may not do what you want. For example the ‘frac’ table may only support converting 1/4, 1/2, and 3/4 to ¼, ½, and ¾ respectively (as these three values have actual Unicode points) and not the generic conversion of arbitrary fractions like 7/8.

        It would be nice to know which glyphs have stylistic alternatives but this information is buried deep inside the OpenType tables (often spread out among many tables) and there appears to be no way to access this information through Pango.

  2. Just this week, I’ve been starting to think about the lettering font for my new comic — I’ve been wanting to experiment with alternate/contextual glyphs for a long time, so this is perfect (my use case is FontForge->Inkscape->render as PNG for the web, so browser support and matched creation/render isn’t an issue). Do you know of any good tutorials/etc. for getting started with OpenType tables, particularly in FontForge?

    1. A good way to add OpenType feature support to a font is to use fonttools to convert the font to UFO (a human-ediatable, xml description of the font), add the feature, and then convert it back to OTF (or directly to WOFF).

      Use Behedad’s current, maintained port of fonttools
      https://github.com/behdad/fonttools

      1. You don’t need to create a UFO. fontTools has the TTX xml format which represents a binary font, in human-readable form.

        Secondly, FontForge fully supports OpenType features.

  3. Thanks for the replies. Looks like I should get my feet wet with standard ligatures (which are on by default in stable Inkscape), then branch out to fancier features with bleeding-edge Inkscape/Pango when I run into a lettering problem that ligatures can’t handle.

    From poking around at the Linux Biolinum TTFs in FontForge, the relevant bits appear to be in Element->Font Info->Lookups->GSUB->”liga”->Edit Data

Comments are closed.