[XeTeX] \XeTeXglyphbounds question

Jonathan Kew jfkthame at googlemail.com
Mon Feb 7 13:04:05 CET 2011


On 7 Feb 2011, at 11:42, Will Robertson wrote:

> On 2011-02-04 23:57:38 +1030, Jonathan Kew <jfkthame at googlemail.com> said:
> 
>> On 4 Feb 2011, at 05:41, Adam Twardoch (List) wrote:
>>> I could use:
>>> \XeTeXcharglyph`f
>>> but this only gives me the glyph ID of the *default* glyph for the "f"
>>> character. Yet since the font uses contextual alternates, I may end up
>>> having any alternate "f" there, depending on the contents of \sampletext
>>> So: how do I find out which glyph ID is the first (or 2nd, or last, for
>>> that matter) in my box?
>> Unfortunately, I don't think there's currently any way to do that.
> 
> 
> This reminds me that it would also be very useful to be able to differentiate glyphs when OT features are applied; e.g., if \XeTeXcharglyph expanded to different values according to the currently enabled font features (and contrarywise allow you to detect when a feature doesn't affect a certain glyph).
> 
> Is this a fundamental limitation with the means by which XeTeX handles \XeTeXcharglyph?

Well, not exactly, but it's true that \XeTeXcharglyph currently looks *only* at the character-to-glyph mapping of the font, it does not consider OpenType features.

> In a way, it's surprising that
> 
> \font\1="[texgyrepagella-regular.otf]" at 12pt
> \font\2="[texgyrepagella-regular.otf]:+smcp" at 12pt
> 
> \1 a: \the\XeTeXcharglyph`\a /
> \2 a: \the\XeTeXcharglyph`\a
> 
> would result in the same glyph slot.

Yes, I know; this has come up previously, IIRC. One issue to keep in mind is that \XeTeXcharglyph would still not necessarily tell you which glyph will end up being used for any particular instance of "a" in your text, as they may be modified by *contextual* substitutions. And for the same reason, it would not be a reliable way to determine whether "a feature does[n't] affect a certain glyph", because the feature might affect the glyph in question only in certain contexts, not in isolation.

So while I think I agree that it would be good for \XeTeXcharglyph to respect the font's selected OT features, it's important to recognize the limitations inherent in *any* API that tries to get glyph information at the level of individual characters. I worry that people will start assuming that they can identify which characters are affected by a given feature on the basis of an API like this, which is a fundamentally flawed approach.

JK




More information about the XeTeX mailing list