summaryrefslogtreecommitdiff
path: root/fonts/cooperhewitt/latex/CooperHewitt.sty
blob: 3b3c965ff046cc7bef72977faecca1c9dacd8bab (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{CooperHewitt}
    [2022/10/18 (Bob Tennent) Supports Cooper Hewitt fonts for all LaTeX engines.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}
\newif\ifcphwt@otf 
\ifxetex
  \cphwt@otftrue
\else\ifluatex
  \cphwt@otftrue
\else  % [pdf]LaTeX
  \cphwt@otffalse
\fi\fi

\newif\ifcphwt@default \cphwt@defaultfalse
\newif\ifcphwt@semibold \cphwt@semiboldfalse
\newif\ifcphwt@medium  \cphwt@mediumfalse
\newif\ifcphwt@heavy  \cphwt@heavyfalse
\newif\ifcphwt@thin  \cphwt@thinfalse
\newif\ifcphwt@light  \cphwt@lightfalse

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

\DeclareOptionX{default}{\cphwt@defaulttrue}
\DeclareOptionX{sfdefault}{\cphwt@defaulttrue}
\DeclareOptionX{type1}{\cphwt@otffalse}

\DeclareOptionX{semibold}{\cphwt@semiboldtrue}
\DeclareOptionX{heavy}{\cphwt@heavytrue}
\DeclareOptionX{medium}{\cphwt@mediumtrue}
\DeclareOptionX{thin}{\cphwt@thintrue}
\DeclareOptionX{light}{\cphwt@lighttrue}

\ProcessOptionsX\relax

\ifcphwt@otf

  \def\cphwt@boldstyle{Bold}
  \ifcphwt@semibold\def\cphwt@boldstyle{SemiBold}\fi
  \ifcphwt@heavy\def\cphwt@boldstyle{Heavy}\fi
  \def\cphwt@regstyle{Book}
  \ifcphwt@medium\def\cphwt@regstyle{Medium}\fi
  \ifcphwt@thin\def\cphwt@regstyle{Thin}\fi
  \ifcphwt@light\def\cphwt@regstyle{Light}\fi

\else  % type1

\IfFileExists{fontaxes.sty}{
    \RequirePackage{fontaxes}
    \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
    \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
    \def\supfigures{\@nomath\supfigures
        \fontfigurestyle{superior}\selectfont}
    \let\sufigures\supfigures
    \let\textsu\textsup
    \let\textsuperior\textsup

}{}

  \def\bfseries@sf{bold}
  \ifcphwt@semibold\def\bfseries@sf{semibold}\fi
  \ifcphwt@heavy\def\bfseries@sf{heavy}\fi
  \def\mdseries@sf{book}
  \ifcphwt@medium\def\mdseries@sf{medium}\fi
  \ifcphwt@thin\def\mdseries@sf{thin}\fi
  \ifcphwt@light\def\mdseries@sf{light}\fi
\fi

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

\ifcphwt@otf

  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \CpHwt@scale ,
        Extension = .otf }
  \setsansfont
      [ UprightFont    = *-\cphwt@regstyle ,
        ItalicFont     = *-\cphwt@regstyle Italic ,
        BoldFont       = *-\cphwt@boldstyle , 
        BoldItalicFont = *-\cphwt@boldstyle Italic ]
      {CooperHewitt}

% grab current family in case of subsequent change:
  \let\cphwtfamily\sfdefault  
  \ifcphwt@default\renewcommand*\familydefault{\cphwtfamily}\fi

  \newfontfamily\cooperhewitt
      [ UprightFont    = *-\cphwt@regstyle ,
        ItalicFont     = *-\cphwt@regstyle Italic ,
        BoldFont       = *-\cphwt@boldstyle , 
        BoldItalicFont = *-\cphwt@boldstyle Italic ]
      {CooperHewitt}

  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}


\else % type1

  \def\cphwtfamily{CpHwt-TLF}
  \newcommand*\cooperhewitt{\fontfamily{\cphwtfamily}\selectfont}
  \def\sfdefault{\cphwtfamily}
  \ifcphwt@default\edef\familydefault{\sfdefault}\edef\seriesdefault{\mdseries@sf}\fi

\fi

\DeclareTextFontCommand{\textsu}{\sufigures}

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


\endinput