summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/beamertheme-metropolis/beamerfontthememetropolis.dtx
blob: 4c9b4516bd34b1ecae5e4ac6d72a6e192bb7f2ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
% \iffalse meta-comment -------------------------------------------------------
% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of
% contributors can be found at
%
%     https://github.com/matze/mtheme/graphs/contributors
%
% and the original template was based on the HSRM theme by Benjamin Weiss.
%
% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
% International License (https://creativecommons.org/licenses/by-sa/4.0/).
% ------------------------------------------------------------------------- \fi
% \iffalse
%<driver> \ProvidesFile{beamerfontthememetropolis.dtx}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerfontthememetropolis}[2015/12/04 Metropolis font theme]
%</package>
%<driver> \documentclass{ltxdoc}
%<driver> \usepackage{beamerfontthememetropolis}
%<driver> \begin{document}
%<driver> \DocInput{beamerfontthememetropolis.dtx}
%<driver> \end{document}
% \fi
% \CheckSum{0}
% \StopEventually{}
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
% \subsection{\textsc{metropolis} font theme}
%
%
% Load required packages.
%    \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}
%    \end{macrocode}
%
% \subsubsection{Load Fira font}
% If the presentation is compiled with XeLaTeX or LuaLaTeX the fontspec package
% will be loaded.
%    \begin{macrocode}
\ifboolexpr{bool {xetex} or bool {luatex}}{
  \RequirePackage[no-math]{fontspec}
%    \end{macrocode}
%
% To simplify the check whether the |Fira| fonts are installed, a set macros is
% defined.
%
% \begin{macro}{\checkfont}
% Checks if a font is installed and increases |fontsnotfound| counter if not.
%    \begin{macrocode}
  \newcounter{fontsnotfound}
  \newcommand{\checkfont}[1]{%
    \suppressfontnotfounderror=1%
    \font\x = "#1" at 10pt
    \selectfont
    \ifx\x\nullfont%
      \stepcounter{fontsnotfound}%
    \fi%
    \suppressfontnotfounderror=0%
  }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffontexists}
% Resets the |fontsnotfound| counter and calls |\checkfont| for each font in
% the comma separated list in the first argument.
%    \begin{macrocode}
  \newcommand{\iffontsexist}[3]{%
    \setcounter{fontsnotfound}{0}%
    \expandafter\forcsvlist\expandafter%
    \checkfont\expandafter{#1}%
    \ifnum\value{fontsnotfound}=0%
      #2%
    \else%
      #3%
    \fi%
  }
%    \end{macrocode}
% \end{macro}
%
% Using the previously defined macros it is tried to load the |Fira| fonts.
% First the default |Fira| name will be tried. Second the |Fira| fonts with
% the suffix OT -- used by some Linux distributions -- will be tried. If this
% also fails a warning will be displayed and the standard fonts will be used.
%
%    \begin{macrocode}
  \iffontsexist{Fira Sans Light,%
                Fira Sans Light Italic,%
                Fira Sans,%
                Fira Sans Italic}{%
    \setsansfont[BoldFont={Fira Sans}]{Fira Sans Light}%
  }{%
    \iffontsexist{Fira Sans Light OT,%
                  Fira Sans Light Italic OT,%
                  Fira Sans OT,%
                  Fira Sans Italic OT}{%
      \setsansfont[BoldFont={Fira Sans OT}]{Fira Sans Light OT}%
    }{%
      \PackageWarning{beamerthememetropolis}{%
        Could not find Fira Sans fonts%
      }
    }
  }
  \iffontsexist{Fira Mono, Fira Mono Bold}{%
    \setmonofont{Fira Mono}%
  }{%
    \iffontsexist{Fira Mono OT, Fira Mono Bold OT}{%
      \setmonofont{Fira Mono OT}%
    }{%
      \PackageWarning{beamerthememetropolis}{%
        Could not find Fira Mono fonts%
      }
    }
  }
  \AtBeginEnvironment{tabular}{%
    \addfontfeature{Numbers={Monospaced}}%
  }
}{%
  \PackageWarning{beamerthememetropolis}{%
    You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts%
  }
}
%    \end{macrocode}
%
%
%
% \subsubsection{General font definitions}
%
%    \begin{macrocode}
\setbeamerfont{title}{size=\Large,%
                      series=\bfseries}
\setbeamerfont{author}{size=\small}
\setbeamerfont{date}{size=\small}
\setbeamerfont{section title}{size=\Large,%
                              series=\bfseries}
\setbeamerfont{plain title}{size=\Large,%
                            series=\bfseries}
\setbeamerfont{block title}{size=\normalsize,%
                            series=\bfseries}
\setbeamerfont{block title alerted}{size=\normalsize,%
                                    series=\bfseries}
\setbeamerfont*{subtitle}{size=\large}
\setbeamerfont{frametitle}{size=\large,%
                           series=\bfseries}
\setbeamerfont{caption}{size=\small}
\setbeamerfont{caption name}{series=\bfseries}
\setbeamerfont{description item}{series=\bfseries}
\setbeamerfont{page number in head/foot}{size=\scriptsize}
\setbeamerfont{bibliography entry author}{size=\normalsize,%
                                          series=\normalfont}
\setbeamerfont{bibliography entry title}{size=\normalsize,%
                                         series=\bfseries}
\setbeamerfont{bibliography entry location}{size=\normalsize,%
                                            series=\normalfont}
\setbeamerfont{bibliography entry note}{size=\small,%
                                        series=\normalfont}
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
% \Finale
\endinput