Am 12.12.2010 um 16:22 schrieb Marco:

> On 2010-12-12 Wolfgang Schuster <schuster.wolfg...@googlemail.com> wrote:
> 
>>> Depending on your answers, I would perhaps request to trigger
>>> \setff{smallcaps} by \sc in the core.
>> 
>> Can be a problem because we have font (e.g. Latin Modern) where
>> smallcaps are still in a separate file.
> So the user has to know in which fashion the small caps were created, as font
> feature or in a seperate file. That's not very convenient. When the user
> switches to another font it may break the document, since he has to change the
> \setff{smallcaps} to \sc.
> 
> 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}{...}? I have the following logic in mind:
> 
> 1) Check if small caps are a font feature, if not
> 2) check if small caps are in a seperate font, if not
> 3) fake them.

\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

Wolfgang

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

maillist : ntg-context@ntg.nl / 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