Changes

Jump to navigation Jump to search
2,835 bytes added ,  20:27, 14 July 2020
< [[Basic Text Formatting]] | [[Fonts]] >
 
 
In ConTeXt there are four ways to switch fonts:
* a complete font change ({{cmd|setupbodyfont}}, {{cmd|switchtobodyfont}}).
== Warnings Before you start ... ==
1. Placing a font switch at the begin of a paragraph can sometimes generate unexpected side-effects. This can be avoided by forcing horizontal mode before any font change:
and then use <code>\important{important text}</code> in the text.
== Font styles and alternatives ==
There are three main types of font styles: serif, sans serif, and teletype. To
{{cmd|em}} switches to slanted; and if the current font alternative is slanted,
{{cmd|em}} switches to normal.
 
<context>
\starttabulate[|l|f{\tf}l|f{\it}l|f{\sl}l|f{\bf}l|f{\bi}l|f{\bs}l|]
\NC \NC \tttf \tex{tf} \NC \tttf \tex{it} \NC \tttf \tex{sl} \NC
\tttf \tex{bf} \NC \tttf \tex{bi} \NC \tttf \tex{bs} \NC\NR
\NC \NC Text \NC Text \NC Text \NC
Text \NC Text \NC Text \NC\NR
\NC \tex{em} \NC \em Text \NC \em Text \NC \em Text \NC
\em Text \NC \em Text \NC \em Text \NC\NR
\NC \tex{boldface} \NC \boldface Text \NC \boldface Text \NC \boldface Text \NC
\boldface Text \NC \boldface Text \NC \boldface Text \NC\NR
\NC \tex{typeface} \NC \typeface Text \NC \typeface Text \NC \typeface Text \NC
\typeface Text \NC \typeface Text \NC \typeface Text \NC\NR
\NC \tex{swapface} \NC \swapface Text \NC \swapface Text \NC \swapface Text \NC
\swapface Text \NC \swapface Text \NC \swapface Text \NC\NR
\stoptabulate
</context>
ConTeXt uses the Latin Modern fonts by default; these fonts look
</texcode>
{{note| For Opentype fonts, italic correction needs to be set using
<texcode>\definefontfeature[default][default][itlc=yes]</texcode>}}
== Font sizes ==
|- align="right"
|d ||2.074 ||8.3||10.4||12.4||14.5||16.6||18.7||20.7||22.8||24.9||29.9||35.9||42.9
|- align="right"
|e ||2.488 ||10.0||12.4||14.9||17.4||19.9||22.4||24.9||27.4||29.9||35.8||43.0||52.5
|-
| _
|}
As defined in [[source:font-ini.mkivmkvi|font-ini]]. All sizes in pt, except factor.
\setuphead[section][style=bold]
</texcode>
 
(<code>\boldface</code> shown above is also defined to parallel the
<code>\typeface</code> and <code>\swapface</code> switches.)
 
== Capitalizing words ==
 
* Note that {{cmd|WORD}}, {{cmd|Word}} and all following macros aren't ''switches'', but ''commands'' (brackets behind, not around): <tt>{</tt>{{cmd|em}} <tt>switch}</tt>, vs {{cmd|Word}}<tt>{macro}</tt>.
 
== Underline, strike through, and overline ==
 
* Underlined, struck, and overlined text can be achieved with {{cmd|overbar}} , {{cmd|overbars}}, {{cmd|overstrike}}, {{cmd|overstrikes}}, {{cmd|underbar}}, and {{cmd|underbars}}.
 
The canonical way is <code>\overstrike{text}</code>. However, it you're using mycrotypography with <code>\setupalign[hz,hanging]</code> expect the rule to be placed over the character (with the Latin Modern fonts you should not have this problem, experienced with Linux Libertine and mkiv). This is not what is expected. The workaround is to put the overstriked text in a <code>\inframed[frame=off]{}</code>.
 
E.g.
<texcode>
bla bla bla \inframed[frame=off]{\overstrike{striked}} bla bla
</texcode>
 
<context>
bla bla bla \inframed[frame=off]{\overstrike{striked}} bla bla
</context>
 
Disabling mycrotypography also works, but probably not desiderable.
<pre>
\setupalign[nothanging,nohz]
\strikeout{text}
\setupalign[hanging,hz]
</pre>
== Complete font (bodyfont) change ==
* [[Simple Typescript Example]]
* [[Example Roboto Typescript]] an example with normal and condensed font variants]]
* [[Linux Libertine on mkiv]]
== From font-var.mkvi [https://source.contextgarden.net/tex/context/base/mkiv/font-var.mkvi?search=fontface#l49] ==
 
<context source=yes>
% fontclass % modern dejavu
% fontbody % ... 10pt 11pt 12pt ...
% fontstyle % rm ss tt mm hw cg ...
% fontalternative % tf bf sl it bs bi sc ...
% fontsize % a b c d ...
% fontface % 0=normal 1=text 2=script 3=scriptscript 4=x 5=xx (math are temporary)
 
class: \fontclass
 
body : \fontbody
 
style: \fontstyle
 
alternative: \fontalternative
 
size: \fontsize
 
face: \fontface
 
</context>
[[Category:Fonts]]

Navigation menu