summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/iffont/iffont.sty
blob: 97f20e8ffe6608e2cb81ac4e1586e16d20c16dc3 (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
%%
%% This is file `iffont.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% iffont.dtx  (with options: `package')
%% Copyright (C) 2015 by Benjamin Weiss <weissbenjamin@me.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Benjamin Weiss.
%% 
%% This work consists of the files iffont.dtx and iffont.ins and the
%% derived file iffont.sty.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{iffont}
    [2015/11/11 1.0.0 Iffont package]
\RequirePackage{fontspec}
\RequirePackage{etoolbox}
\newtoggle{@iffont@fontfound}
\newcommand{\@iffont@firstfont}{Fira Sans}
\newcounter{@iffont@fontsnotfound}
\newcommand{\iffontsexist}[3]{
  \setcounter{@iffont@fontsnotfound}{0}
  \expandafter\forcsvlist\expandafter\@iffont@checkfont\expandafter{#1}
  \ifnumequal{\value{@iffont@fontsnotfound}}{0}{%
    #2
  }{%
    #3
  }
}
\newcommand{\ifxfontsexist}[3]{
  \iffontsexist{#1}{#3}{#2}
}
\newcommand{\iffontexists}[3]{
  \suppressfontnotfounderror=1
  \font\x = "#1" at 10pt
  \ifx\x\nullfont
    #3
  \else
    #2
  \fi
  \suppressfontnotfounderror=0
}
\newcommand{\ifxfontexists}[3]{
  \iffontexists{#1}{#3}{#2}
}
\newcommand{\settofirstfound}[2]{
  \togglefalse{@iffont@fontfound}
  \expandafter\forcsvlist\expandafter\@iffont@checkfont\expandafter{#2}
  \let#1\@iffont@firstfont
}
\newcommand{\@iffont@checkfont}[1]{
  \suppressfontnotfounderror=1
  \font\x = "#1" at 10pt
  \ifx\x\nullfont
    \stepcounter{@iffont@fontsnotfound}
  \else
    \nottoggle{@iffont@fontfound}{%
      \renewcommand{\@iffont@firstfont}{#1}
      \toggletrue{@iffont@fontfound}
    }{}
  \fi
  \suppressfontnotfounderror=0
}
\endinput
%%
%% End of file `iffont.sty'.