summaryrefslogtreecommitdiff
path: root/fonts/merriweather/latex/merriweather.sty
blob: d0645b1f86e8b6ee6d549855129f46394e7eac43 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
\ProvidesPackage{merriweather}[%
   2020/09/12 (Bob Tennent)  Supports Merriweather(Sans) fonts for all LaTeX engines. ] 

\RequirePackage{ifxetex,ifluatex,textcomp}

\newif\ifmerriweather@otf
\ifxetex
  \merriweather@otftrue
\else\ifluatex
  \merriweather@otftrue
\else  % [pdf]LaTeX
  \merriweather@otffalse
\fi\fi

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

\newif\ifmerriweather@rm \merriweather@rmfalse
\newif\ifmerriweather@sf \merriweather@sffalse
\newif\ifmerriweather@sfdefault \merriweather@sfdefaultfalse
\newif\ifmerriweather@rmlight \merriweather@rmlightfalse
\newif\ifmerriweather@sflight \merriweather@sflightfalse
\newif\ifmerriweather@rmblack \merriweather@rmblackfalse
\newif\ifmerriweather@sfblack \merriweather@sfblackfalse
\newif\ifmerriweather@rmlining \merriweather@rmliningfalse
\newif\ifmerriweather@rmtabular \merriweather@rmtabularfalse
\newif\ifmerriweather@sflining \merriweather@sfliningfalse
\newif\ifmerriweather@sftabular \merriweather@sftabularfalse


\DeclareOptionX{sf}{\merriweather@sftrue}
\DeclareOptionX{rm}{\merriweather@rmtrue}
\DeclareOptionX{sfdefault}{\merriweather@sftrue\merriweather@sfdefaulttrue}
\DeclareOptionX{type1}{\merriweather@otffalse}
\DeclareOptionX{light}{\merriweather@rmlighttrue\merriweather@sflighttrue}
\DeclareOptionX{rmlight}{\merriweather@rmlighttrue}
\DeclareOptionX{sflight}{\merriweather@sflighttrue}
\DeclareOptionX{black}{\merriweather@rmblacktrue\merriweather@sfblacktrue}
\DeclareOptionX{rmblack}{\merriweather@rmblacktrue}
\DeclareOptionX{sfblack}{\merriweather@sfblacktrue}
\DeclareOptionX{rmlining}{\merriweather@rmliningtrue}
\DeclareOptionX{rmoldstyle}{\merriweather@rmliningfalse}
\DeclareOptionX{sflining}{\merriweather@sfliningtrue}
\DeclareOptionX{sfoldstyle}{\merriweather@sfliningfalse}
\DeclareOptionX{rmtabular}{\merriweather@rmtabulartrue}
\DeclareOptionX{rmproportional}{\merriweather@rmtabularfalse}
\DeclareOptionX{sftabular}{\merriweather@sftabulartrue}
\DeclareOptionX{sfproportional}{\merriweather@sftabularfalse}


\ProcessOptionsX\relax

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

\ifmerriweather@rm\else\ifmerriweather@sf\else
  \merriweather@rmtrue\merriweather@sftrue  % both false -> both true
\fi\fi

\ifmerriweather@otf
  \ifmerriweather@rmlining
    \def\merriweather@figurestyle{Lining}
  \else
    \def\merriweather@figurestyle{OldStyle} 
  \fi
  \ifmerriweather@rmtabular
    \def\merriweather@figurealign{Monospaced} 
  \else
    \def\merriweather@figurealign{Proportional} 
  \fi

  \ifmerriweather@sflining
    \def\merriweathersans@figurestyle{Lining}
  \else
    \def\merriweathersans@figurestyle{OldStyle} 
  \fi
  \ifmerriweather@sftabular
    \def\merriweathersans@figurealign{Monospaced} 
  \else
    \def\merriweathersans@figurealign{Proportional} 
  \fi

  \ifmerriweather@rmlight
    \def\merriweather@regularstyle{Light}
  \else
    \def\merriweather@regularstyle{Regular}
  \fi
  \ifmerriweather@rmblack
    \def\merriweather@boldstyle{Black}
  \else
    \def\merriweather@boldstyle{Bold}
  \fi

  \ifmerriweather@sflight
    \def\merriweathersans@regularstyle{Light}
  \else
    \def\merriweathersans@regularstyle{Regular}
  \fi
  \ifmerriweather@sfblack
    \def\merriweathersans@boldstyle{ExtraBold}
  \else
    \def\merriweathersans@boldstyle{Bold}
  \fi
    
\else % type1
  \ifmerriweather@rmlining
    \def\merriweather@figurestyle{LF}
  \else
    \def\merriweather@figurestyle{OsF}
  \fi
  \ifmerriweather@rmtabular
    \def\merriweather@figurealign{T}
  \else
    \def\merriweather@figurealign{}
  \fi
  \ifmerriweather@sflining
    \def\merriweathersans@figurestyle{LF}
  \else
    \def\merriweathersans@figurestyle{OsF}
  \fi
  \ifmerriweather@sftabular
    \def\merriweathersans@figurealign{T}
  \else
    \def\merriweathersans@figurealign{}
  \fi

  \ifmerriweather@rmlight
    \def\mdseries@rm{light}
  \else
    \def\mdseries@rm{m}
  \fi
  \def\seriesdefault{\mdseries@rm}
  \ifmerriweather@rmblack
    \def\bfseries@rm{black}
  \else
    \def\bfseries@rm{b}
  \fi

  \ifmerriweather@sflight
    \def\mdseries@sf{light}
  \else
    \def\mdseries@sf{m}
  \fi
  \def\seriesdefault{\mdseries@sf}
  \ifmerriweather@sfblack
    \def\bfseries@sf{black}
  \else
    \def\bfseries@sf{b}
  \fi

\fi


% Set main and/or sans fonts:
\ifmerriweather@otf

  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .otf ,
  }
  \ifmerriweather@rm
    \ifmerriweather@rmlight
      \ifmerriweather@rmblack
        \setmainfont
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Black , 
              BoldItalicFont = *-BlackItalic ]
            {Merriweather}
        \newfontfamily\merriweather
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Black , 
              BoldItalicFont = *-BlackItalic ]
            {Merriweather}
      \else
        \setmainfont
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]
            {Merriweather}
        \newfontfamily\merriweather
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Bold , ]
            {Merriweather}
      \fi
    \else
      \ifmerriweather@rmblack
        \setmainfont
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Black , 
              BoldItalicFont = *-BlackItalic ]
            {Merriweather}
        \newfontfamily\merriweather
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Black , 
              BoldItalicFont = *-BlackItalic ]
            {Merriweather}
      \else
        \setmainfont
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]
            {Merriweather}
        \newfontfamily\merriweather
            [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]
            {Merriweather}
      \fi
    \fi
  \fi
  \ifmerriweather@sf
    \ifmerriweather@sflight
      \ifmerriweather@sfblack
        \setsansfont
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-ExtraBold , 
              BoldItalicFont = *-ExtraBoldItalic ]  
            {MerriweatherSans}
        \newfontfamily\merriweathersans
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-ExtraBold , 
              BoldItalicFont = *-ExtraBoldItalic ]  
            {MerriweatherSans}
      \else
        \setsansfont
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]  
            {MerriweatherSans}
        \newfontfamily\merriweathersans
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Light ,
              ItalicFont     = *-LightItalic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]  
            {MerriweatherSans}
      \fi
    \else
      \ifmerriweather@sfblack
        \setsansfont
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-ExtraBold , 
              BoldItalicFont = *-ExtraBoldItalic ]  
            {MerriweatherSans}
        \newfontfamily\merriweathersans
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-ExtraBold , 
              BoldItalicFont = *-ExtraBoldItalic ]  
            {MerriweatherSans}
      \else
        \setsansfont
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]  
            {MerriweatherSans}
        \newfontfamily\merriweathersans
            [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
              Scale     = \MerriwthrSans@scale ,
              UprightFont    = *-Regular ,
              ItalicFont     = *-Italic ,
              BoldFont       = *-Bold , 
              BoldItalicFont = *-BoldItalic ]  
            {MerriweatherSans}
      \fi
    \fi
  \fi
  % grab the \sfdefault in case it changes subsequently:
  \let\merriweathersffamily\sfdefault
  \ifmerriweather@sfdefault
     \renewcommand*\familydefault{\merriweathersffamily}
  \fi
  \newfontfamily\merriweatherlight
      [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
        UprightFont    = *-Light ,
        ItalicFont     = *-LightItalic ,
        BoldFont       = *-Light , 
        BoldItalicFont = *-LightItalic ]
      {Merriweather}
  \newfontfamily\merriweathersanslight
      [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
        Scale     = \MerriwthrSans@scale ,
        UprightFont    = *-Light ,
        ItalicFont     = *-LightItalic ,
        BoldFont       = *-Light ,
        BoldItalicFont = *-LightItalic ]  
      {MerriweatherSans}
  \newfontfamily\merriweatherblack
      [ Numbers = {\merriweather@figurealign,\merriweather@figurestyle},
        UprightFont    = *-Black ,
        ItalicFont     = *-BlackItalic ,
        BoldFont       = *-Black , 
        BoldItalicFont = *-BlackItalic ]
      {Merriweather}
  \newfontfamily\merriweathersansblack
      [ Numbers = {\merriweathersans@figurealign,\merriweathersans@figurestyle},
        Scale     = \MerriwthrSans@scale ,
        UprightFont    = *-ExtraBold ,
        ItalicFont     = *-ExtraBoldItalic ,
        BoldFont       = *-ExtraBold ,
        BoldItalicFont = *-ExtraBoldItalic ]  
      {MerriweatherSans}

\else % type1

  \ifmerriweather@rm
    \ifmerriweather@rmlight\def\mdseries@rm{l}\else\def\mdseries@rm{m}\fi
    \ifmerriweather@rmblack\def\bfseries@rm{eb}\else\def\bfseries@rm{b}\fi
  \else
    \def\mdseries@rm{m}\def\bfseries@rm{b}
  \fi
  \ifmerriweather@sf
    \ifmerriweather@sflight\def\mdseries@sf{l}\else\def\mdseries@sf{m}\fi
    \ifmerriweather@sfblack\def\bfseries@sf{eb}\else\def\bfseries@sf{b}\fi
  \else
    \def\mdseries@sf{m}\def\bfseries@sf{b}
  \fi



  \def\merriweatherfamily{Merriwthr-\merriweather@figurealign\merriweather@figurestyle}
  \def\merriweathersffamily{MerriwthrSans-\merriweathersans@figurealign\merriweathersans@figurestyle}

  \ifmerriweather@rm
    \renewcommand*\rmdefault{\merriweatherfamily}
  \fi

  \ifmerriweather@sf
    \renewcommand*\sfdefault{\merriweathersffamily}
  \fi

  \ifmerriweather@sfdefault
    \renewcommand*\familydefault{\merriweathersffamily}
  \fi
  
  \renewcommand*\seriesdefault{\mdseries@rm}

  \newcommand*\merriweather{\fontfamily{\merriweatherfamily}\selectfont}
  \newcommand*\merriweathersans{\fontfamily{\merriweathersffamily}\selectfont}
  \newcommand*\merriweatherlight{\fontfamily{\merriweatherfamily}\fontseries{l}\selectfont}
  \newcommand*\merriweathersanslight{\fontfamily{\merriweathersffamily}\fontseries{l}\selectfont}
  \newcommand*\merriweatherblack{\fontfamily{\merriweatherfamily}\fontseries{eb}\selectfont}
  \newcommand*\merriweathersansblack{\fontfamily{\merriweathersffamily}\fontseries{eb}\selectfont}


\fi

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

\endinput