<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><pre>dears Jonathan, <span class="email">Adam and others,</span><br><br>I know, that in icu-project, they haven't yet done any OpenType justification support yet;<br>so, I simulate this feature in a web code.<br>Adding APIs to OpenTypeLayoutEngine to discover the minimum and maximum<br>widths that a given word can have, and taking into account justification alternates, <br>will be a second step. or it can be done using libotf library. <br>I start with a prior knowledge that some glyph has alternatives with different widths.<br>and I'm focussing essentially the line break algorithm, in the adv_past subroutine of line_break routine, I make a parallel calculation; the first<br>based on the default width of the node, and the second using alternative glyph. in the end of line I will <br>choose the best with the minimum demerit.<br>But I don't know how can I access
 to glyphs informations using xetex primitives within the web code.<br><br><span style="font-family: arial;"></span>&nbsp;<br><br></pre><br>--- En date de&nbsp;: <b>Mar 20.1.09, Jonathan Kew <i>&lt;jonathan@jfkew.plus.com&gt;</i></b> a écrit&nbsp;:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">De: Jonathan Kew &lt;jonathan@jfkew.plus.com&gt;<br>Objet: Re: [XeTeX] glyph index<br>À: "Unicode-based TeX for Mac OS X and other platforms" &lt;xetex@tug.org&gt;<br>Cc: franc_milo@yahoo.fr<br>Date: Mardi 20 Janvier 2009, 17h09<br><br><pre>On 20 Jan 2009, at 15:40, franÿffffe7ois franc wrote:<br><br>&gt; &gt;Do you really mean that you want to substitute one *glyph* for<br>another, or do you want<br>&gt; &gt;to substitute a *character* in a certain context? Maybe you could give<br>a<br>&gt; &gt;real-life example to make it clear what you're trying to achieve.<br>&gt; <br>&gt; Actually I'm trying to use jalt
 (justification alternative) of OT<br>font, to improve line<br>&gt; justification, so I'm working to<br>&gt;  modify the line breaking algorithm. thus I want that the<br>&gt; substitution to be independent of the font engine.<br>&gt; and the replacement happens only if that improves the line justification.<br><br>Ok, I see. In that case, I think you have several problems to worry about! This<br>is not a straightforward thing to do...<br><br>There are a couple of approaches to consider: you could choose line-breaks<br>first, based on the default widths of the words, and then use justification<br>alternates where possible to improve each individual line (this is the simpler<br>option, essentially done within the hpack() routine); or for the very best<br>results, at the cost of extra complexity, you could allow the availability of<br>the alternates to affect which line-breaks are chosen. This would be quite a bit<br>trickier, I think.<br><br>If you
 substitute a glyph from a 'jalt' feature, the positions of other<br>glyphs will need to be recomputed, and indeed other glyphs might need to be<br>substituted as well (e.g., if there are contextual alternates that vary<br>depending which glyph from 'jalt' is chosen). In general, you can't<br>just do the 'jalt' substitution after the rest of OpenType layout<br>processing has been done; that lookup needs to be applied at the proper place in<br>the overall sequence of OT lookups.<br><br>I think the best way forward will probably be to implement this as an extension<br>to the OpenType layout engine itself, rather than trying to do the justification<br>alternates as a separate step outside the main OT layout process. E.g., you<br>could add APIs to OpenTypeLayoutEngine to discover the minimum and maximum<br>widths that a given word can have, taking into account justification alternates,<br>and then use this information to help the line-breaking routine. Then,
 having<br>chosen the breaks, you'd have to set the appropriate 'jalt' features<br>on the words to get the best fit; only then can you get the final positioned<br>glyph data back from the layout engine.<br><br>Anything you do here should be designed to fit in with the ICU layout engine<br>APIs, and if possible, pushed upstream to the original ICU project. As far as I<br>know, they haven't yet done any OpenType justification support yet;<br>there's an open ICU ticket on this, but no activity AFAIK.<br>http://www.icu-project.org/trac/ticket/1072<br><br>JK<br><br></pre></blockquote></td></tr></table><br>