summaryrefslogtreecommitdiff
path: root/fonts/gandhi/latex/gandhi.sty
blob: 6b4c1d6b0feb177a514631956048feecffe942a7 (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
\ProvidesPackage{gandhi}[%
   2017/02/26 (Bob Tennent)  Supports GandhiSerif and GandhiSans fonts for all LaTeX engines. ] 

\RequirePackage{ifxetex,ifluatex,textcomp}

\newif\ifgandhi@otf
\ifxetex
  \gandhi@otftrue
\else\ifluatex
  \gandhi@otftrue
\else  % [pdf]LaTeX
  \gandhi@otffalse
\fi\fi

\newcommand*{\GandhiSerif@scale}{1}  % not adjustable
\newcommand*{\GandhiSans@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\GandhiSans@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\GandhiSans@scale}{#1}}

\newif\ifgandhi@rm \gandhi@rmfalse
\newif\ifgandhi@sf \gandhi@sffalse
\newif\ifgandhi@sfdefault \gandhi@sfdefaultfalse
\newif\ifgandhi@lining \gandhi@liningfalse
\newif\ifgandhi@tabular \gandhi@tabularfalse

\DeclareOptionX{sf}{\gandhi@sftrue}
\DeclareOptionX{rm}{\gandhi@rmtrue}
\DeclareOptionX{sfdefault}{\gandhi@sftrue\gandhi@sfdefaulttrue}
\DeclareOptionX{type1}{\gandhi@otffalse}
\DeclareOptionX{osf}{\gandhi@liningfalse}
\DeclareOptionX{oldstyle}{\gandhi@liningfalse}
\DeclareOptionX{lf}{\gandhi@liningtrue}
\DeclareOptionX{lining}{\gandhi@liningtrue}
\DeclareOptionX{proportional}{\gandhi@tabularfalse}
\DeclareOptionX{p}{\gandhi@tabularfalse}
\DeclareOptionX{tabular}{\gandhi@tabulartrue}
\DeclareOptionX{t}{\gandhi@tabulartrue}


\ProcessOptionsX\relax

\ifgandhi@otf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes}
\fi

\ifgandhi@rm\else\ifgandhi@sf\else
  \gandhi@rmtrue\gandhi@sftrue  % both false -> both true
\fi\fi

\ifgandhi@otf
  \ifgandhi@lining
    \def\gandhi@figurestyle{Lining}
  \else
    \def\gandhi@figurestyle{OldStyle}
  \fi
  \ifgandhi@tabular
    \def\gandhi@figurealign{Monospaced} 
  \else
    \def\gandhi@figurealign{Proportional} 
  \fi

\else 

  \ifgandhi@lining
    \def\gandhi@figurestyle{LF} 
  \else
    \def\gandhi@figurestyle{OsF} 
  \fi
  \ifgandhi@tabular
    \def\gandhi@figurealign{T} 
  \else
    \def\gandhi@figurealign{} 
  \fi

\fi



% Set main and/or sans fonts:
\ifgandhi@otf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .otf ,
  }
  \ifgandhi@rm
    \setmainfont
        [ Numbers   = {\gandhi@figurestyle,\gandhi@figurealign},
          UprightFont    = *-Regular ,
          ItalicFont     = *-Italic ,
          BoldFont       = *-Bold , 
          BoldItalicFont = *-BoldItalic ]
        {GandhiSerif}
  \fi
  \ifgandhi@sf
    \setsansfont
        [ Numbers   = {\gandhi@figurestyle,\gandhi@figurealign},
          Scale     = \GandhiSans@scale ,
          UprightFont    = *-Regular ,
          ItalicFont     = *-Italic ,
          BoldFont       = *-Bold , 
          BoldItalicFont = *-BoldItalic ]  
        {GandhiSans}
  \fi
  % grab the \sfdefault in case it changes subsequently:
  \let\gandhisffamily\sfdefault
  \ifgandhi@sfdefault
     \renewcommand*\familydefault{\gandhisffamily}
  \fi

  \newfontfamily\gandhi
      [ Numbers   = {\gandhi@figurestyle,\gandhi@figurealign},
        UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
        BoldItalicFont = *-BoldItalic ]
      {GandhiSerif}
  \newfontfamily\gandhisans
        [ Numbers   = {\gandhi@figurestyle,\gandhi@figurealign},
          Scale     = \GandhiSans@scale ,
          UprightFont    = *-Regular ,
          ItalicFont     = *-Italic ,
          BoldFont       = *-Bold , 
          BoldItalicFont = *-BoldItalic ]  
        {GandhiSans}

\else % type1
  \def\gandhifamily{GandhiSerif-\gandhi@figurealign\gandhi@figurestyle}
  \def\gandhisffamily{GandhiSans-\gandhi@figurealign\gandhi@figurestyle}

  \ifgandhi@rm
    \renewcommand*\rmdefault{\gandhifamily}
  \fi

  \ifgandhi@sf
    \renewcommand*\sfdefault{\gandhisffamily}
  \fi

  \ifgandhi@sfdefault
    \renewcommand*\familydefault{\gandhisffamily}
  \fi
  
  \newcommand*\gandhi{\fontfamily{\gandhifamily}\selectfont}
  \newcommand*\gandhisans{\fontfamily{\gandhisffamily}\selectfont}

\fi

% turn off defaults in case other fonts are selected:
\ifgandhi@otf
  \defaultfontfeatures{}
\fi

\endinput