[XeTeX] Checking for existence of font feature

Michael Lynch michael.s.lynch at gmail.com
Thu Aug 12 05:53:16 CEST 2010


On 11/08/2010 22:54, Khaled Hosny wrote:
> On Wed, Aug 11, 2010 at 09:39:07PM +0100, Michael Lynch wrote:
>    
>> On 11/08/2010 20:54, Michael Lynch wrote:
>>      
>>> Hello all,
>>>
>>> I'm trying to test for the existence of an OpenType font feature before
>>> it's used in a document.
>>>
>>> I want a command that will transparently emulate an acceptable
>>> alternative in the event that the feature doesn't exist, whilst logging
>>> the problem in the log file. Since the command is part of a package I'm
>>> creating, I think this is preferable to it failing outright.
>>>
>>> One of the features I'd like to test for is small caps. I'm not
>>> optimistic, as in a plain XeTeX document,
>>>
>>> \font\a="Times New Roman:+smcp" at 12pt
>>>
>>> doesn't register as causing any problems, even though this call doesn't
>>> produce anything different to
>>>
>>> \font\a="Times New Roman" at 12pt
>>>
>>> Have I missed something? opentype-info.tex iterates through all the
>>> features, so there might be some way to check each one as it goes past,
>>> but this does seem pretty laborious. I don't really have the experience
>>> of TeX to know how to do something with that either though.
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>        
>> One thing I'd forgotten is that with XeLaTeX, fontspec warns when
>> features aren't available. Looking at the package, it seems that
>> \fontspec_check_ot_feat is responsible, but this package is about as
>> complicated as any I've looked at and I'm not quite sure how it
>> should be used.
>>
>> Will, or someone else suitably knowledgeable, can you explain how
>> this could be used for this?
>>      
> Fontspec 2 has public API for checking font features, check fontspec
> manual §18 Programing details.
>
> Regards,
>   Khaled
>
>    
Ah, thank you. Are these features (relatively) new? Rather embarrassing 
not to have spotted them, but anyway…

I've got a problem using these commands. Using XeTeX v0.9995.1 texlive 
svn 15079 on MiKTeX 2.8, fontspec 2010/08/01, none of these 
“lower-level” fontspec features I've tried work.

I've copied the appropriate example from the manual:

\fontspec_if_feature:nTF {smcp} {True} {False}.

When I just put this into the main document text there are errors, 
complaining about the font "_" not existing. When I force it to 
continue, what looks like fragments of Metafont code appear on the 
console, presumably when it's given up on finding the font "_". What do 
I need to encapsulate it in to make it work? Could someone be kind 
enough to give a working example of it?

Regards,

Mike



More information about the XeTeX mailing list