ConTeXt: Font weights
To access more alternatives with a single typeface you have to create first additional alternatives with the \definefontalternative
command. For my example I add new definitions for a light and a medium style, for the name of the alternative itself you’re limited to two letter for each and you should ensure no important commands are overwritten, e.g. below I overwrite the language switch for lithuanian
which can be ignored because you can still use \language[lt]
in a document.
\definefontalternative[lt] % light
\definefontalternative[li] % lightitalic
\definefontalternative[md] % medium
\definefontalternative[mi] % mediumitalic
Now you can add entries for the light and medium styles in your typescript and map synonyms to the font files, for the names of the synonyms you should stick close the the default names, e.g. I used SerifLight
for the light style if the font.
\starttypescript [serif] [antykwa-torunska-extended]
\definefontsynonym [SerifLight] [file:antykwatorunskalightregular] [features=default]
\definefontsynonym [SerifLightItalic] [file:antykwatorunskalightitalic] [features=default]
\definefontsynonym [Serif] [file:antykwatorunskaRegular] [features=default]
\definefontsynonym [SerifItalic] [file:antykwatorunskaitalic] [features=default]
\definefontsynonym [SerifMedium] [file:antykwatorunskamedregular] [features=default]
\definefontsynonym [SerifMediumItalic] [file:antykwatorunskameditalic] [features=default]
\definefontsynonym [SerifBold] [file:antykwatorunskabold] [features=default]
\definefontsynonym [SerifBoldItalic] [file:antykwatorunskabolditalic] [features=default]
\definefontsynonym [SerifCaps] [file:antykwatorunskaregular] [features=smallcaps]
\stoptypescript
Now comes the important part where I assign the files for the light and medium styles to the additional alternatives which is done with the \definebodyfont
command.
\starttypescript [serif] [antykwa-torunska-extended]
\definebodyfont [default] [rm]
[lt=SerifLight sa 1,
li=SerifLightItalic sa 1,
tf=Serif sa 1,
it=SerifItalic sa 1,
md=SerifMedium sa 1,
mi=SerifMediumItalic sa 1,
bf=SerifBold sa 1,
bi=SerifBoldItalic sa 1,
sc=SerifCaps sa 1]
\stoptypescript
After this is done you I can now create a new typeface which supports alternatives than the one provided by default (\tf
, \it
etc.).
\definetypeface[antykwa-torunska-extended][rm][serif][antykwa-torunska-extended][default]
\setupbodyfont[antykwa-torunska-extended]
\starttext
\starttabulate[|l|l|]
\NC \tex{lt} \NC \lt Light \NC\NR
\NC \tex{li} \NC \li LightItalic \NC\NR
\NC \tex{tf} \NC \tf Regular \NC\NR
\NC \tex{it} \NC \it Italic \NC\NR
\NC \tex{md} \NC \md Medium \NC\NR
\NC \tex{mi} \NC \mi MediumItalic \NC\NR
\NC \tex{bf} \NC \bf Bold \NC\NR
\NC \tex{bi} \NC \bi BoldItalic \NC\NR
\NC \tex{sc} \NC \sc SmallCaps \NC\NR
\stoptabulate
\stoptext
I am relatively new to ConTeXt but I think the canonical solution to any font loading problem is writing a typescript. To access semibold small caps you have to do \setff{smallcaps}\bf
. This is due to the fact that \sc
and \bf
are not additive (just like in Plain TeX). Once you switch to small caps using \setff
you can access all the different styles using the mnemonic font switches.
I don't have the proprietary Calluna fonts, so I'm using TeX Gyre Termes and TeX Gyre Heros. Just substitute the files and it should work.
\starttypescriptcollection [calluna]
\starttypescript [serif] [calluna]
\definefontsynonym [Serif] [file:texgyretermes-regular.otf] [features=default]
\definefontsynonym [SerifItalic] [file:texgyretermes-italic.otf] [features=default]
\definefontsynonym [SerifBold] [file:texgyretermes-bold.otf] [features=default]
\definefontsynonym [SerifBoldItalic] [file:texgyretermes-bolditalic.otf] [features=default]
\definefontsynonym [SerifCaps] [file:texgyretermes-regular.otf] [features=smallcaps]
\stoptypescript
\starttypescript [sans] [calluna]
\definefontsynonym [Sans] [file:texgyreheros-regular.otf] [features=default]
\definefontsynonym [SansItalic] [file:texgyreheros-italic.otf] [features=default]
\definefontsynonym [SansBold] [file:texgyreheros-bold.otf] [features=default]
\definefontsynonym [SansBoldItalic] [file:texgyreheros-bolditalic.otf] [features=default]
\definefontsynonym [SansCaps] [file:texgyreheros-regular.otf] [features=smallcaps]
\stoptypescript
\starttypescript [calluna]
\definetypeface [calluna] [rm] [serif] [calluna] [default] [features=default]
\definetypeface [calluna] [ss] [sans] [calluna] [default] [features=default]
\stoptypescript
\stoptypescriptcollection
\setupbodyfont[calluna]
\starttext
{
\tf Serif
\it SerifItalic
\bf SerifBold
\bi SerifBoldItalic
}
{
\setff{smallcaps}
\tf serifcaps
\it serifitaliccaps
\bf serifboldcaps
\bi serifbolditaliccaps
}
{
\ss Sans
\it SansItalic
\bf SansBold
\bi SansBoldItalic
}
{
\setff{smallcaps}
\ss SansCaps
\it SansItalicCaps
\bf SansBoldCaps
\bi SansBoldItalicCaps
}
\stoptext