[XeTeX] Checking for existence of font feature

Khaled Hosny khaledhosny at eglug.org
Thu Aug 12 08:46:54 CEST 2010


On Thu, Aug 12, 2010 at 04:53:16AM +0100, Michael Lynch wrote:
> 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…

All were introduced in version 2, I think.

> 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?

Since those command use expl3 syntax, you will need \ExplSyntaxOn before
using them.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer


More information about the XeTeX mailing list