Search code examples
javascripthtmlopentype

can i add a opentype feature in html/css?


is it possible to add a opentype features and lookups directly on html?

like adding a kern lookup, Because the font dos not have propre kerning...


Solution

  • No.

    OpenType features are either in the font, and then you can toggle them using CSS font features, or they're not in the font, and then you can't toggle them because there's nothing to toggle. There is no mechanism for you to add features to a font using normal HTML/CSS or standard JS Web APIs.

    (but: if you think you know enough about a font to add kerning, contact the person(s) who made it and offer them your kerning data, and then they can decide whether that contribution preserves the look and feel of typeface they designed)

    Now... can you write some JS that fetches the file, parses the response byte data as an opentype data structure, injects/replaces a payload for adding GPOS information specific to the internal cmap subtables, then repacks it with all the offsets updated to reflect the new bytecode layout, and reload it as a webfont from a data-uri? In theory, yes, but if you know how to do that, you also already know why you shouldn't do that, so practically speaking: still no =)