%This style file allows to easily switch between many fonts.
%It is particularly useful when working with 16bits TeX
%but it can be used with normal TeX too (with less
%font choices).
%
%This style uses options to determine the fonts to use.
% lmodern (or nothing) to choose the default font "lmmodern".
% cmunicode to use the "cmunicode" fonts. This fonts
% has been created with all the CM fonts for 8bits TeX
% and it is quite nice. THe characters are similar to lmmodern
% with more glyphs (greek, cyrillic IPA) and no math font.
% L'aspect des caractères est similaire à latin Modern.
% Some of the characters are based on the good fonts from BlueSky.
% didot to use GFS Didot with Asana Math for mathematic.
% When 8bits TeX is used, the package "gfsdidot" is loaded.
% lucida to use lucida (mathematic and standard)
% stix to use STIX2 fonts (Mathematic and Standard)
% cambria to use Cambria with Cambria Math
% Calibri is used for the sans serif font.
% dejavu to use DejaVu (serif) and the math fonts from GUST foundry.
% dejavusans to use DejaVu Sans for text and Math. To complement
% the LucidaBrightOT is used. When 8bits TeX is used,
% the package "arev" is loaded.
% neohellenic to use GFS Neo Hellenic with GFSNeoHellenicMath.
%
%
%
%
% — Normally, other sahpe (tt or sans) are Latin Modern or DejaVu.
%
% — Fonts "Latin Modern", "GFS Didot" and "Asana" are provided
% (in usul directories) with all TeX distributions.
% — The fonts «STIX» version 2 (similar to Times Roman)
% should be installed, after being downloaded from site
% «
http://www.stixfonts.org/», in the usual directories of TeX.
% — The fonts family "Lucida" should be bought at TUG
% (
https://www.tug.org) and installed in usual TeX directories.
% — The fonts "Cambria", "Cambria Math" and "Calibri" should be installed
% as system fonts. This is generally the case when Excel is installed.
%
% — For the TeX 8bits, the fonts lmmodern is used except when gfsdidot or arev is loaded.
% To use an other fonts, one can load the correct package after this style.
% Par exemple, \usepackage[charter]{mathdesign}
%
% — This code has been tested with XeLateX (TeX 16bits) and pdflatex (TeX 8bits).
\chardef\PoliceLatinModern=0
\chardef\PoliceDidot=1
\chardef\PoliceLucida=2
\chardef\PoliceStixII=3
\chardef\PoliceCambria=4
\chardef\PoliceDejaVu=5
\chardef\PoliceCmUnicode=6
\chardef\PoliceDejavuSans=7
\chardef\PoliceNeoHellenic=8
%Useful to have an invalid value for a font. A such value can be used
%as an initializer or a delimiter of list
\chardef\PoliceInvalide=254
%The default font used to typeset the document if the wanted font
%is not found. If one change this font, he should change
%the macros '\PoliceParDefaut' and '\MainFontDocText' accordingly.
\chardef\PoliceDocumentParDefaut=\PoliceLatinModern
%The real font of the document
\chardef\PoliceDocument\PoliceDocumentParDefaut
%The wanted font of the document. This macro and the previous one
%have the same value if the font is found but might differ
%if the default font is used when the wanted font cannot be found.
\chardef\PoliceDesiree\PoliceLatinModern
\DeclareOption{lmodern}{\chardef\PoliceDocument\PoliceLatinModern
\chardef\PoliceDesiree\PoliceLatinModern}
\DeclareOption{didot}{\chardef\PoliceDocument\PoliceDidot
\chardef\PoliceDesiree\PoliceDidot}
\DeclareOption{lucida}{\chardef\PoliceDocument\PoliceLucida
\chardef\PoliceDesiree\PoliceLucida}
\DeclareOption{stix}{\chardef\PoliceDocument\PoliceStixII
\chardef\PoliceDesiree\PoliceStixII}
\DeclareOption{cambria}{\chardef\PoliceDocument\PoliceCambria
\chardef\PoliceDesiree\PoliceCambria}
\DeclareOption{dejavu}{\chardef\PoliceDocument\PoliceDejaVu
\chardef\PoliceDesiree\PoliceDejaVu}
\DeclareOption{cmunicode}{\chardef\PoliceDocument\PoliceCmUnicode
\chardef\PoliceDesiree\PoliceCmUnicode}
\DeclareOption{dejavusans}{\chardef\PoliceDocument\PoliceDejavuSans
\chardef\PoliceDesiree\PoliceDejavuSans}
\DeclareOption{neohellenic}{\chardef\PoliceDocument\PoliceNeoHellenic
\chardef\PoliceDesiree\PoliceNeoHellenic}
\ProcessOptions
\usepackage{iftex}
%
%-------------------------------------Macros provided by the style--------------------------
%
%This macro provides the default settings when no font is specified (for TeX Unicode only).
%The default is to use the font Latin Modern and generally since it is
%the current default from pdfTeX, XeTeX and LuaTeX, almost nothing
%should be done.
%
%Since this fonts does not provide the greek character, these one are taken
%from the very similar CM Unicode font.
%
%This Macro has no parameter.
%
%This macro modify the global variable/macro "\PoliceDocument"
\newcommand\PoliceParDefaut{%
\iftutex %16 bits TeX
%The default font is Latin Modern, always defined with 16 bits TeX.
%However, Greek is missing from Latin Modern. It will be taken from
%the almost identical font CM Unicode.
%The command «\greekfont» is used with "polyglossia" and
%probably "babel".
\newfontfamily\greekfont[Script=Greek]{cmunrm.otf}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=cmunbx,%
ItalicFont=cmunti,%
BoldItalicFont=cmunbi]%
\else %8bits TeX
\RequirePackage{lmodern}%
\fi
\chardef\PoliceDocument\PoliceDocumentParDefaut
}
%This macros contain the text to describe
%the default main font of the document.
%
%The macro has no parameter
\newcommand\MainFontDocText{%
\iftutex{Latin Modern (Unicode)}\else{Latin Modern (\TeX)}\fi
}
%This macro typeset the name of the current set of fonts used to format
%the document.
%The name is similar to the option choosen but generally more suitable to be
%typeset in a document.
%
%To know, programmatically, the current font of the document, it's much
%better to use the macro "\PoliceDocument".
%
%The macro has no parameter.
\newcommand\MainDocFontName[1][\PoliceDocument]{
\iftutex
\ifcase#1%
%Latin Modern
\MainFontDocText
\or
%Didot
GFS Didot, Asana Math%
\or
%Lucida
Lucida%
\or
%Stix version 2
Stix 2%
\or
%Cambria
Cambria, Cambria Math%
\or
%DejaVu
DejaVu, TeX Gyre DejaVu Math%
\or
%CMUnicode
CMUnicode, Latin Modern Math%
\or
%DejaVuSans
\IfFontExistsTF{LucidaBrightMathOT.otf}{%
DejaVu Sans, Lucida Bright Math%
}{%
DejaVu Sans, DejaVu Sans Math%
}%
\or
%NeoHellenic
GFS NeoHellenic%
\else
\MainFontDocText
\fi
\else
%TeX standard
\ifx\PoliceDocument\PoliceDejavuSans
%Arev
Arev (\TeX)%
\else
\ifx\PoliceDocument\PoliceDidot
%Didot
GFS Didot (\TeX)%
\else
%The default, lmmodern
\MainFontDocText
\fi
\fi
\fi
}
%This macro setup the definition to setup a font (in almost
%all the possible modes: Text, Math, Greek etc) in a 16 Bits LaTeX (lualatex,xelatex)
%and to setup the default font in 8bit TeX.
%
%The macro has 3 parameters:
% 1) the name of the font in a form usable by the command
% "\IfFontExistsTF" of the package "fontspec"
% 2) the set of command to define the fonts to be used
% 3) a set of commands used as a fallback in the case of the font
% is unavailable on a system
%
%Only the second parameter is used with 8 bits TeX.
\newcommand\ChoixPolice[3]{%
\iftutex %TeX 16 bits
\IfFontExistsTF{#1}{#2}{%Font wanted not found
\wlog{The font #1 is not found. The font '\MainFontDocText' will be used instead.}%
#3}%
\else %TeX 8bits
#2%
\fi
}
%The following macros define the commands to be able to use the different
%available fonts in a document. Since they are so many fonts available, only
%the fonts with mathemathecal counterpart are defined.
\newcommand\ChoixDidot{%
\ChoixPolice{GFSDidot.otf}{%
\setmathfont{Asana-Math.otf}%
\setmainfont{GFSDidot}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=*Bold,%
ItalicFont=*Italic,%
BoldItalicFont=*BoldItalic%
]%
\setsansfont{DejaVuSans}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
Scale = MatchLowercase%
]%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
}{\PoliceParDefaut}%
}
\newcommand\ChoixLucida{%
\ChoixPolice{LucidaBrightOT.otf}{%
% Slightly reduce the size.
%\defaultfontfeatures{Scale=.92}
\setmathfont{LucidaBrightMathOT.otf}%
\setmathfont[version=bold]{LucidaBrightMathOT-Demi.otf}%
%
% The explicit .otf extension tells the engines to find the font via%
% filenames in the TeX trees, rather than as system-installed fonts.%
%
\setmainfont{LucidaBrightOT}[% main rm%
Extension=.otf,%
UprightFont=*,%
ItalicFont=*-Italic,%
BoldFont=*-Demi,%
BoldItalicFont=*-DemiItalic,%
]%
%
\setsansfont{LucidaSansOT}[% main sans%
Extension=.otf,%
UprightFont=*,%
ItalicFont=*-Italic,%
BoldFont=*-Demi,%
BoldItalicFont=*-DemiItalic,%
]%
%
\setmonofont{LucidaSansTypewriterOT.otf}[% main typewriter%
Extension=.otf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
%
%
% The specialized one-off fonts:%
\newfontface\LucidaBlackletter{LucidaBlackletterOT.otf}%
\newfontface\LucidaCalligraphy{LucidaCalligraphyOT.otf}%
\newfontface\LucidaHandwriting{LucidaHandwritingOT.otf}%
}{\PoliceParDefaut}%
}
\newcommand\ChoixStix{%
\ChoixPolice{STIX2Text-Regular.otf}{%
%Stix version 2 (the first version working with TeX)
\setmathfont{STIX2Math.otf}%
\setmainfont{STIX2Text}[%
Extension=.otf,%
UprightFont=*-Regular,%
ItalicFont=*-Italic,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldItalic,%
]%
\setsansfont{DejaVuSans}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
%The macro "\greekfont" is used with "polyglossia" and "babel"%
\newfontfamily\greekfont[Script=Greek]{LinLibertine_R.otf}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=LinLibertine_RB,%
ItalicFont=LinLibertine_RI,%
BoldItalicFont=LinLibertine_RBI]%
}{\PoliceParDefaut}%
}
\newcommand\ChoixCambria{%
\ChoixPolice{Cambria}{%
\setmathfont{Cambria Math}%
\setmainfont{Cambria}%
\setsansfont{Calibri}%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
}{\PoliceParDefaut}%
}
\newcommand\ChoixDejaVu{%
\ChoixPolice{DejaVuSerif.ttf}{%
\setmathfont{texgyredejavu-math.otf}%
\setmainfont{DejaVuSerif}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Italic,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldItalic,%
]%
\setsansfont{DejaVuSans}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
}{\PoliceParDefaut}%
}
\newcommand\ChoixCMUnicode{%
\ChoixPolice{cmunrm.otf}{%
%Latin Modern is used for math. For the rest, the CM Unicode (very similar to Latin
%Modern is used). CM Unicode has more characters than Latin Modern
\setmainfont{cmunrm}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=cmunbx,%
ItalicFont=cmunti,%
BoldItalicFont=cmunbi]%
\setsansfont{cmunss}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=cmunsx,%
ItalicFont=cmunsi,%
BoldItalicFont=cmunso]%
\setmonofont{cmuntt}[%
Extension=.otf,%
UprightFont=*,%
BoldFont=cmuntb,%
ItalicFont=cmunst,%
BoldItalicFont=cmuntx]%
}{\PoliceParDefaut}%
}
\newcommand\ChoixDejaVuSans{%
\ChoixPolice{DejaVuSans.ttf}{%
\IfFontExistsTF{LucidaBrightMathOT.otf}{%
\setmathfont{LucidaBrightMathOT.otf}%Font color match better with dejaVuSans
}{%
\setmathfont{DejaVuSans.ttf}%
}%
\setmathfont{DejaVuSans.ttf}[range=up]%
\setmathfont{DejaVuSans.ttf}[range=bb->bfsfup]%
\setmathfont{DejaVuSans-Oblique.ttf}[range=it]%
\setmathfont{DejaVuSansMono.ttf}[range=tt]%
\setmathfont{DejaVuSans-Bold.ttf}[range=bfup]%
\setmathfont{DejaVuSans-BoldOblique.ttf}[range=bfit]%
\setmainfont{DejaVuSerif}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Italic,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldItalic,%
]%
\setsansfont{DejaVuSans}[%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
\renewcommand\familydefault{\sfdefault}%
}{\PoliceParDefaut}%
}
\newcommand\ChoixNeohellenic{%
\ChoixPolice{GFSNeohellenic.otf}{%
%Load GFS Neo Hellenic as the sans font and use the GFS Neo Hellenic
%for math. Do some specific adaptation for the GFS Neo Hellenic at 12pt.
\RequirePackage{gfsneohellenicot}%
\setmonofont{DejaVuSansMono}[% main typewriter%
Extension=.ttf,%
UprightFont=*,%
ItalicFont=*-Oblique,%
BoldFont=*-Bold,%
BoldItalicFont=*-BoldOblique,%
]%
\renewcommand\familydefault{\sfdefault}%
}{\PoliceParDefaut}%
}
%
%--------------------------------------Code executed when loading style----------------------
%
\iftutex
\usepackage{unicode-math}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\ifcase\PoliceDocument
%Latin Modern is the default font
\PoliceParDefaut
\or
\ChoixDidot
\or
\ChoixLucida
\or
\ChoixStix
\or
\ChoixCambria
\or
\ChoixDejaVu
\or
\ChoixCMUnicode
\or
\ChoixDejaVuSans
\or
\ChoixNeohellenic
\else
\PoliceParDefaut
\fi
\else
%TeX standard
\RequirePackage{amssymb}
\ifx\PoliceDocument\PoliceDejavuSans
\RequirePackage{arev}
\else
\ifx\PoliceDocument\PoliceDidot
\RequirePackage{gfsdidot}
\else
\PoliceParDefaut
\fi
\fi
\fi