Contextual kerning across multiple HTML tags (webfont)

Hello everyone,

I’m having two issues that I can’t seem to solve pertaining to the application of webfonts.

The first is that line breaks and new html tags (<span>, <a>, etc.) are (understandably) read by the font as new blocks of text, which means contextual alternates, contextual kerning and so on don’t work across multiple lines, tags, etc… So if you have, say:


then any kerning or alternates set up for an XY pair are ignored because the two letters don’t know the other exists.

Here is an example using my font (this is ancient Egyptian in RTL):

The top line works as planned (the group on the right is actually four separate symbols contextually substituted and pushed together with contextual kerning. However, if I convert the left half into a hyperlink (indicated by the grey box), the font no longer knows to add extra kerning to the last of the group of four, because as far as it’s concerned, the text block has ended.

Now it’s understandable why this is happening, I was just wondering if anyone was aware of, or had found, a workaround…?

Any help would be greatly appreciated!!

I’m going to post my second question separately to keep this from getting too long.

Thanks for your time,


The first line of defense is to make the font work as well as possible without kerning. I cannot really tell from the screenshot, but my guess is that some of the glyphs have negative sidebearings? Avoid situations where you need positive kern pairs, prefer negative kern pairs. Or that the addition on the side of that one letter should be a spacing (rather than a nonspacing) mark. Again, hard to tell from just the screenshot.

Otherwise you should be able to find a solution in CSS.

I would try to make the spacing of the left block in a way that it is independent of further context. I don’t know if that that is practical in this case.

OK, thanks for the quick reply guys. I’ll just take care of the spacing in those cases in the JavaScript mirroring, then.

Thanks again.

Hello again,

Thanks again for the quick reply.

I’m assuming on a similar note that if I have a string of characters that are always within <a> tags throughout the text, there’s no way to avoid that string always looking identical, because the loop through the contextual alternates will start over each time? So, for example:

<p>test <a>link</a> test <a>link again</a> test <a>link three</a></p>

in a handwriting font would render the word “test” and the word “link” identically in every instance, and that’s unavoidable?



That depends on the way you set up your context feature. You can add some look ahead substitutions. The Beowulferize script is doing that:

Wow, this is great! Thanks, I’ll look into it.

There’s one last n00b assumption I’m making. I’m assuming there’s no way to test for the end of a line or block in the feature itself? Something like:

sub @CLASS1 @CLASS2eol/nothing/etc by @CLASS2_END;

Or can this be taken care of in Python (if so, I’ll look into it)?

Thank you very much!!

This can be done with an ignore statement.

Got it. That was the nudge I needed.

Thank you!