summaryrefslogtreecommitdiff
path: root/fonts/cabin/latex/cabin.sty
blob: af1019206173cdc6e14554a337e57354524bf0cb (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cabin}
    [2019/10/21 (Bob Tennent)  Supports Cabin fonts for all LaTeX engines.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifcabin@otf 
\ifxetex
  \cabin@otftrue
\else\ifluatex
  \cabin@otftrue
\else  % [pdf]LaTeX
  \cabin@otffalse
\fi\fi

\newif\ifcabin@default \cabin@defaultfalse
\newif\ifcabin@lining \cabin@liningfalse
\newif\ifcabin@tabular \cabin@tabularfalse
\newif\ifcabin@semibold \cabin@semiboldfalse
\newif\ifcabin@medium  \cabin@mediumfalse
\newif\ifcabin@condensed \cabin@condensedfalse

\newcommand*{\Cabin@scale}{1}
\DeclareOptionX{scaled}{\renewcommand*{\Cabin@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\Cabin@scale}{#1}}

\DeclareOptionX{default}{\cabin@defaulttrue}
\DeclareOptionX{sfdefault}{\cabin@defaulttrue}
\DeclareOptionX{type1}{\cabin@otffalse}
\DeclareOptionX{semibold}{\cabin@semiboldtrue}
\DeclareOptionX{bold}{\cabin@semiboldfalse}
\DeclareOptionX{medium}{\cabin@mediumtrue}
\DeclareOptionX{regular}{\cabin@mediumfalse}
\DeclareOptionX{condensed}{\cabin@condensedtrue}

\ExecuteOptionsX{bold,regular}
\ProcessOptionsX\relax

\ifcabin@otf
  \def\cabin@boldstyle{Bold}
  \ifcabin@semibold\def\cabin@boldstyle{SemiBold}\fi
  \def\cabin@regstyle{Regular}
  \ifcabin@medium\def\cabin@regstyle{Medium}\fi

\else % type1

  \ifcabin@condensed
    \def\bfseries@sf{bc}
    \ifcabin@semibold\def\bfseries@sf{sbc}\fi
    \def\mdseries@sf{c}
    \ifcabin@medium\def\mdseries@sf{mediumcondensed}\fi
    \def\seriesdefault{\mdseries@sf}
  \else
    \def\bfseries@sf{b}
    \ifcabin@semibold\def\bfseries@sf{sb}\fi
    \def\mdseries@sf{m}
    \ifcabin@medium\def\mdseries@sf{mediumcondensed}\fi
  \fi
\fi

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

\ifcabin@otf
  \def\cabin@regular{Regular}
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Cabin@scale ,
        Extension = .otf }
  \ifcabin@condensed
    \setsansfont
        [ UprightFont    = *-\cabin@regstyle ,
          ItalicFont     = *-\ifx\cabin@regstyle\cabin@regular Italic\else\cabin@regstyle Italic\fi ,
          BoldFont       = *-\cabin@boldstyle , 
          BoldItalicFont = *-\cabin@boldstyle Italic ]
        {CabinCondensed}
  \else
    \setsansfont
        [ UprightFont    = *-\cabin@regstyle ,
          ItalicFont     = *-\ifx\cabin@regstyle\cabin@regular Italic\else\cabin@regstyle Italic\fi ,
          BoldFont       = *-\cabin@boldstyle , 
          BoldItalicFont = *-\cabin@boldstyle Italic ]
        {Cabin}
  \fi
  % grab current family in case of subsequent change:
  \let\cabinfamily\sfdefault  
  \ifcabin@default\renewcommand*\familydefault{\cabinfamily}\fi
  \newfontfamily\cabin
        [ UprightFont    = *-\cabin@regstyle ,
          ItalicFont     = *-\ifx\cabin@regstyle\cabin@regular Italic\else\cabin@regstyle Italic\fi ,
          BoldFont       = *-\cabin@boldstyle , 
          BoldItalicFont = *-\cabin@boldstyle Italic ]
        {Cabin}
  \newfontfamily\cabincondensed
        [ UprightFont    = *-\cabin@regstyle ,
          ItalicFont     = *-\ifx\cabin@regstyle\cabin@regular Italic\else\cabin@regstyle Italic\fi ,
          BoldFont       = *-\cabin@boldstyle , 
          BoldItalicFont = *-\cabin@boldstyle Italic ]
        {CabinCondensed}
\else % type1
  \def\cabinfamily{Cabin-TLF}
  \newcommand*\cabin{\fontfamily{\cabinfamily}\selectfont}
  \newcommand*\cabincondensed{%
    \def\bfseries@sf{bc}
    \ifcabin@semibold\def\bfseries@sf{sbc}\fi
    \def\mdseries@sf{c}
    \ifcabin@medium\def\mdseries@sf{mediumcondensed}\fi
    \mdseries
  }
  \def\sfdefault{\cabinfamily}
  \ifcabin@default\edef\familydefault{\sfdefault}\edef\seriesdefault{\mdseries@sf}\fi
\fi

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

\endinput