[Foxet] typescript definitions

Hans Hagen pragma at wxs.nl
Thu Dec 23 17:39:12 CET 2004


Adam Lindsay wrote:
> Hey all.
> 
> I'm trying to get a minimal functional, non-Foxet-specific configuration
> system going in XML (liberally stealing from x-fx). I'd  like to trim
> some of the redundancy when calling this, though:
> \defineXMLcommand
>    [setup:definetypeface] [fox] 
>    [label=default, class=rm, family=serif, name=times, 
>     size=default, rscale=1, encoding=\defaultencoding]
>    {\initializefox
>     \expanded{\definetypeface[\foxlabel] [\foxclass]
>      [\foxfamily] [\foxname] [\foxsize] [\foxarguments]}}
> 
> (All of the parameter names are arbitrary--feel free to correct me on them.)
> This works more or less as I like:
> <setup:definetypeface label="mine" family="serif" class="rm" name="palatino"/>
> <setup:definetypeface label="mine" family="sans" class="ss" name="helvetica"/>
> <setup:definetypeface label="mine" family="math" class="mm" name="palatino"/>
> 
>  ...but I'd like to get rid of the class parameter, as, for most
> everyone's purposes, it adds no information. I considered and rejected
> \mapXMLvalue, because it's from a different attribute.

hm, actually mapping is a fast and effient way to achieve this

> My first try was this, but it leaves some textual garbage.
> 
> \defineXMLcommand
>    [setup:definetypeface] [fox] 
>    [label=default, family=serif, name=times, 
>     size=default, rscale=1, encoding=\defaultencoding]
>    {\initializefox
>     \expanded{\definetypeface[\foxlabel] 
>      [\XMLifequalelse{setup:definetypeface}{family}{serif}{rm}
>       {\XMLifequalelse{setup:definetypeface}{family}{sans}{ss}
>       {\XMLifequalelse{setup:definetypeface}{family}{math}{mm}
>       {\XMLifequalelse{setup:definetypeface}{family}{mono}{tt}
>       {\XMLifequalelse{setup:definetypeface}{family}{handwriting}{hw}
>       {\XMLifequalelse{setup:definety
> peface}{family}{calligraphy}{cg}{rm}}}}}}]
>      [\foxfamily] [\foxname] [\foxsize] [\foxarguments]}}
> 
> 
> ConTeXt's XML mappings are new to me, so I'm clearly overlooking
> something. Anyone have any advice?

\usemodule[fx]

\starttext

\mapXMLvalue {fox:dtf} {serif} {rm}
\mapXMLvalue {fox:dtf} {sans}  {ss}
\mapXMLvalue {fox:dtf} {mono}  {tt}
\mapXMLvalue {fox:dtf} {math}  {mm}

\defineXMLcommand
   [define:typeface] [fox]
   [label=default, class=rm, family=serif, name=times,
    size=default, rscale=1, encoding=\defaultencoding]
   {\initializefox
    \expanded{\definetypeface
      [\foxlabel]
      [\XMLval{fox:dtf}{\XMLop\foxclass}{\XMLop\foxclass}]
      [\foxfamily]
      [\foxname][\foxsize]
      [\foxarguments]}}

\defineXMLcommand
   [setup:bodyfont] [fox]
   [label=default, class=rm]
   {\initializefox
    \expanded{\setupbodyfont[\foxlabel,\foxclass]}}

\startXMLdata
<define:typeface label="mine" family="serif" class="rm" name="palatino"/>
<define:typeface label="mine" family="sans"  class="ss" name="helvetica"/>
<define:typeface label="mine" family="math"  class="mm" name="palatino"/>

<setup:bodyfont label="mine"/>Palatino!

<define:typeface label="your" family="serif" name="times"/>
<define:typeface label="your" family="sans"  name="helvetica"/>
<define:typeface label="your" family="math"  name="times"/>

<setup:bodyfont label="your"/>Times!
\stopXMLdata

\stoptext

Do you collect these code snippet somewhere?

BTW, instead of \foxarguments, just add the encoding, rscale and handling (else 
you quickly run out of hashspace)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the Foxet mailing list