Changes

Jump to navigation Jump to search
The first step is to declare the storage locations of the fonts you want ConTeXt to consider.
Either way, ConTeXt will use fonts properly stored in its tree structure (for example, any fonts you would have downloaded from [https://www.fontsquirrel.com Fonts Squirrel] [https://fonts.google.com Google Fonts], or see [[Available Free Fonts]]).
* '''TeX users create a new folder for each new font in <code>tex/texmf-fonts/fonts/</code>''', following [http://tug.org/tds/ TeX Directory Structure].
** it helps the algorithms to deal with the incredibly wide variety of fonts's variables and parameters.
** People who handle a lot of fonts can be more structured by using <code>tex/texmf-fonts/fonts/truetype/vendor/fontfamily</code>.
 
But it it's very likely that you also want to use the '''fonts already available on your Operating System''':
:* 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/Library/Fonts/.fonts;/System/Library/Fonts;$HOMEusr/Libraryshare/Fontsfonts</code>
:* Add it to your .bashrc or shell equivalent to make the declaration permanent.
;2. Run ConTeXt to index the files
Now, let's learn how to use them for typesetting.
= Practical application #1: - Quick use of a new font from = Let's take a 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 web =ConTeXt databases like shown previously, go directly to '''#2'''.
Let's take a exampleIt not, we want you have to use [https://fontsdownload and store it first.google.com/specimen/Noto+Serif Noto Serif]. The google Google website enable us to download provides a zip file with the 4 alternative variations (Regular 400, Regular 400 italic, Bold 700, Bold 700 italic).
; #1. Store them is 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>.
:* Regenerate ConTeXt databases
:** the file database: <code>mtxrun --generate</code>
:** the fonts database: <code>mtxrun --script font --reload</code>
; #2. Regenerate ConTeXt databases:* Now you can check the file database: <code>mtxrun --generate</code>:* ''fontname'' used to identify the fonts database: <code>mtxrun --script font --reload</code>, :* and check the situation run <code>mtxrun --script font --list --file -pattern=*noto*</code>:. You should obtain something like
<texcode>familyname weight style width variant fontname filename subfont fontweight
</texcode>
; #3. Your 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>
\definedfont[filename:NotoSerif-BoldItalic notoserifbolditalic*default at 12pt12 pt]
The quick brown fox jumps over the lazy dog
</texcode>
[[File:result_of_test_with_noto-serif_one.png]]
= Practical application #2: - Use the different font variations (i.e. define a typescript) =
* It's not nice to have to write \definedfont[filename:YourSuperFontyoursuperfont-WeightStyle weightstyle*default at xxpt] each time you want to use a particular font.
* That why it's worth defining a '''typescript'''. It's just 3 steps, and less than 5 minutes. Then, you will be able to easily switch between fonts with {{cmd|tf}}, {{cmd|it}}, {{cmd|bf}}, {{cmd|bi}} (see [[Font_Switching#Font_styles_and_alternatives]]), and all the typesetting of your document will use a consistent set of fonts.
* [[Typescripts_examples| Many typescripts are ready ]] for use on usual free and commercial fonts, and obviously for the [[ConTeXt_distribution's_Fonts|ConTeXt distribution's Fonts]].

Navigation menu