Changes

Jump to navigation Jump to search
Minimum effort to save yet another jargon from being orphan with a link *intentionally* set to point to a snapshot of the repo so that it will never point to a random parenthesis or a nonexistent file at all as some other links in this wiki do.
;1. Specify where ConTeXt should looked for fonts, by setting the '''OSFONTDIR''' environment variable.
:* WINDOWS: <code>set OSFONTDIR=c:/windows/fonts/</code>
:* MAC: <code>export OSFONTDIR=/Library/Fonts/;:/System/Library/Fonts;:$HOME/Library/Fonts</code>:* GNU/LINUX: <code>export OSFONTDIR=$HOME/.fonts;:/usr/share/fonts</code>
:* Add it to your .bashrc or shell equivalent to make the declaration permanent.
;2. Run ConTeXt to index the files and the fonts :
= Practical application #1 - Quick use of a new font =
Let's take a an example: we want to use [https://fonts.google.com/specimen/Noto+Serif Noto Serif].
If it is already installed on your computer, and you already updated the ConTeXt databases like shown previously, go directly to '''#2'''.
It not, you have to download and store it first. The Google website provides a zip file with the 4 alternative variations (Regular 400, Regular 400 italic, Bold 700, Bold 700 italic).
; #1. Store them is in a dedicated folder [[#Fonts location on your computer|indexed by ConTeXt]].
:* for example, create a "Noto-serif" in the ConTeXt distribution <code>tex/texmf-fonts/fonts/</code>.
:* unzip and store the .ttf file in <code>tex/texmf-fonts/fonts/Noto-serif/</code>.
; #2. Now you can check the ''fontname'' used to identify the fonts,
:*run <code>mtxrun --script font --list --file -pattern=*noto*</code>. You should obtain something like
<texcode>familyname weight style style width variant fontname filename subfont fontweight
notoserif bold bold normal normal normal normal notoserifbold NotoSerif-Bold.ttfnotoserif bold bold italic normal normal normal notoserifbolditalic NotoSerif-BoldItalic.ttfnotoserif normal italic normal normal normal notoserifitalic NotoSerif-Italic.ttfnotoserif normal normal normal normal normal notoserif NotoSerif-Regular.ttf
</texcode>
; #3. Your You are done! You can use the font anywhere in your input files with {{cmd|definedfont}}
:* it's good to add <code>*default</code> to benefit from default features, like for example [http://www.pragma-ade.com/general/manuals/fonts-mkiv.pdf#&#91;169,{%22name%22:%22Fit%22}&#93; kerning].
<texcode>
</texcode>
; #2. The boring step, define the links between ''[https://github.com/contextgarden/context-mirror/blob/a0270f13065d116355a953c6f246cbba26289fc2/tex/context/base/mkiv/font-sel.lua#L514 ConTeXt basics names]'' and the ''People-readable names''.
:* It's good to add a fallback.
<texcode>
\starttypescript [mynotoserif]
\setups[font:fallback:serif] % security: if not found==> bask back to defaults% \definefontsynonym[ConTeXt bascics basics name] [Human readable] [features=default]
\definefontsynonym[Serif] [NotoSerif-Regular] [features=default]
\definefontsynonym[SerifItalic] [NotoSerif-Italic] [features=default]
# Save your file as <code>type-(fontname|foundrysome-name-you-like).tex</code>, for example here <code>type-mynotoserif.tex</code>
# Copy the typescript files into <code>tex/texmf-fonts/tex/context/user/</code>
# Run <code>context --generate</code> to update ConTeXt file database
# It's done! Now, two lines at the beginning of any input will declare to typeset with the new fonts:
<texcode>
\usetypescriptfile[mynotoserif]% this is the 'some-name-you-like' part of the saved filename\setupbodyfont[mynotoserif]% this is the first argument to \definetypeface
</texcode>
[[Category:Fonts]]
17

edits

Navigation menu