Changes

Jump to navigation Jump to search
m
add link to sources
'''ATTENTION!!'''
 
As of December 2013, the functionality of the Simplefonts module has been included into the ConTeXt core. You do no longer need to load any external module to take advantage of the simplified font commands. However, the commands have slightly changed:
 
`\setmainfont`
 
is now
 
`\definefontfamily [myfamily] [serif] [DejaVu]`
 
(and the same syntax to set the sans, mono and math font).
 
To use this family:
 
`\setupbodyfont [myfamily]`
 
Note that for monospace fonts, undesired ligatures may be used in `\type`. To avoid this, font features should be disabled:
 
`\definefontfamily [myfamily] [mono] [TeX Gyre Cursor] [features=none]`
 
If you want more examples, have a look at the file {{src|font-sel.mkvi}} in the distribution, which contains a good explanation.
 
-----
 
=== Introduction ===
* the interface is much easier to use.
 
* Note that some major changes were released in Oct. 2013. Documentation on this page typically describes the earlier version of simplefonts distributed with TeX Live 2013, unless otherwise noted.
=== Installing <code>simplefonts</code> ===
* If you’re using LuaTeX along with [https://www.tug.org/texlive/ TeX Live], <code>simplefonts</code> is already installed.
* If you’re running [[ConTeXt Standalone]] (which is a better optionupdated more often, allowing use of newer features but with less stability testing), <code>simplefonts</code> can be installed like [[ConTeXt_Standalone#Installing_third_party_modules|any third-party module]]:
first-setup.sh --modules="t-simplefonts"
Here is the most basic sample:
<texcodecontext mode="mkiv" source="yes">
\setupbodyfontenvironment[default][em=italic]
\usemodule[simplefonts][size=10pt]
\setmainfont[FreeSerif]\setmonofont[FreeMonoTeX Gyre Termes]\setsansfont[FreeSans] \starttextSerif typeface: regular, {\em italic}, {\bf bold} and {\bf\em bold italic} fonts. {\ss Sans--serif typeface: regular {\em italic}, {\bf bold} and {\bf\em bold italic} fonts.} {\tt Monospace typeface: regular {\em italic}, {\bf bold} and {\bf\em bold italic} fonts.}\stoptext</texcode> It isn’t required to define size for 12pt, since it is the default value. <!-- when MkIV is enabled in the wikiThis is the output: <context>\setupbodyfontenvironment[default][em=italic]\usemodule[simplefonts][size=10pt]\setmainfont[FreeSerifTeX Gyre Heros]\setmonofont[FreeMono]\setsansfont[FreeSansTeX Gyre Cursor]
\starttext
\stoptext
</context>
-->It isn’t required to define size for 12pt, since it is the default value.
=== Mixing fonts ===
In some cases, you might want to mix fonts (it is up to you whether they really match or not).
Here is the way to do it(I know that fonts don’t match):
<texcodecontext mode="mkiv" source="yes">
\setupbodyfontenvironment[default][em=italic]
\usemodule[simplefonts]
\setmainfont[TheanoDidotTeX Gyre Termes][italicfont=Old StandardTeX Gyre Bonum-Italic, boldfont=Old StandardTeX Gyre Adventor-Bold,bolditalicfont=TeX Gyre Pagella-Bold Italic] % yes, bold italics don’t match
\starttext
Serif typeface: regular , {\em italic}, {\bf bold} and {\bf\em bold italic} fonts.
\stoptext
</texcodecontext>
=== Font fallback mechanism ===
We can have documents in which we use typefaces that lack some characters or a whole character range. In that case, font fallbacks can be defined.
The example shows how to get Greek characters for TeX Gyre Pagella(I know they don’t fit well together, but I rely on system fonts):
<texcodecontext mode="mkiv" source="yes">
\setupbodyfontenvironment[default][em=italic]
\usemodule[simplefonts]
\setmainfontfallback[GFS DidotDejaVu Serif][range={greekandcoptic, greekextended}, force=yes, rscale=auto]
\setmainfont[TeX Gyre Pagella]
{\bf\em English text. δύσκολα τὰ καλά.}
\stoptext
</texcodecontext>
Two things to be considered:
* `range` can assume the following values: any of the block names from [http://source.contextgarden.net/tex/context/base/in {{src|char-ini.lua this list]}}, or pure numeric values (a manual range such as `0x003B1-0x003B6`).
* `force=yes` should be enabled, unless you want the characters to have their glyphs from the original font replaced with the ones from the fallback font.
*`\definesimplefonttypeface`, defines a single typeface.
*`\simplefonttypeface`, can define a typeface set (such as serif, sans–serif, monospaced, caligraphy and others).
 
The \definesimplefont command can be used when you want a certain font
for the heading of a chapter, section etc. E.g.
 
<texcode>
\definesimplefont[ChapterFont][Gentium Basic][size=24pt]
\setuphead[chapter][style=ChapterFont]
</texcode>
 
but Wolfgang doesn’t recommend this command anymore (and removed it from the new, Oct. 2013 version) because you can get the same result with a custom typeface, e.g.
 
<texcode>
\definesimplefonttypeface[chapterfont][TeX Gyre Termes]
\definefont[ChapterFont][\classfont{chapterfont}{Serif} at 24pt]
\setuphead[chapter][style=ChapterFont]
</texcode>
 
When you want to change only the global font for your document you
need the <code>\definesimplefonttypeface</code> command, e.g.
 
<texcode>
\definesimplefonttypeface[documentfont][TeX Gyre Termes]
\setupbodyfont[documentfont]
</texcode>
=== Handling special cases ===
Again, it would be the exception, rather than the rule, where this suggested method outputs a reasonable result. If you use ConTeXt for its high–quality typographical performance, using faked fonts can ruin that performance.
Wolfgang Schuster proposed the following code to get slanted and fake bold fonts (not working right now, I guess it’s a bug):
<texcodecontext mode="mkiv" source="yes">
\setupbodyfontenvironment[default][em=italic]
\usemodule[simplefonts]
\definefontfeature[fakebold][default][extend=2]
\definefontfeature[fakebolditalic][default][slant=.25, extend=2]
\setmainfont[LarabiefontTeX Gyre Pagella] \definesimplefonttypeface[fakingall][TeX Gyre Pagella][italicfont={* Regular}, boldfont={*Regular}, bolditalicfont={* Regular}, italicfeatures=fakeitalic,
boldfeatures=fakebold, bolditalicfeatures=fakebolditalic]
 \starttextCompare: Four fonts, real typeface: regular, {\em italic}, {\bf bold} and {\bf\em bold italic} fonts. {\fakingall One font, faked typeface: regular, {\em italic (actually slanted)} , {\bf bold (actually stretched)} and {\bf\em bold italic (actually slanted and stretched)} fonts.}\stoptext</texcodecontext>

Navigation menu