Difference between revisions of "Font Variants"

From ConTeXt wiki
Jump to navigationJump to search
(Begin with an example)
 
m (Corrected link)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page is presented as an extension of [http://home.salamander.com/~wmcclain/context-help.html#newfont-type1-texfont Bill's tutorial on enabling new fonts]:
+
This page is presented as an extension of [http://watershade.net/wmcclain/context-help.html#newfont-type1-texfont Bill's tutorial on enabling new fonts]:
  
 
Bill creates a <tt>type-sabon</tt> typescript file. Our example starts from the same place:
 
Bill creates a <tt>type-sabon</tt> typescript file. Our example starts from the same place:
%
+
<texcode>
% Adobe Sabon
+
%
%
+
% Adobe Sabon
\usetypescriptfile[type-buy]
+
%
\loadmapfile[texnansi-adobe-sabon.map]
+
\usetypescriptfile[type-buy]
\starttypescript [serif] [sabon] [texnansi]
+
\loadmapfile[texnansi-adobe-sabon.map]
  \definefontsynonym [Sabon-Roman]          [texnansi-sar]  [encoding=texnansi]
+
\starttypescript [serif] [sabon] [texnansi]
  \definefontsynonym [Sabon-Bold]          [texnansi-sab]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Roman]          [texnansi-sar]  [encoding=texnansi]
  \definefontsynonym [Sabon-Italic]        [texnansi-sai]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Bold]          [texnansi-sab]  [encoding=texnansi]
  \definefontsynonym [Sabon-Bold-Italic]    [texnansi-sabi] [encoding=texnansi]
+
\definefontsynonym [Sabon-Italic]        [texnansi-sai]  [encoding=texnansi]
  \definefontsynonym [Sabon-Roman-SmallCaps][texnansi-sarsc]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Bold-Italic]    [texnansi-sabi] [encoding=texnansi]
  \definefontsynonym [Sabon-Italic-OSF]    [texnansi-saiof]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Roman-SmallCaps][texnansi-sarsc]  [encoding=texnansi]
  \definefontsynonym [Sabon-Bold-OSF]      [texnansi-sabof]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Italic-OSF]    [texnansi-saiof]  [encoding=texnansi]
  \definefontsynonym [Sabon-Bold-Italic-OSF][texnansi-sabio]  [encoding=texnansi]
+
\definefontsynonym [Sabon-Bold-OSF]      [texnansi-sabof]  [encoding=texnansi]
\stoptypescript
+
\definefontsynonym [Sabon-Bold-Italic-OSF][texnansi-sabio]  [encoding=texnansi]
 +
\stoptypescript
 +
</texcode>
  
 
The sabon encoding typescript remains the same from Bill's example.
 
The sabon encoding typescript remains the same from Bill's example.
 
The name typescript gains a few more entries, however:
 
The name typescript gains a few more entries, however:
  
\starttypescript [serif] [sabon] [name]
+
<texcode>
  \usetypescript[serif][fallback]
+
\starttypescript [serif] [sabon] [name]
  \definefontsynonym [Serif]          [Sabon-Roman]
+
\usetypescript[serif][fallback]
  \definefontsynonym [SerifBold]      [Sabon-Bold]
+
\definefontsynonym [Serif]          [Sabon-Roman]
  \definefontsynonym [SerifItalic]    [Sabon-Italic]
+
\definefontsynonym [SerifBold]      [Sabon-Bold]
  \definefontsynonym [SerifBoldItalic] [Sabon-Bold-Italic]
+
\definefontsynonym [SerifItalic]    [Sabon-Italic]
  \definefontsynonym [SerifCaps]      [Sabon-Roman-SmallCaps]
+
\definefontsynonym [SerifBoldItalic] [Sabon-Bold-Italic]
 +
\definefontsynonym [SerifCaps]      [Sabon-Roman-SmallCaps]
 +
</texcode>
 
The above remain the same, but then there follow some more definitions:
 
The above remain the same, but then there follow some more definitions:
 +
<texcode>
 
   \definefontsynonym [SerifRegular]      [Serif]
 
   \definefontsynonym [SerifRegular]      [Serif]
 +
</texcode>
 
SerifRegular must be defined as a synonym to Serif, because of the way we navigate the font variants internally. The following synonyms have "OsF" appended to the existing font synonyms on the left side, and point to the defined oldstyle figure variations on the right hand side:
 
SerifRegular must be defined as a synonym to Serif, because of the way we navigate the font variants internally. The following synonyms have "OsF" appended to the existing font synonyms on the left side, and point to the defined oldstyle figure variations on the right hand side:
  \definefontsynonym [SerifRegularOsF]    [Sabon-Roman-SmallCaps]
+
<texcode>
  \definefontsynonym [SerifBoldOsF]      [Sabon-Bold-OSF]
+
\definefontsynonym [SerifRegularOsF]    [Sabon-Roman-SmallCaps]
  \definefontsynonym [SerifItalicOsF]    [Sabon-Italic-OSF]
+
\definefontsynonym [SerifBoldOsF]      [Sabon-Bold-OSF]
  \definefontsynonym [SerifSlantedOsF]    [Sabon-Italic-OSF]
+
\definefontsynonym [SerifItalicOsF]    [Sabon-Italic-OSF]
  \definefontsynonym [SerifBoldItalicOsF] [Sabon-Bold-Italic-OSF]
+
\definefontsynonym [SerifSlantedOsF]    [Sabon-Italic-OSF]
  \definefontsynonym [SerifBoldSlantedOsF][Sabon-Bold-Italic-OSF]
+
\definefontsynonym [SerifBoldItalicOsF] [Sabon-Bold-Italic-OSF]
  \definefontsynonym [SerifCapsOsF]      [Sabon-Roman-SmallCaps]
+
\definefontsynonym [SerifBoldSlantedOsF][Sabon-Bold-Italic-OSF]
 +
\definefontsynonym [SerifCapsOsF]      [Sabon-Roman-SmallCaps]
 +
</texcode>
 
Finally, we define a variant. It says, in shorthand: ''for this Serif font, a ''<tt>\Var[osf]</tt>'' command will postpend ''OsF'' to the current font name, and switch'':
 
Finally, we define a variant. It says, in shorthand: ''for this Serif font, a ''<tt>\Var[osf]</tt>'' command will postpend ''OsF'' to the current font name, and switch'':
  \definefontvariant  [Serif][osf][OsF]
+
<texcode>
\stoptypescript
+
\definefontvariant  [Serif][osf][OsF]
 +
\stoptypescript
 
   
 
   
\starttypescript [Sabon]  
+
\starttypescript [Sabon]  
  \definetypeface [Sabon] [rm] [serif] [sabon] [default] [encoding=texnansi]
+
\definetypeface [Sabon] [rm] [serif] [sabon] [default] [encoding=texnansi]
\stoptypescript
+
\stoptypescript
 +
</texcode>
 
Usage would proceed this way:
 
Usage would proceed this way:
\usetypescriptfile[type-sabon]
+
<texcode>
\usetypescript[Sabon]
+
\usetypescriptfile[type-sabon]
\setupbodyfont[Sabon]
+
\usetypescript[Sabon]
\starttext
+
\setupbodyfont[Sabon]
This is Sabon roman 0123456789,  
+
 
old-style \Var[osf] 0123456789,  
+
\starttext
{\it\Var[osf] italic 0123456789,}  
+
This is Sabon roman 0123456789,  
{\bf bold 01234\Var[osf]56789,}  
+
old-style \Var[osf] 0123456789,  
and {\bi bold-italic \Var[osf]0123456789.}
+
{\it\Var[osf] italic 0123456789,}  
+
{\bf bold 01234\Var[osf]56789,}  
{\em \bf This is also \Var[osf] bold-italic 0123456789.}
+
and {\bi bold-italic \Var[osf]0123456789.}
+
 
\stoptext
+
{\em \bf This is also \Var[osf] bold-italic 0123456789.}
 +
\stoptext
 +
</texcode>
 +
[[Category:Fonts]]

Latest revision as of 08:18, 28 May 2009

This page is presented as an extension of Bill's tutorial on enabling new fonts:

Bill creates a type-sabon typescript file. Our example starts from the same place:

%
% Adobe Sabon
%
\usetypescriptfile[type-buy]
\loadmapfile[texnansi-adobe-sabon.map]
\starttypescript [serif] [sabon] [texnansi]
 \definefontsynonym [Sabon-Roman]          [texnansi-sar]  [encoding=texnansi]
 \definefontsynonym [Sabon-Bold]           [texnansi-sab]  [encoding=texnansi]
 \definefontsynonym [Sabon-Italic]         [texnansi-sai]  [encoding=texnansi]
 \definefontsynonym [Sabon-Bold-Italic]    [texnansi-sabi] [encoding=texnansi]
 \definefontsynonym [Sabon-Roman-SmallCaps][texnansi-sarsc]  [encoding=texnansi]
 \definefontsynonym [Sabon-Italic-OSF]     [texnansi-saiof]  [encoding=texnansi]
 \definefontsynonym [Sabon-Bold-OSF]       [texnansi-sabof]  [encoding=texnansi]
 \definefontsynonym [Sabon-Bold-Italic-OSF][texnansi-sabio]  [encoding=texnansi]
\stoptypescript

The sabon encoding typescript remains the same from Bill's example. The name typescript gains a few more entries, however:

\starttypescript [serif] [sabon] [name]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]           [Sabon-Roman]
 \definefontsynonym [SerifBold]       [Sabon-Bold]
 \definefontsynonym [SerifItalic]     [Sabon-Italic]
 \definefontsynonym [SerifBoldItalic] [Sabon-Bold-Italic]
 \definefontsynonym [SerifCaps]       [Sabon-Roman-SmallCaps]

The above remain the same, but then there follow some more definitions:

  \definefontsynonym [SerifRegular]       [Serif]

SerifRegular must be defined as a synonym to Serif, because of the way we navigate the font variants internally. The following synonyms have "OsF" appended to the existing font synonyms on the left side, and point to the defined oldstyle figure variations on the right hand side:

 \definefontsynonym [SerifRegularOsF]    [Sabon-Roman-SmallCaps]
 \definefontsynonym [SerifBoldOsF]       [Sabon-Bold-OSF]
 \definefontsynonym [SerifItalicOsF]     [Sabon-Italic-OSF]
 \definefontsynonym [SerifSlantedOsF]    [Sabon-Italic-OSF]
 \definefontsynonym [SerifBoldItalicOsF] [Sabon-Bold-Italic-OSF]
 \definefontsynonym [SerifBoldSlantedOsF][Sabon-Bold-Italic-OSF]
 \definefontsynonym [SerifCapsOsF]       [Sabon-Roman-SmallCaps]

Finally, we define a variant. It says, in shorthand: for this Serif font, a \Var[osf] command will postpend OsF to the current font name, and switch:

 \definefontvariant  [Serif][osf][OsF]
\stoptypescript
 
\starttypescript [Sabon] 
 \definetypeface [Sabon] [rm] [serif] [sabon] [default] [encoding=texnansi]
\stoptypescript

Usage would proceed this way:

\usetypescriptfile[type-sabon]
\usetypescript[Sabon]
\setupbodyfont[Sabon]

\starttext
This is Sabon roman 0123456789, 
old-style \Var[osf] 0123456789, 
{\it\Var[osf] italic 0123456789,} 
{\bf bold 01234\Var[osf]56789,} 
and {\bi bold-italic \Var[osf]0123456789.}

{\em \bf This is also \Var[osf] bold-italic 0123456789.}
\stoptext