Difference between revisions of "Command/definefontfamily"
(Syntax definition for the \definefontfamily command) |
(Fixed wring arguments for the \definefontfamily command) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
== [[Help:Reference|Syntax]] == | == [[Help:Reference|Syntax]] == | ||
+ | |||
<table cellspacing="4" cellpadding="2" class="cmd"> | <table cellspacing="4" cellpadding="2" class="cmd"> | ||
<tr> | <tr> | ||
Line 22: | Line 23: | ||
</tr> | </tr> | ||
<tr valign="top" class="fourth"> | <tr valign="top" class="fourth"> | ||
− | <td class="cmd">[[Command/keyword: | + | <td class="cmd">[[Command/keyword:rscale|rscale]]</td> |
<td>[[Command/value:NUMBER|NUMBER]]</td> | <td>[[Command/value:NUMBER|NUMBER]]</td> | ||
− | |||
− | |||
− | |||
− | |||
</tr> | </tr> | ||
<tr valign="top" class="fourth"> | <tr valign="top" class="fourth"> | ||
Line 34: | Line 31: | ||
</tr> | </tr> | ||
<tr valign="top" class="fourth"> | <tr valign="top" class="fourth"> | ||
− | <td class="cmd">[[Command/keyword: | + | <td class="cmd">[[Command/keyword:designsize|designsize]]</td> |
− | <td>[[Command/value: | + | <td>[[Command/value:default|default]] [[Command/value:auto|auto]]</td> |
</tr> | </tr> | ||
<tr valign="top" class="fourth"> | <tr valign="top" class="fourth"> | ||
Line 42: | Line 39: | ||
</tr> | </tr> | ||
</table> | </table> | ||
+ | |||
+ | == Description == | ||
+ | |||
+ | == Example == | ||
+ | |||
+ | In the first example we create a new typeface with the name `mainface` which includes fonts from the TeX Gyre family. Even though there is no math used in this example it is better to set one because math symbols are sometimes used in text mode. | ||
+ | |||
+ | <context mode="mkiv" source="yes" text="produces"> | ||
+ | \definefontfamily [mainface] [rm] [TeX Gyre Pagella] | ||
+ | \definefontfamily [mainface] [ss] [TeX Gyre Heros] | ||
+ | \definefontfamily [mainface] [mm] [TeX Gyre Pagella Math] | ||
+ | |||
+ | \setupbodyfont[mainface] | ||
+ | |||
+ | \starttext | ||
+ | \rm Serif: TeX Gyre Pagella | ||
+ | |||
+ | \ss Sans: TeX Gyre Heros | ||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | In this example we are switching the fonts which are used for the upright, italic etc. alternatives. With the help of the `style` keyword you access one of the predefined styles, by default `\definefontfamily` uses the following styles for each alternative: | ||
+ | |||
+ | {| | ||
+ | ! Alternative !! Style | ||
+ | |- | ||
+ | | tf || regular | ||
+ | |- | ||
+ | | it || italic | ||
+ | |- | ||
+ | | sl || slanted | ||
+ | |- | ||
+ | | bf || bold | ||
+ | |- | ||
+ | |bi || bolditalic | ||
+ | |- | ||
+ | | sc || smallcaps | ||
+ | |} | ||
+ | |||
+ | <context mode="mkiv" source="yes" text="produces"> | ||
+ | \definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold,bf=style:bolditalic,bi=style:regular] | ||
+ | |||
+ | \setupbodyfont[pagella] | ||
+ | |||
+ | \starttext | ||
+ | \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
+ | |||
+ | \switchtobodyfont[changedstyles] | ||
+ | |||
+ | \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
+ | </context> | ||
+ | |||
+ | <context mode="mkiv" source="yes" text="produces"> | ||
+ | \definefontfamily[changedfiles][rm][TeX Gyre Pagella][it=file:texgyreherositalic,bi=file:texgyrecursorbolditalic] | ||
+ | |||
+ | \setupbodyfont[changedfiles] | ||
+ | |||
+ | \starttext | ||
+ | \tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
+ | </context> | ||
+ | |||
+ | <context mode="mkiv" source="yes" text="produces"> | ||
+ | \definefontfamily[changedfeatures][rm][TeX Gyre Pagella][tf=features:smallcaps,bf=features:none] | ||
+ | |||
+ | \setupbodyfont[pagella] | ||
+ | |||
+ | \starttext | ||
+ | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
+ | |||
+ | \switchtobodyfont[changedfeatures] | ||
+ | |||
+ | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | If it is not possible to install fonts system-wide, one can explicitly specify the filename of a font. Custom fonts often don't come with math symbols or a fitting monospaced font. One can replace these using Latin Modern which comes with ConTeXt. | ||
+ | |||
+ | <context mode="mkiv" source="yes" text="produces"> | ||
+ | \definefontfamily [mainface][serif] [Latin Modern Roman] | ||
+ | [tf=file:filename_serif_regular.ttf, | ||
+ | it=file:filename_serif_italic.ttf, | ||
+ | bf=file:filename_serif_bold.ttf, | ||
+ | bi=file:filename_serif_bold_italic.ttf, | ||
+ | sc=file:filename_serif_smallcaps.ttf] | ||
+ | \definefontfamily [mainface][sans] [Latin Modern Sans] | ||
+ | [tf=file:filename_sans_regular.ttf, | ||
+ | it=file:filename_sans_italic.ttf, | ||
+ | bf=file:filename_sans_bold.ttf, | ||
+ | bi=file:filename_sans_bold_italic.ttf, | ||
+ | sc=file:filename_sans_smallcaps.ttf] | ||
+ | \definefontfamily [mainface] [mono] [Latin Modern Mono] [features=none] | ||
+ | \definefontfamily [mainface] [math] [Latin Modern Math] | ||
+ | \setupbodyfont [mainface,11pt] | ||
+ | \starttext | ||
+ | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
+ | |||
+ | \tt Monospaced | ||
+ | |||
+ | $\sqrt{3x^2}$ | ||
+ | |||
+ | \stoptext | ||
+ | |||
+ | </context> | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * {{cmd|definetypeface}} | ||
+ | * {{cmd|definefallbackfamily}} |
Revision as of 20:45, 14 August 2016
\definefontfamily
Syntax
\definefontfamily[...][...][...][...,...=...,...] | |
[...] | TEXT (typescript identifier) |
[...] | rm ss tt mm hw cg serif sans mono math handwriting calligraphy |
[...] | TEXT (existing font name) |
rscale | NUMBER |
features | IDENTIFIER |
designsize | default auto |
goodies | IDENTIFIER |
Description
Example
In the first example we create a new typeface with the name mainface
which includes fonts from the TeX Gyre family. Even though there is no math used in this example it is better to set one because math symbols are sometimes used in text mode.
\definefontfamily [mainface] [rm] [TeX Gyre Pagella] \definefontfamily [mainface] [ss] [TeX Gyre Heros] \definefontfamily [mainface] [mm] [TeX Gyre Pagella Math] \setupbodyfont[mainface] \starttext \rm Serif: TeX Gyre Pagella \ss Sans: TeX Gyre Heros \stoptext
produces
In this example we are switching the fonts which are used for the upright, italic etc. alternatives. With the help of the style
keyword you access one of the predefined styles, by default \definefontfamily
uses the following styles for each alternative:
Alternative | Style |
---|---|
tf | regular |
it | italic |
sl | slanted |
bf | bold |
bi | bolditalic |
sc | smallcaps |
\definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold,bf=style:bolditalic,bi=style:regular] \setupbodyfont[pagella] \starttext \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. \switchtobodyfont[changedstyles] \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic.
produces
\definefontfamily[changedfiles][rm][TeX Gyre Pagella][it=file:texgyreherositalic,bi=file:texgyrecursorbolditalic] \setupbodyfont[changedfiles] \starttext \tf Regular, \it Italic, \bf Bold and \bi BoldItalic.
produces
\definefontfamily[changedfeatures][rm][TeX Gyre Pagella][tf=features:smallcaps,bf=features:none] \setupbodyfont[pagella] \starttext \tf ffi, \it ffi, \bf ffi, \bi ffi. \switchtobodyfont[changedfeatures] \tf ffi, \it ffi, \bf ffi, \bi ffi. \stoptext
produces
If it is not possible to install fonts system-wide, one can explicitly specify the filename of a font. Custom fonts often don't come with math symbols or a fitting monospaced font. One can replace these using Latin Modern which comes with ConTeXt.
\definefontfamily [mainface][serif] [Latin Modern Roman] [tf=file:filename_serif_regular.ttf, it=file:filename_serif_italic.ttf, bf=file:filename_serif_bold.ttf, bi=file:filename_serif_bold_italic.ttf, sc=file:filename_serif_smallcaps.ttf] \definefontfamily [mainface][sans] [Latin Modern Sans] [tf=file:filename_sans_regular.ttf, it=file:filename_sans_italic.ttf, bf=file:filename_sans_bold.ttf, bi=file:filename_sans_bold_italic.ttf, sc=file:filename_sans_smallcaps.ttf] \definefontfamily [mainface] [mono] [Latin Modern Mono] [features=none] \definefontfamily [mainface] [math] [Latin Modern Math] \setupbodyfont [mainface,11pt] \starttext \tf ffi, \it ffi, \bf ffi, \bi ffi. \tt Monospaced $\sqrt{3x^2}$ \stoptext
produces