On 2010-12-12 Wolfgang Schuster <[email protected]> wrote:

> > Maybe it is possible that the \sc macro can check if the font contains the
> > small caps as a feature. Is there a switch like
> > \doiffontfeatureexists{smcp}{...}?
> 
> \startluacode
>     function commands.doifelsecurrentfonthasfeature(name)
>         local f = fonts.identifiers[font.current()]
>         f = f and f.shared
>         f = f and f.otfdata
>         f = f and f.luatex
>         f = f and f.features
>         commands.doifelse(f and (f.gpos[name] or f.gsub[name]))
>     end
> \stopluacode
> 
> \def\doifelsecurrentfonthasfeature#1%
>   {\ctxlua{commands.doifelsecurrentfonthasfeature("#1")}}
> 
> \let\normalsc\sc
> \definefontfeature[smcp][smcp=yes]
> \definefontfeature[latn][script=latn]
> 
> \unexpanded\def\sc{\doifelsecurrentfonthasfeature{smcp}{\addfs{smcp}}\normalsc}
> 
> \starttext
> 
> \tf text \sc text
> 
> \switchtobodyfont[cambria]\addfs{latn} % cambria needs the latin script for
> smallcaps
> 
> \tf text \addfs{smcp} text
> 
> \switchtobodyfont[modern]
> 
> \tf text \sc text
> 
> \stoptext
That's a nice piece of code! Thanks for your effort.

Marco


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to