Difference between revisions of "Command/definefontfamily"
m (→Example) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 28: | Line 28: | ||
\starttext | \starttext | ||
+ | \startTEXpage[offset=2.5em] | ||
\rm Serif: TeX Gyre Pagella | \rm Serif: TeX Gyre Pagella | ||
\ss Sans: TeX Gyre Heros | \ss Sans: TeX Gyre Heros | ||
+ | \stopTEXpage | ||
\stoptext | \stoptext | ||
</context> | </context> | ||
Line 53: | Line 55: | ||
<context mode="mkiv" source="yes" text="produces"> | <context mode="mkiv" source="yes" text="produces"> | ||
− | \definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold, | + | \definefontfamily[changedstyles][rm][TeX Gyre Pagella][tf=style:italic,it=style:bold,bi=style:bolditalic,bf=style:regular] |
\setupbodyfont[pagella] | \setupbodyfont[pagella] | ||
\starttext | \starttext | ||
+ | \startTEXpage[offset=2.5em] | ||
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
Line 63: | Line 66: | ||
\rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
+ | \stopTEXpage | ||
+ | \stoptext | ||
</context> | </context> | ||
Line 71: | Line 76: | ||
\starttext | \starttext | ||
+ | \startTEXpage[offset=2.5em] | ||
\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | \tf Regular, \it Italic, \bf Bold and \bi BoldItalic. | ||
</context> | </context> | ||
Line 80: | Line 86: | ||
\starttext | \starttext | ||
+ | \startTEXpage[offset=2.5em] | ||
\tf ffi, \it ffi, \bf ffi, \bi ffi. | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
Line 85: | Line 92: | ||
\tf ffi, \it ffi, \bf ffi, \bi ffi. | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
+ | \stopTEXpage | ||
\stoptext | \stoptext | ||
</context> | </context> | ||
Line 107: | Line 115: | ||
\setupbodyfont [mainface,11pt] | \setupbodyfont [mainface,11pt] | ||
\starttext | \starttext | ||
+ | \startTEXpage[offset=2.5em] | ||
\tf ffi, \it ffi, \bf ffi, \bi ffi. | \tf ffi, \it ffi, \bf ffi, \bi ffi. | ||
Line 112: | Line 121: | ||
$\sqrt{3x^2}$ | $\sqrt{3x^2}$ | ||
− | + | \stopTEXpage | |
\stoptext | \stoptext | ||
Line 125: | Line 134: | ||
* {{cmd|definefontfile}} | * {{cmd|definefontfile}} | ||
* {{cmd|definefallbackfamily}} | * {{cmd|definefallbackfamily}} | ||
+ | * https://meeting.contextgarden.net/2021/talks/2021-09-23/definefontfamily.pdf | ||
[[Category:Command/Fonts|definefontfamily]] | [[Category:Command/Fonts|definefontfamily]] |
Latest revision as of 11:51, 29 February 2024
\definefontfamily
Syntax (autogenerated)
\definefontfamily[...][...][...][...=...,...] | |
[...] | name |
[...] | rm ss tt mm hw cg roman serif regular sansserif sans support teletype type mono handwritten calligraphic math mathematics |
[...] | font |
rscale | number |
designsize | default auto |
goodies | file |
features | name |
tf | text |
bf | text |
it | text |
sl | text |
bi | text |
bs | text |
sc | text |
\definefontfamily[...][...][...][...,...] | |
[...] | name |
[...] | rm ss tt mm hw cg roman serif regular sansserif sans support teletype type mono handwritten calligraphic math mathematics |
[...] | font |
[...,...] | name |
Syntax
Description
- typescript identifier
- font class
- existing font name
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 \startTEXpage[offset=2.5em] \rm Serif: TeX Gyre Pagella \ss Sans: TeX Gyre Heros \stopTEXpage \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,bi=style:bolditalic,bf=style:regular] \setupbodyfont[pagella] \starttext \startTEXpage[offset=2.5em] \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. \switchtobodyfont[changedstyles] \rm\tf Regular, \it Italic, \bf Bold and \bi BoldItalic. \stopTEXpage \stoptext
produces
\definefontfamily[changedfiles][rm][TeX Gyre Pagella][it=file:texgyreherositalic,bi=file:texgyrecursorbolditalic] \setupbodyfont[changedfiles] \starttext \startTEXpage[offset=2.5em] \tf Regular, \it Italic, \bf Bold and \bi BoldItalic.
produces
internal error: copy error QtGFQE/cropped.pdf
\definefontfamily[changedfeatures][rm][TeX Gyre Pagella][tf=features:smallcaps,bf=features:none] \setupbodyfont[pagella] \starttext \startTEXpage[offset=2.5em] \tf ffi, \it ffi, \bf ffi, \bi ffi. \switchtobodyfont[changedfeatures] \tf ffi, \it ffi, \bf ffi, \bi ffi. \stopTEXpage \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 \startTEXpage[offset=2.5em] \tf ffi, \it ffi, \bf ffi, \bi ffi. \tt Monospaced $\sqrt{3x^2}$ \stopTEXpage \stoptext
produces