[luatex] Kerning: when does it not work?

Paul Isambert zappathustra at free.fr
Wed May 4 11:11:42 CEST 2011


Le 04/05/2011 10:34, Ulrike Fischer a écrit :
> Am Tue, 03 May 2011 16:58:28 +0200 schrieb Paul Isambert:
>
>
>>> Regarding Till's concrete problems (\url and biblatex) I wouldn't
>>> bet that they insert only penalties between the glyphs.
>> I haven't been able to run the example correctly (my LaTeX installation
>> is far from maintained, let alone LuaLaTeX). For instance I haven't been
>> able to make the feature file work. Anyway I've analysed what is produce
>> by \url{http://}, and the result is (nodes are separated by space; for
>> glyphs I give the character):
>>
>> math_node h t t p glue_node : glue_node / / math_node
>>
>> So the problem here stems from glues, not penalties, between characters.
>> I suppose that's the same with biblatex (glues around the slash in e.g.
>> 6/2, to allow linebreaking). And it would be totally absurd to require
>> that kern pairs be applied across glues; on the other hand, a
>> LuaTeX-aware package should be able to mark such glues (e.g. with
>> attributes) and to insert the kerns with something similar to the code
>> I've proposed.  Yet it would seem much more logical to me to insert real
>> penalties instead of phantom spaces (I've checked, those spaces have no
>> width nor stretch nor shrink, so they're really here for the line break,
>> I suppose),
> url.sty is rather complicated. Roughly (I don't know the details)
> the urls are set in mathmode. At the start url sets the mathcode of
> various chars. E.g. dot and slash get the mathcode of a binary
> operator, the colon of a relation. Some chars are "mathactive" (e.g.
> the %).
>
> This means that line breaking is done with the math rules.
>
> I can get the wanted kerning if I remove the colon and the slash
> from the break/big break list and declare them as ordinary
> characters:
>
> \documentclass{article}
> \usepackage{url}
> \urlstyle{same}
> \usepackage{fontspec}
> \setmainfont[FeatureFile=mybonum.fea]{TeX Gyre Bonum}
>
> \begin{document}
> http:// \url{http://}
>
> \def\UrlBreaks{}
> \def\UrlBigBreaks{}
> \def\UrlOrds{\do\*\do\-\do\~\do\'\do\"\do\-\do/\do:}%
>
> \url{http://}
>
> \end{document}
>
> So I think the problem is that no kerning is inserted in math mode
> e.g. between a relation and a normal char.
>
> At my opinion it doesn't make much sense to try to add functions to
> the kerning callback. One should try to rewrite \url for lualatex. I
> doubt that with luatex all this mathcode-tweaking is necessary.
> After all you only want to type a text with some catcode changes and
> insert some break points. Also url does contain some encoding (OT1,
> TI, LY1) specific code which could bite when you are using unicode
> fonts.

As noted by Ulrike, the problem is mathmode, which I had overlooked; but 
that's not the end of the story, otherwise we could kick in the 
"mlist_to_hlist" callback and add our function (actually not so easy, 
because of subboxes and the like). The problem is that this code tested with

$\rm V\hskip0pt e$

doesn't work because a font kern is already inserted after V by the 
math-to-horizontal algorithm for reasons I don't know but probably 
explained in appendix G of the /TeXbook/. (Note that perhaps it works 
nonetheless with a pair of slashes.)

I agree with Ulrike that hacking around isn't a solution; the url 
package should be rewritten to work properly with LuaTeX. Two things, in 
my opinion, should be corrected: replace zero-width glues with proper 
penalties, and avoid math mode. With LuaTeX, where most aspects of TeX 
can be modified or at least inspected, using math mode for material that 
isn't maths should be avoided, I suppose. I don't know what the package 
does precisely, but rewriting it to manipulate nodes directly should be 
rather easy: typeset the url in a box (so proper kerning is added), then 
add penalties automatically before/after some characters.

So, Till, you're most unfortunate. On the other hand, could the fine 
typography you're trying to achieve (as exemplified by your attention to 
kerns) tolerate such things as urls in the main text? Wouldn't they be 
better placed in a footnote of their own, with linebreak done by hand? 
Oh, yes, I'm drowning the fish, as we say in French :)

Best,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20110504/3c796f08/attachment-0001.html>


More information about the luatex mailing list