[XeTeX] Diacritics in color

mskala at ansuz.sooke.bc.ca mskala at ansuz.sooke.bc.ca
Thu Dec 1 00:09:09 CET 2011


On Wed, 30 Nov 2011, Khaled Hosny wrote:
> processed by the layout engine, which would require keeping account of
> character to glyph mapping (which is doable, all text editing GUI's have
> to do it).

It will, of course, have to do something sensible (even if that just means
complain) should the desired location of a reinserted special end up in
the middle of a ligature.

Suppose someone types

   f\textcolor{red}{f}

and the font tries to replace the two fs with an ff ligature.  In that
case there is no sensible way to colour just the second one red.
Changing the colour of a mark and not the base is different from changing
the colour of just part of a ligature, and the system can certainly
distinguish mark-to-base from ligatures; but especially if colour is
handled by a special that the TeX engine only understands as an opaque
blob of data, it'll be hard for the engine to know what is the right thing
to do with the above.

In the Korean fonts I'm currently working on, some syllables are converted
to single precomposed glyphs by ligature substitution, and others are
built up by overlaying zero-width glyphs, and the difference between the
two ways of drawing syllables should ideally not be visible to the user.
(This approach is driven by Unicode, which specifies roughly 11000 code
points for entire Korean syllables, but a more complicated way of
expressing the several hundred thousand imaginable syllables that do not
have code points of their own.)  The zero-width glyphs also change their
shapes contextually.  Suppose someone tries to change the colour of just
one of the sub-glyphs in what would otherwise be a precomposed syllable.

Well, if that breaks the glyph sequence for the purposes of the ligature
substitution, it's actually a good thing.  It means my font will fall
back on the overlaid zero-width glyphs, and then just the one the user
picked will change colour, and the user will get what they wanted.  The
layout of the overlaid combination won't be quite as good as if the font
had been allowed to use a precomposed glyph, but there isn't really any
better way it could work.

Trouble is, the overlaid zero-width glyph method also depends on
contextual substitutions (because there are actually six different layouts
for an overlaid syllable, used to approximate the more nuanced layout
decisions that go into the precomposed glyphs).  If the colour special
interrupts the glyph sequence for the purpose of those contextual
substitutions, then the font will end up falling all the way back to its
default layout (or, even worse, different layout guesses for different
parts of the same syllable) and the result will be unacceptable.  The
ideal for my fonts would be if colour specials interrupted the glyph
sequence in the liga feature - thus preventing ligature substitution from
occurring - but not in the ccmp, ljmo, or vjmo features.  What would be
ideal in some other font might be different from that.

I don't know the right answer to how it should work, but I'm highlighting
this issue just because I hope anyone who tries to implement a solution
will think carefully about the consequences for multiple cases.
-- 
Matthew Skala
mskala at ansuz.sooke.bc.ca                 People before principles.
http://ansuz.sooke.bc.ca/


More information about the XeTeX mailing list