Difference between revisions of "Simple Typescript Example"

From Wiki
Jump to navigation Jump to search
Line 1: Line 1:
(not finished now)

Revision as of 16:52, 21 August 2010


To map Nimbus Sans on rm-fonts and Nimbus Serif on ss-fonts.


The Nimbus Sans and Nimbus Serif fonts are installed at your System and also recognized by ConTeXt. If

mtxrun --script fonts --list --all --pattern=nimbus*

does not shows you minimum:

nimbusromno9lmedi          nimbusromno9lmedi        utmb8a.afm
nimbusromno9lmedibold      nimbusromno9lmedi        utmb8a.afm
nimbusromno9lmediital      nimbusromno9lmediital    utmbi8a.afm
nimbusromno9lregu          nimbusromno9lregu        utmr8a.afm
nimbusromno9lreguital      nimbusromno9lreguital    utmri8a.afm
nimbusromno9lregunormal    nimbusromno9lregu        utmr8a.afm
nimbussanlbold             nimbussanlbold           uhvb8a.afm
nimbussanlboldital         nimbussanlboldital       uhvbo8a.afm
nimbussanlregu             nimbussanlregu           uhvr8a.afm
nimbussanlreguital         nimbussanlreguital       uhvro8a.afm
nimbussanlregunormal       nimbussanlregu           uhvr8a.afm

please visit the instruction how to install fonts to MkIV.

You do not have to use this Nimbus fonts. For this example you can use any Unicode font you like. If you use different fonts do not forget to exchange the font names in the example script below.




\starttypescript [serif] [nimbus] 
  \definefontsynonym [Serif]        	   [name:nimbussanlregu]
  \definefontsynonym [SerifBold]	   [name:nimbussanlbold]
  \definefontsynonym [SerifItalic]         [name:nimbussanlreguital]
  \definefontsynonym [SerifSlanted]        [name:nimbussanlreguital]
  \definefontsynonym [SerifBoldItalic]     [name:nimbussanlboldital]
  \definefontsynonym [SerifBoldSlanted]    [name:nimbussanlboldital]
  \definefontsynonym [SerifCaps]           [name:nimbussanlregu]

\starttypescript [sans] [nimbus] 
  \definefontsynonym [Sans]        	  [name:nimbusromno9lregu]
  \definefontsynonym [SansBold]		  [name:nimbusromno9lbold]
  \definefontsynonym [SansItalic]         [name:nimbusromno9lreguital]
  \definefontsynonym [SansSlanted]        [name:nimbusromno9lreguital]
  \definefontsynonym [SansBoldItalic]     [name:nimbusromno9lboldital]
  \definefontsynonym [SansBoldSlanted]    [name:nimbusromno9lboldital]
  \definefontsynonym [SansCaps]           [name:nimbusromno9lregu]

\definetypeface	[nimbus]	[rm]	[serif]	[nimbus]
\definetypeface [nimbus]	[ss]	[sans]	[nimbus]




{\it Italic}

{\bf Bold}

{\bi Bold-Italic}

{\sc KaPiTaLe}




  • The first two lines say:
    • We only enter unicode
    • We only use unicode fonts
  • Thirds line (setupcapitals) say ConTeXt to use the Capital Letters defined in the fonts
  • Two scripts are defined:
    1. the scripts named [serif][nimbus] and
    2. the script named [sans][nimbus]
  • Both scripts map the fonts names to the different (existing) font style.
  • Both definetypeface-lines define the typeface nimbus. The first defines the rm-fonts and the second the ss-fonts.
  • setupbodyfont says to ConTeXt witch typeface to use with which parameters.

The chain starts with setupbodyfont: it calls the typeface nimbus. Then the typeface nimbus

  1. calls the typescript [serif][nimbus] for the rm-fonts
  2. calls the typescript [sans][nimbus] for the ss-fonts.

And inside these scripts the fonts are mapped to the different font styles.

Small extension

To show how to call a typescript directly we extend the script a litte:

\definefontsynonym [SansCaps]           [name:nimbusromno9lregu]

\starttypescript [nimbus]
  \definetypeface [nimbus]	[rm]	[serif]	[nimbus]
  \definetypeface [nimbus]	[ss]	[sans]	[nimbus]




  • A thrid typescript is defined named [nimbus]
  • usetypescript calls the typescript [nimbus] in which the typeface [nimbus] is defined
  • typeface [nimbus] and typescript [nimbus] are two totally different things
  • if the typescript [nimbus] would not be called via usetypescript then the typeface [nimbus] would not be defined


  • setupbodyfont
  • showbodyfont
  • definetypeface (not found in the references)
  • starttypescript / stoptypescript (not found in the references)
  • definefontsynonym (not found in the references)