# [XeTeX] inconsistant kerning

Jonathan Kew jonathan_kew at sil.org
Mon Sep 25 20:21:24 CEST 2006

On 25 Sep 2006, at 5:13 pm, Pablo Rodríguez wrote:

> Steve Grathwohl wrote:
>> On 9/22/06, *Jonathan Kew* <jonathan_kew at sil.org
>> OK, speaking of Juncode...
>>
>> if I say
>>
>> \documentclass{article}
>> \usepackage{fontspec}
>> \setromanfont{Junicode}
>>
>> \begin{document}
>> \textsc{first}
>> \end{document}
>>
>> I get fiRST; that is, lowercase fi lig then smallcap RST. What's
>> going
>> on here? I haven't seen this behavior in any other font.
>
> This has been fixed in lastest CVS version
> (http://junicode.cvs.sourceforge.net/junicode/junicode/src/Junicode-
> Regular.sfd?view=log)
> .
>
> It has been solved by adding the small cap ligatures. But I wonder
> whether this is the right method for doing it, since if scmp where
> applied first, there would be no characters to apply the f i liga
> GSUB.
>
> To the OpenType experts: am I wrong in my previous remark?

No, you're right (except for the technicality that GSUB features
apply to *glyphs*, not *characters*).

The behavior depends not on *feature* order but on *lookup* order; a
single feature (such as 'smcp' or 'liga') may be implemented by one
or more lookups, though in practice both of these are likely to be
single lookups. See http://www.microsoft.com/typography/otspec/
gsub.htm, which tells us:

> To access GSUB information, clients should use the following
> procedure:
>
> Locate the current script in the GSUB ScriptList table.
> If the language system is known, search the script for the correct
> LangSys table; otherwise, use the script's default language system
> (DefaultLangSys table).
> The LangSys table provides index numbers into the GSUB FeatureList
> table to access a required feature and a number of additional
> features.
> Inspect the FeatureTag of each feature, and select the features to
> apply to an input glyph string. Each feature provides an array of
> index numbers into the GSUB LookupList table.
> Assemble all lookups from the set of chosen features, and apply the
> lookups in the order given in the LookupList table.
So it is the ordering of the LookupList table that controls which
substitution (lowercase -> smallcaps or separate glyphs -> ligature)
happens first, and Junicode has the order wrong.

This entry, found in the FontForge changelog somewhere between April
and July 2006, makes me suspect that a FF bug might be responsible
for this:
> lookup ordering within GSUB has been totally broken at least since
> I added the c ode to coalesce lookups for kerning.
Thus, it could be that the Junicode font was built with a buggy tool,
or it could be that the features were incorrectly specified. Either
way, it should be fixable in a better way than creating "small cap
ligatures".

JK