Difference between revisions of "Use the fonts you want"

From Wiki
Jump to navigation Jump to search
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
= Quick use of a new font =
  
= Using a newly downloaded font  =
+
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 variations (Regular 400, Regular 400 italic, Bold 700, Bold 700 italic).
 
 
== 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
 
; #1. Store them is a dedicated folder
Line 26: Line 19:
 
</texcode>
 
</texcode>
  
; #3. Your are done! You can use the font anywhere on in your input files.
+
; #3. Your are done! You can use the font anywhere in your input files with {{cmd|definedfont}}
:* Use the commands {{cmd|definedfont}}
 
 
<texcode>
 
<texcode>
 
\definedfont[file:NotoSerif-BoldItalic at 12pt]
 
\definedfont[file:NotoSerif-BoldItalic at 12pt]
Line 34: Line 26:
 
[[File:result_of_test_with_noto-serif_one.png]]
 
[[File:result_of_test_with_noto-serif_one.png]]
  
== Use all the styles (3 steps, 1 min.) ==
+
= Use of the different font variations =
 +
 
 +
* It's not nice to have to write \definedfont[file:YourSuperFont-WeightStyle 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| Many typescripts are ready for use on usual free and commercial fonts]].
  
; #1. Define them as a new typescript (ConTeXt vocabulary) in your input file.
+
 
:* Use the commands {{cmd|starttypescript}} and {{cmd|definefontsynonym}} to declare
+
 
 +
; #1. Define a new typescript in your input file, with {{cmd|starttypescript}}.
 +
:* Define the links between ''filenames'' and ''People-readable names'' with {{cmd|definefontsynonym}}.
 +
:* In this example, the typescript is called "mynotoserif".
  
 
<texcode>
 
<texcode>
\starttypescript [serif] [notoserif]
+
\starttypescript [mynotoserif]
   \definefontsynonym[NotoSerif-Regular]         [file:NotoSerif-Regular]
+
% \definefontsynonym[Human readable]      [file:filename without extension]
   \definefontsynonym[NotoSerif-Italic]         [file:NotoSerif-Italic]
+
   \definefontsynonym[NotoSerif-Regular]   [file:NotoSerif-Regular]
   \definefontsynonym[NotoSerif-Bold]           [file:NotoSerif-Bold]
+
   \definefontsynonym[NotoSerif-Italic]     [file:NotoSerif-Italic]
   \definefontsynonym[NotoSerif-BoldItalic]     [file:NotoSerif-BoldItalic]
+
   \definefontsynonym[NotoSerif-Bold]       [file:NotoSerif-Bold]
 +
   \definefontsynonym[NotoSerif-BoldItalic] [file:NotoSerif-BoldItalic]
 
\stoptypescript
 
\stoptypescript
 
</texcode>
 
</texcode>
  
; #2. Define them as part of your font family, here as a roman
+
; #2. The boring step, define the links between ''ConTeXt basics names'' and the ''People-readable names''.
 +
:* It's good to add a fallback.
 
<texcode>
 
<texcode>
\definefontfamily [MyFontIdentifier] [rm] [notoserif]
+
\starttypescript [mynotoserif]
 +
  \setups[font:fallback:serif]          % security: if not found==> bask to defaults
 +
% \definefontsynonym[ConTeXt bascics name] [Human readable]      [features=default]
 +
  \definefontsynonym[Serif]                [NotoSerif-Regular]    [features=default]
 +
  \definefontsynonym[SerifItalic]          [NotoSerif-Italic]    [features=default]
 +
  \definefontsynonym[SerifBold]            [NotoSerif-Bold]      [features=default]
 +
  \definefontsynonym[SerifBoldItalic]      [NotoSerif-BoldItalic] [features=default]
 +
\stoptypescript
 +
</texcode>
 +
 
 +
; #3. Define the pack of the 4 variations as the roman typeface of the typescript "mynotoserif" :
 +
<texcode>
 +
\starttypescript [mynotoserif]
 +
  \definetypeface [mynotoserif]    [rm] [serif] [mynotoserif]    [default]
 +
\stoptypescript
 
</texcode>
 
</texcode>
  
Line 56: Line 71:
  
 
<texcode>
 
<texcode>
\starttypescript [serif] [notoserif]
+
\starttypescript [mynotoserif]
   \definefontsynonym[NotoSerif-Regular]         [file:NotoSerif-Regular]
+
   \definefontsynonym[NotoSerif-Regular]   [file:NotoSerif-Regular]
   \definefontsynonym[NotoSerif-Italic]         [file:NotoSerif-Italic]
+
   \definefontsynonym[NotoSerif-Italic]     [file:NotoSerif-Italic]
   \definefontsynonym[NotoSerif-Bold]           [file:NotoSerif-Bold]
+
   \definefontsynonym[NotoSerif-Bold]       [file:NotoSerif-Bold]
   \definefontsynonym[NotoSerif-BoldItalic]     [file:NotoSerif-BoldItalic]
+
   \definefontsynonym[NotoSerif-BoldItalic] [file:NotoSerif-BoldItalic]
 +
\stoptypescript
 +
 
 +
\starttypescript [mynotoserif]
 +
  \setups[font:fallback:serif]
 +
  \definefontsynonym[Serif]                [NotoSerif-Regular]    [features=default]
 +
  \definefontsynonym[SerifItalic]          [NotoSerif-Italic]    [features=default]
 +
  \definefontsynonym[SerifBold]            [NotoSerif-Bold]      [features=default]
 +
  \definefontsynonym[SerifBoldItalic]      [NotoSerif-BoldItalic] [features=default]
 
\stoptypescript
 
\stoptypescript
  
\definefontfamily [MyFontIdentifier] [rm] [notoserif]
+
\starttypescript [mynotoserif]
 +
  \definetypeface [mynotoserif]    [rm] [serif] [mynotoserif]    [default]
 +
\stoptypescript
  
\setupbodyfont[MyFontIdentifier]
+
\setupbodyfont[mynotoserif]
 
\setupbodyfont[12pt]
 
\setupbodyfont[12pt]
{\rm   The quick brown fox jumps over the lazy dog}\\
+
{    The quick brown fox jumps over the lazy dog}\\
{\rm\bf The quick brown fox jumps over the lazy dog}\\
+
{\it The quick brown fox jumps over the lazy dog}\\
{\rm\it The quick brown fox jumps over the lazy dog}\\
+
{\bf The quick brown fox jumps over the lazy dog}\\
 +
{\bi The quick brown fox jumps over the lazy dog}\\
 
</texcode>
 
</texcode>
  

Revision as of 17:30, 1 June 2020

Quick use of a new font

Let's take a example, we want to use Noto Serif. The google website enable us to download 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
  • create a "Noto-serif" in the ConTeXt distribution tex/texmf-fonts.
  • unzip and store the .ttf file in tex/texmf-fonts/Noto-serif/.
#2. Regenerate ConTeXt databases
  • the file database: mtxrun --generate
  • the fonts database: mtxrun --script font --reload
  • and check the situation mtxrun --script font --list --file -pattern=*noto*:
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
#3. Your are done! You can use the font anywhere in your input files with \definedfont
\definedfont[file:NotoSerif-BoldItalic at 12pt]
The quick brown fox jumps over the lazy dog

result of test with noto-serif one.png

Use of the different font variations


#1. Define a new typescript in your input file, with \starttypescript.
  • Define the links between filenames and People-readable names with \definefontsynonym.
  • In this example, the typescript is called "mynotoserif".
\starttypescript [mynotoserif]
% \definefontsynonym[Human readable]       [file:filename without extension]
  \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
#2. The boring step, define the links between ConTeXt basics names and the People-readable names.
  • It's good to add a fallback.
\starttypescript [mynotoserif]
  \setups[font:fallback:serif]          % security: if not found==> bask to defaults
% \definefontsynonym[ConTeXt bascics name] [Human readable]       [features=default]
  \definefontsynonym[Serif]                [NotoSerif-Regular]    [features=default]
  \definefontsynonym[SerifItalic]          [NotoSerif-Italic]     [features=default]
  \definefontsynonym[SerifBold]            [NotoSerif-Bold]       [features=default]
  \definefontsynonym[SerifBoldItalic]      [NotoSerif-BoldItalic] [features=default]
\stoptypescript
#3. Define the pack of the 4 variations as the roman typeface of the typescript "mynotoserif" 
\starttypescript [mynotoserif]
  \definetypeface [mynotoserif]    [rm] [serif] [mynotoserif]    [default]
\stoptypescript
#3. You are done! Finally, we have the following input file
\starttypescript [mynotoserif]
  \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

\starttypescript [mynotoserif]
  \setups[font:fallback:serif]
  \definefontsynonym[Serif]                [NotoSerif-Regular]    [features=default]
  \definefontsynonym[SerifItalic]          [NotoSerif-Italic]     [features=default]
  \definefontsynonym[SerifBold]            [NotoSerif-Bold]       [features=default]
  \definefontsynonym[SerifBoldItalic]      [NotoSerif-BoldItalic] [features=default]
\stoptypescript

\starttypescript [mynotoserif]
  \definetypeface [mynotoserif]    [rm] [serif] [mynotoserif]    [default]
\stoptypescript

\setupbodyfont[mynotoserif]
\setupbodyfont[12pt]
{    The quick brown fox jumps over the lazy dog}\\
{\it The quick brown fox jumps over the lazy dog}\\
{\bf The quick brown fox jumps over the lazy dog}\\
{\bi The quick brown fox jumps over the lazy dog}\\

And it gives:

result of test with noto-serif.png