mastodon warning! may contain trace amounts of Lisp

Character Protrusion

As punctuation seems to distort the margin's line of any block of justified text, there must be a way to kick it to outside that line, so to make the page look more neat: that is character protrusion, one of many shibboleths in typography. To do so there is in LaTeX the microtype package, that unfortunately doesn't work on XeTeX. I've swept the web in search for another way to do this, until yesterday without anything workable.

It's not an easy thing to do, specially for the hyphens, as the LaTeX engine cut each line already counting the space needed to each hyphen; if you change its position after that, there will be a hole where it should be… I guess. So the only way to make it work is editing the font (or 'typeface', before someone bites me) to have a zero-width hyphen; that is, the hyphen will not ask any space for itself, more or less like a combining diacritic, in Unicode. So, that is easy: install Fontforge, find the hyphen, and drag the width bar to 0, regenerate the font, and there it is. But what if you happen to have any hyphen in the text? It will be awkward, invading the precedent character's space.

The only way I've found to overcome that is change the hyphen character used by LaTeX to another one… in principle any other, but it would be good to have something that, when perhaps translated to pure text, would remain understandable… not like, say, a thorn (þ). Meanwhile I've learnt that HTML can have working hyphens ('soft hyphens') too. And that is nice.

Anyway, besides the ASCII hyphen (U+002D), I've found another, U+2010. This one I edited, and it doesn't mess anything. To make the change in XeTeX, use:

/setmainfont[HyphenChar={‐}]{Junicode}

The Fontspec specification mentions another way to cite the character, by its code, but I did not understand it, really. Anyhow, after that the hyphen is gone, let's just solve every other possible mark, then ; ).

A Marcus Sousa, in 1997, in an message compiled in this digest, gave almost all the solution; curiously, less than a month before, he was asking how to do exactly that, so I gather he solved it in the mean while… that's good indeed. Let's see some examples of the output:

Here, the punctuation is duly kicked out:

0002-01.png

And here:

0002-02.png

But here it doesn't work after the first o-, I have no idea why:

0002-03.png

But in normal text, it works flawlessly, as far as I can see:

0002-05.png

0002-04.png

Finally, it's not quite like optical margin alignment, because, well, it's not optical, but I very much prefer this, anyway. Now a working example and its output:

fix/0002.tex

fix/0002.pdf

And of this no more.


· © Edgard Bikelis (eſb) created using Emacs 29.0.50 (Org mode 9.5.3) ·
· created: 2008-12-24 last modified: 2022-06-09 ·