Re: Ligatures, kerning, ZWNJ & OpenType

From: John Hudson (john@tiro.ca)
Date: Sun Jul 15 2007 - 12:17:32 CDT

  • Next message: Marcin 'Qrczak' Kowalczyk: "Re: Ligatures, kerning, ZWNJ & OpenType"

    Marcin 'Qrczak' Kowalczyk wrote:

    > Forming a syllable is mandatory when a consonant is followed by a vowel,
    > except in rare cases where it's prohibited. I'm currently using OpenType
    > ligatures for that. How to encode the case where forming a syllable is
    > prohibited?

    > I suppose the answer is ZWNJ, even if it was meant to be advisory.
    > Unfortunately, in XeTeX at least (which uses ICU) ZWNJ inhibits kerning,
    > or perhaps requires separate kerning rules for cases involving ZWNJ.
    > And I need lots of kerning rules for pleasant results (the primitive TTF
    > "kern" table size limit was too small, and "GPOS" takes 52kB). Is it
    > possible to specify in a font that ZWNJ should be transparent for
    > kerning, so it only prevents forming ligatures? If it requires separate
    > rules for separate combinations, how to specify the kerning of triplets
    > with invisible ZWNJ in the middle?

    I believe ZWNJ should *not* inhibit kerning, and given the way GPOS kerning works it
    should be possible for a layout engine to apply the kern feature after the control
    character glyphs have been stripped from the glyph stream. I don't know why they don't.

    But it sounds like you're going to need a workaround...

    The trouble with trying to kern a triplet with the invisible ZWNJ in the middle is that
    the ZWNJ is, well, invisible, which means that there is no glyph to which kerning can be
    applied. In any case, this approach would be very complex because what you would actually
    need to do is kern one of the letters to the ZWNJ glyph, presuming you could see it, in
    context of the second letter. This would be a very cumbersome approach, requiring a huge
    number of lookups.

    I have another idea for a workaround:

    Put duplicate letter glyphs in the font for any letter that might precede a ZWNJ, i.e. for
    any letter that might be prohibited from forming a syllable with a following letter in
    some situations. Call them something like 'letter_ZWNJ'. In the OT Layout GSUB table,
    include a lookup that either substitutes the base letters for these duplicates in context
    of a following ZWNJ:

            letter -> letter_ZWNJ
            | ZWNJ

    or performs a ligature substitution:

            letter ZWNJ -> letter_ZWNJ

    The latter might be more consistent with your approach to syllable building. These lookups
    should precede your syllable-forming ligations and, of course, the key is that

            letter + letter = syllable

    but

            letter_ZWNJ + letter ≠ syllable

    The letter_ZWNJ glyphs should have the same kerning as the letter glyphs, solving your
    problem.

    John Hudson

    -- 
    Tiro Typeworks        www.tiro.com
    Gulf Islands, BC      tiro@tiro.com
    We say our understanding measures how things are,
    and likewise our perception, since that is how we
    find our way around, but in fact these do not measure.
    They are measured.   -- Aristotle, Metaphysics
    


    This archive was generated by hypermail 2.1.5 : Sun Jul 15 2007 - 12:22:56 CDT