Difference between revisions of "Simple Typescript Example"

From ConTeXt wiki
(New page: (in progress))
 
Line 1: Line 1:
(in progress)
+
[[Category:Fonts]]
 +
 
 +
(not finished now)
 +
 
 +
==Task==
 +
 
 +
To map Nimbus Sans on rm-fonts and Nimbus Serif on ss-fonts.
 +
 
 +
==Requirements==
 +
 
 +
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 [[Fonts_in_LuaTeX#Building_the_font_database|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.
 +
 
 +
==Script==
 +
 
 +
<texcode>
 +
\enableregime[utf]
 +
\setupencoding[default=uc]
 +
 
 +
\setupcapitals[sc=yes]
 +
 
 +
\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]
 +
\stoptypescript
 +
 
 +
\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]
 +
\stoptypescript
 +
 
 +
\definetypeface [nimbus] [rm] [serif] [nimbus]
 +
\definetypeface [nimbus] [ss] [sans] [nimbus]
 +
 
 +
\setupbodyfont[nimbus,rm,10pt]
 +
 
 +
\starttext
 +
 
 +
Regular
 +
 
 +
{\it Italic}
 +
 
 +
{\bf Bold}
 +
 
 +
{\bi Bold-Italic}
 +
 
 +
{\sc KaPiTaLe}
 +
 
 +
\showbodyfont
 +
 
 +
\stoptext
 +
</texcode>
 +
 
 +
Annotations:
 +
* 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:
 +
*# the scripts named ''[serif][nimbus]'' and
 +
*# 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''
 +
# calls the ''typescript [serif][nimbus]'' for the rm-fonts
 +
# calls the ''typescript [sans][nimbus]'' for the ss-fonts.
 +
And inside these scripts the fonts are mapped to the different font styles.
 +
 
 +
==Small extension==
 +
 
 +
 
 +
 
 +
==References==
 +
 
 +
* [[Reference/en/setupbodyfont|setupbodyfont]]
 +
* [[Reference/en/showbodyfont|showbodyfont]
 +
* definetypeface (not found in the references)
 +
* starttypescript / stoptypescript (not found in the references)
 +
* definefontsynonym (not found in the references)

Revision as of 16:36, 21 August 2010


(not finished now)

Task

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

Requirements

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.

Script

\enableregime[utf]
\setupencoding[default=uc]

\setupcapitals[sc=yes]

\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]
\stoptypescript

\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]
\stoptypescript

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

\setupbodyfont[nimbus,rm,10pt]

\starttext

Regular

{\it Italic}

{\bf Bold}

{\bi Bold-Italic}

{\sc KaPiTaLe}

\showbodyfont

\stoptext

Annotations:

  • 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

References

  • setupbodyfont
  • [[Reference/en/showbodyfont|showbodyfont]
  • definetypeface (not found in the references)
  • starttypescript / stoptypescript (not found in the references)
  • definefontsynonym (not found in the references)