# [XeTeX] Several apostrophe-related problems (kerning, mapping)

Pierre Morel pier.morel at gmail.com
Sun Oct 31 19:14:12 CET 2010

Thank you John, your hack indeed solves the problem when U+0027 apostrophes are replaced with U+2019 apostrophes (I did not try to make U+0027 active) and when the margin kering is not activated.

However, replacing U+0027 with U+2019 apostrophes showed that the margin-kerning bug is not due to the tex-text mapping : even when the apostrophes are U+2019 in the source file, they are replaced by U+0027 apostrophes in the PDF !! And this only for the font for which margin kerning is activated.

Any ideas on this last problem ?

Le 31 oct. 2010 à 16:32, John Was a écrit :

> Hello
>
> I can't help with the marginal kering (which I don't use), but here is what I do in a font that also had overtight kerning associated with apostrophes:
>
> \catcode"2019=\active
> \def’{\leavevmode \kern 1sp \hbox{'}}
> \catcode"201D=\active
> \def”{\leavevmode \kern 1sp \hbox{''}}
>
> Note that the characters in the \hboxes are the ordinary straight apostrophe (since I also use TeX mapping in my font calls.)
>
> As it stands, this would involve you actually using the correct Unicode characters 2019 and 201D for closing single and double apostrophes in your document, in spite of your tex-mapping - and I guess you could achieve this by global search-and-replace in your file.  But you  may be able to do much the same thing by making 0027 active instead (I haven't tried that - I can see a potential danger of a loop if you are using 0027 to define itself).
>
> I'm sure there are more elegant solutions - and I use plain TeX so there may be LaTeX issues that I don't know about.
>
> (Of course, if my request for custom kerning could be met, we would all be able to refine the kerning of any font at will.  Unfortunately, someone in another thread explained that that is very difficult in XeTeX because of the way it looks up font information (LuaTeX can do it because it has another method of accessing the font's tables).  I was rather hoping that someone would see that as an opportunity to show off hrs computing prowess by performing the miracle - but this hasn't happened yet.)
>
> John
>
>
>
> ----- Original Message ----- From: "Pierre Morel" <pier.morel at gmail.com>
> To: "Unicode-based TeX for Mac OS X and other platforms" <xetex at tug.org>
> Sent: 31 October 2010 15:02
> Subject: [XeTeX] Several apostrophe-related problems (kerning, mapping)
>
>
> Hello,
>
> My thesis is finished soon, but I have an annoying apostrophe problem.
>
> In French we have a lot of apostrophes uses like this : L'œil, l'incertitude, etc.
> In theory, these apostrophes should be the unicode character U+2019 (right single quotation mark) instead of a straight apostrophe (U+0027). This replacement is automatically made by this command : \defaultfontfeatures{Mapping=tex-text}
>
> First there is a problem with the kerning of this U+2019 character, it is possibly a bug in the font I'm using (Adobe Caslon Pro), but I'd like to solve it anyway.
> Here is an example (The word L'œil, on the top right) :
> http://dl.dropbox.com/u/1205127/Images/xetex.jpg
> The apostrophe is completely kerned above the "œ" (the same problem is present for any small character), which thus touches the "L".
> So my first question is: is there a way to override the default kerning of this U+2019 character so that it behaves in a more correct way (with a slight space between the apostrophe and the next letter) ?
>
> Now there is a second problem (which solved the first one but in a bad way).
> When activating margin kerning, xetex behaves as if the line \defaultfontfeatures{Mapping=tex-text} was not present : U+0027 apostrophes stay straight (which curiously solves the kerning problem, see the example on the top left of the image), and  and '' are not converted appropriately (more annoying).
> Here is what I use for the margin kerning (when I comment these line, the mapping problem is corrected) :
>
> \newcount\countA
> \ifx\XeTeXprotrudechars\undefined
>   \pdfprotrudechars=2
> \else
>   \let\pdftexversion=\countA
>   \pdftexversion = 140
>   \XeTeXprotrudechars=2%\fi
> \input protcode-native
> \font\f="Adobe Caslon Pro" at 11pt \f
> \setprotcode\f
>      \pretolerance=-1
>       \tolerance=9999
>       \emergencystretch=2em
>
> With the file protcode-native file being
>
> \def\setprotcode#1{
>   \rpcode#1 U"0021    55
>   \rpcode#1 U"002C    194
>   \rpcode#1 U"002D    233
>   \rpcode#1 U"002E    194
>   \rpcode#1 U"003B    138
>   \rpcode#1 U"003A    138
>   \rpcode#1 U"003F    94
>   \lpcode#1 U"2018    194
>   \rpcode#1 U"2019    194
>   \rpcode#1 U"0027    194
>   \lpcode#1 U"201C    250
>   \rpcode#1 U"201D    250
>   \rpcode#1 U"2013    150
>   \rpcode#1 U"2014    200
> }
>
> So, in short, I want to use margin kerning while maintaining the tex-text mapping AND having a correct kerning with the U+2019 apostrophe.
>
> PS: (this last problem also appears on my sans serif font (Myriad pro), an example is visible in the linked image.
>
> Thank you,
>
> Pierre
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
> http://tug.org/mailman/listinfo/xetex
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
> http://tug.org/mailman/listinfo/xetex