Changes

Jump to navigation Jump to search
3,056 bytes removed ,  14:38, 1 June 2020
no edit summary
* [[Use_fonts_not_provided_by_the_distribution_(2020)]]
 
= Using a newly downloaded font =
 
== Quickly use one of the styles (3 steps, 1 min.) ==
 
Let's take a example, we want to use [https://fonts.google.com/specimen/Noto+Serif Noto Serif]. The google website enable us to download a zip file with the 4 alternative styles:
* Regular 400
* Regular 400 italic
* Bold 700
* Bold 700 italic
 
; #1. Store them is a dedicated folder
:* create a "Noto-serif" in the ConTeXt distribution <code>tex/texmf-fonts</code>.
:* unzip and store the .ttf file in <code>tex/texmf-fonts/Noto-serif/</code>.
 
; #2. Regenerate ConTeXt databases
:* the file database: <code>mtxrun --generate</code>
:* the fonts database: <code>mtxrun --script font --reload</code>
:* and check the situation <code>mtxrun --script font --list --file -pattern=*noto*</code>:
<texcode>familyname weight style width variant fontname filename subfont fontweight
 
notoserif bold normal normal normal notoserifbold NotoSerif-Bold.ttf
notoserif bold italic normal normal notoserifbolditalic NotoSerif-BoldItalic.ttf
notoserif normal italic normal normal notoserifitalic NotoSerif-Italic.ttf
notoserif normal normal normal normal notoserif NotoSerif-Regular.ttf
</texcode>
 
; #3. Your are done! You can use the font anywhere on in your input files.
:* Use the commands {{cmd|definedfont}}
<texcode>
\definedfont[file:NotoSerif-BoldItalic at 12pt]
The quick brown fox jumps over the lazy dog
</texcode>
[[File:result_of_test_with_noto-serif_one.png]]
 
== Use all the styles (3 steps, 1 min.) ==
 
; #1. Define them as a new typescript (ConTeXt vocabulary) in your input file.
:* Use the commands {{cmd|starttypescript}} and {{cmd|definefontsynonym}} to declare
 
<texcode>
\starttypescript [serif] [notoserif]
\definefontsynonym[NotoSerif-Regular] [file:NotoSerif-Regular]
\definefontsynonym[NotoSerif-Italic] [file:NotoSerif-Italic]
\definefontsynonym[NotoSerif-Bold] [file:NotoSerif-Bold]
\definefontsynonym[NotoSerif-BoldItalic] [file:NotoSerif-BoldItalic]
\stoptypescript
</texcode>
 
; #2. Define them as part of your font family, here as a roman
<texcode>
\definefontfamily [MyFontIdentifier] [rm] [notoserif]
</texcode>
 
; #3. You are done! Finally, we have the following input file:
 
<texcode>
\starttypescript [serif] [notoserif]
\definefontsynonym[NotoSerif-Regular] [file:NotoSerif-Regular]
\definefontsynonym[NotoSerif-Italic] [file:NotoSerif-Italic]
\definefontsynonym[NotoSerif-Bold] [file:NotoSerif-Bold]
\definefontsynonym[NotoSerif-BoldItalic] [file:NotoSerif-BoldItalic]
\stoptypescript
 
\definefontfamily [MyFontIdentifier] [rm] [notoserif]
 
\setupbodyfont[MyFontIdentifier]
\setupbodyfont[12pt]
{\rm The quick brown fox jumps over the lazy dog}\\
{\rm\bf The quick brown fox jumps over the lazy dog}\\
{\rm\it The quick brown fox jumps over the lazy dog}\\
</texcode>
 
And it gives:
 
[[File:result_of_test_with_noto-serif.png]]
= Next ? =

Navigation menu