Changes

Jump to navigation Jump to search
no edit summary
=== Introduction ===-----
`simplefonts` is a third–party module written by Wolfgang Schuster.=== Warning ===
It has two main advantages over the standard The information on this page is outdated. See {{cmd|definefontfamily}} for details on a simpler font handling mechanism defined for ConTeXt MKIV. This remainder of this page is historical in nature and the examples may no longer work with recent ConTeXt:distributions.
* the user doesn’t need to write [[Fonts_in_LuaTeX#The_standard_way:_Typescripts|typescripts]].=== History ===
Wolfgang Schuster wrote a third–party module named `simplefonts`, which held a few advantages over standard ConTeXt font handling:
 
* the user doesn’t need to write [[Fonts_in_LuaTeX#The_standard_way:_Typescripts|typescripts]]; and
* the interface is much easier to use.
 
Major changes were released in October, 2013. As such, this page typically documents 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]Before October, 2013, installation of <code>simplefonts</code> is already for[[ConTeXt Standalone]] could be installed.like [[ConTeXt_Standalone#Installing_third_party_modules|any third-party module]]:
* If you’re running [[ConTeXt Standalone]] (which is a better option), <code>simplefonts</code> can be installed like [[ConTeXt_Standalone#Installing_third_party_modules|any third-party module]]:
first-setup.sh --modules="t-simplefonts"
 
For newer release of ConTeXt (or LuaTeX with [https://www.tug.org/texlive/ TeX Live]), <code>simplefonts</code> is installed by default, no additional installation steps are necessary.
==== Setting the system font directory ====
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=== Legacy === As of December 2013, the Simplefonts module is included with ConTeXt. No longer is loading an external module necessary use simplified font commands. However, the commands have changed slightly: `\setmainfont`  is now: `\definefontfamily [myfamily] [serif] [DejaVu]`  which also applies to sans, mono, math fonts. Use the font family as follows: `\setupbodyfont [myfamily]` Note: Monospace fonts may have undesired ligatures when using the `\type` command. Disable the ligature font features to avoid the issue as follows: `\definefontfamily [myfamily] [mono] [TeX Gyre Cursor] [features=none]` See {{src|font-sel.mkvi}} in the distribution for more examples and in depth explanation.  [[Category:Old Content]]

Navigation menu