Changes

Jump to navigation Jump to search
2,387 bytes added ,  16:55, 28 May 2020
< [[Basic Text FormattingBasics#Basics_of_ConTeXt_text_formatting|Basics of text formatting]] | [[Fonts]] | [[Font Sizes]] >
* a complete font change ({{cmd|setupbodyfont}}, {{cmd|switchtobodyfont}}).
== Warning Before you start ... ==
1. Placing a font switch at the begin of a paragraph can sometimesgenerate unexpected side-effects. This can be avoided by forcinghorizontal mode before any font change:
<texcode>
\dontleavehmode{\bf Warning!} Care must be taken when a font switch is usedat the beginning of a paragraph.\par
</texcode>
 
2. It is usually a bad style to use explicit font switches in the text. It is better to define a semantic command that takes care of the font switching. For example, instead of using <code>{\bf\red important text}</code>
<texcode>
\definehighlight[important][style=bold, color=red]
</texcode>
and then use <code>\important{important text}</code> in the text.
== Font styles and alternatives ==
{{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.
\c!em=\v!slanted]
</texcode>
'''N.B.''': <code>scirpt</code> and <code>scriptsize</code> are used in math mode.
  It is also possible to set the scaling factors for specific font sizes. For example, if you want {{cmd|tfa}} to set the effective font size to 12pt when the bodyfont size is 10pt, and to set the effective font size to
14pt when the bodyfont size is 11pt, then add
<texcode>
\definebodyfontenvironment [11pt] [a=14pt]
</texcode>
 
'''Note:''' When the first parameter is <code>default</code>, the scaling factors ''must'' have numerical values. When the first parameter is a font size (e.g., <code>12pt</code>), the scaling factors can either be numerical value or a dimension.
 
{{cmd|definebodyfontenvironment}} is described in detail in
the ConTeXt manual and the [[source:font-ini.mkiv|font-ini]] source file.
In addition, the commands {{cmd|smallbodyfont}} and
{{cmd|bigbodyfont}} can be used to change the font size. The relative size depends on the value of <code>big</code> and <code>small</code> in {{cmd|definebodyfontenvironment}}.
These mnemonic font switches are pretty smart. You can either use them as
\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 ==
{{cmd|switchtobodyfont}} can be localized within a group as usual.
== Different Switching typefaces ==
So far we have discussed style and size changes within a given typeface
family. If you want to use a different typeface altogether, such as Times or
Palatino, see the Pragma web site has recipes covering all the commonly availabletypefaces [http://pragma-ade.com/general/manuals/showfont.pdf], while aseparate manual describes how to write support for new typefaces[http://pragma-ade.com/general/manuals/mfonts.pdf]following articles.
The recipes as given work with the standalone ConTeXt distribution, but not
with TeX Live et al. [http://pragma-ade.com/general/technotes/tfmetrics.pdf]
explains why ConText uses separate font metrics, and gives some differences
between the sets. To use the recipes with other distributions,
try adding one of <code>\usetypescript[berry][ec]</code> or
<code>\usetypescript[adobekb][ec]</code>.
* [[Simple Typescript Example]]
* [[Linux Libertine on mkiv]]
== Conclusion ==
There are many other ways of choosing font styles in ConTeXt. If thesebasic styles do not satisfy your needs, have a look at the [[Manuals|manuals]],or ask on the [[ConTeXt Mailing Lists]].
[[Category:Fonts]]

Navigation menu