[XeTeX] glyph index

Jonathan Kew jonathan at jfkew.plus.com
Tue Jan 20 17:09:40 CET 2009


On 20 Jan 2009, at 15:40, franÿffffe7ois franc wrote:

> >Do you really mean that you want to substitute one *glyph* for  
> another, or do you want
> >to substitute a *character* in a certain context? Maybe you could  
> give a
> >real-life example to make it clear what you're trying to achieve.
>
> Actually I'm trying to use jalt (justification alternative) of OT  
> font, to improve line
> justification, so I'm working to
>  modify the line breaking algorithm. thus I want that the
> substitution to be independent of the font engine.
> and the replacement happens only if that improves the line  
> justification.

Ok, I see. In that case, I think you have several problems to worry  
about! This is not a straightforward thing to do...

There are a couple of approaches to consider: you could choose line- 
breaks first, based on the default widths of the words, and then use  
justification alternates where possible to improve each individual  
line (this is the simpler option, essentially done within the hpack()  
routine); or for the very best results, at the cost of extra  
complexity, you could allow the availability of the alternates to  
affect which line-breaks are chosen. This would be quite a bit  
trickier, I think.

If you substitute a glyph from a 'jalt' feature, the positions of  
other glyphs will need to be recomputed, and indeed other glyphs might  
need to be substituted as well (e.g., if there are contextual  
alternates that vary depending which glyph from 'jalt' is chosen). In  
general, you can't just do the 'jalt' substitution after the rest of  
OpenType layout processing has been done; that lookup needs to be  
applied at the proper place in the overall sequence of OT lookups.

I think the best way forward will probably be to implement this as an  
extension to the OpenType layout engine itself, rather than trying to  
do the justification alternates as a separate step outside the main OT  
layout process. E.g., you could add APIs to OpenTypeLayoutEngine to  
discover the minimum and maximum widths that a given word can have,  
taking into account justification alternates, and then use this  
information to help the line-breaking routine. Then, having chosen the  
breaks, you'd have to set the appropriate 'jalt' features on the words  
to get the best fit; only then can you get the final positioned glyph  
data back from the layout engine.

Anything you do here should be designed to fit in with the ICU layout  
engine APIs, and if possible, pushed upstream to the original ICU  
project. As far as I know, they haven't yet done any OpenType  
justification support yet; there's an open ICU ticket on this, but no  
activity AFAIK. http://www.icu-project.org/trac/ticket/1072

JK



More information about the XeTeX mailing list