summaryrefslogtreecommitdiff
path: root/fonts/cormorantgaramond/latex/CormorantGaramond.sty
blob: 5a2742fd5ef04d664f46ea38adc4d303e12fe100 (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{CormorantGaramond}
    [2022/09/16 (Bob Tennent and autoinst)  Style file for Cormorant Garamond fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifcormorantgaramond@ttf 
\ifxetex
  \cormorantgaramond@ttftrue
\else\ifluatex
  \cormorantgaramond@ttftrue
\else  % [pdf]LaTeX
  \cormorantgaramond@ttffalse
\fi\fi

\newif\ifcormorantgaramond@lining \cormorantgaramond@liningtrue
\newif\ifcormorantgaramond@tabular \cormorantgaramond@tabularfalse
\newif\ifcormorantgaramond@semibold \cormorantgaramond@semiboldfalse
\newif\ifcormorantgaramond@medium \cormorantgaramond@mediumfalse
\newif\ifcormorantgaramond@light \cormorantgaramond@lightfalse

\newcommand*{\CormorantGaramond@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\CormorantGaramond@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\CormorantGaramond@scale}{#1}}
\DeclareOptionX{type1}{\cormorantgaramond@ttffalse}
\DeclareOptionX{lining}{\cormorantgaramond@liningtrue}
\DeclareOptionX{nf}{\cormorantgaramond@liningtrue}
\DeclareOptionX{lf}{\cormorantgaramond@liningtrue}
\DeclareOptionX{oldstyle}{\cormorantgaramond@liningfalse}
\DeclareOptionX{osf}{\cormorantgaramond@liningfalse}
\DeclareOptionX{tabular}{\cormorantgaramond@tabulartrue}
\DeclareOptionX{t}{\cormorantgaramond@tabulartrue}
\DeclareOptionX{proportional}{\cormorantgaramond@tabularfalse}
\DeclareOptionX{p}{\cormorantgaramond@tabularfalse}
\DeclareOptionX{semibold}{\cormorantgaramond@semiboldtrue}
\DeclareOptionX{sb}{\cormorantgaramond@semiboldtrue}
\DeclareOptionX{medium}{\cormorantgaramond@mediumtrue}
\DeclareOptionX{light}{\cormorantgaramond@lighttrue}


\ProcessOptionsX\relax

\ifcormorantgaramond@ttf
  \ifcormorantgaramond@lining
    \def\cormorantgaramond@figurestyle{Lining}
  \else
    \def\cormorantgaramond@figurestyle{OldStyle} 
  \fi
  \ifcormorantgaramond@tabular
    \def\cormorantgaramond@figurealign{Monospaced} 
  \else
    \def\cormorantgaramond@figurealign{} 
  \fi
\else % type1
  \ifcormorantgaramond@lining
    \def\cormorantgaramond@figurestyle{LF}
  \else
    \def\cormorantgaramond@figurestyle{OsF}
  \fi
  \ifcormorantgaramond@tabular
    \def\cormorantgaramond@figurealign{T}
  \else
    \def\cormorantgaramond@figurealign{}
  \fi
\fi

\ifcormorantgaramond@ttf
  \def\cormorantgaramond@boldstyle{Bold}
  \ifcormorantgaramond@semibold\def\cormorantgaramond@boldstyle{SemiBold}\fi
  \ifcormorantgaramond@medium\def\cormorantgaramond@boldstyle{Medium}\fi
  \def\cormorantgaramond@regstyle{Regular}
  \ifcormorantgaramond@light\def\cormorantgaramond@regstyle{Light}\fi
\else
  \def\bfseries@rm{b}
  \ifcormorantgaramond@semibold\def\bfseries@rm{sb}\fi
  \ifcormorantgaramond@medium\def\bfseries@rm{medium}\fi
  \def\mdseries@rm{m}
  \ifcormorantgaramond@light\def\mdseries@rm{l}\fi
\fi

\ifcormorantgaramond@ttf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes,mweights}
\fi

\ifcormorantgaramond@ttf
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \CormorantGaramond@scale ,
        Extension = .ttf }
  \def\cormorantgaramond@regular{Regular}
  \setmainfont
      [ Numbers = {\cormorantgaramond@figurealign,\cormorantgaramond@figurestyle},
        UprightFont    = *-\cormorantgaramond@regstyle ,
        ItalicFont     = *-\ifx\cormorantgaramond@regstyle\cormorantgaramond@regular Italic\else\cormorantgaramond@regstyle Italic\fi ,
        BoldFont    = *-\cormorantgaramond@boldstyle ,
        BoldItalicFont     = *-\cormorantgaramond@boldstyle Italic ,
      ]
      {CormorantGaramond}
  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}
  \providecommand\infigures{\addfontfeatures{VerticalPosition=ScientificInferior}}
  \DeclareTextFontCommand{\oldstylenums}{\addfontfeatures{Numbers=OldStyle}}
  \DeclareTextFontCommand{\liningnums}{\addfontfeatures{Numbers=Lining}}
  \DeclareTextFontCommand{\tabularnums}{\addfontfeatures{Numbers=Tabular}}
  \DeclareTextFontCommand{\proportionalnums}{\addfontfeatures{Numbers=Lining}} % pnum not supported

\else % type1

  \def\cormorantgaramond@family{CormorantGaramond-\cormorantgaramond@figurealign\cormorantgaramond@figurestyle}
  \renewcommand*\rmdefault{\cormorantgaramond@family}
  \edef\seriesdefault{\mdseries@rm}

  \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
  \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
  \def\sufigures{\@nomath\sufigures\fontfigurestyle{superior}\selectfont}

  \fa@naming@exception{figures}{{inferior}{proportional}}{Inf}
  \fa@naming@exception{figures}{{inferior}{tabular}}{Inf}
  \def\infigures{\@nomath\infigures\fontfigurestyle{inferior}\selectfont}

  \DeclareTextFontCommand{\oldstylenums}{\fontfamily{CormorantGaramond-\cormorantgaramond@figurealign OsF}\selectfont}
  \DeclareTextFontCommand{\liningnums}{\fontfamily{CormorantGaramond-\cormorantgaramond@figurealign LF}\selectfont}
  \DeclareTextFontCommand{\tabularnums}{\fontfamily{CormorantGaramond-T\cormorantgaramond@figurestyle}\selectfont}
  \DeclareTextFontCommand{\proportionalnums}{\fontfamily{CormorantGaramond-\cormorantgaramond@figurestyle}\selectfont}

\fi

\DeclareTextFontCommand{\textsu}{\sufigures}
\DeclareTextFontCommand{\textinf}{\infigures}

\ifcormorantgaramond@ttf
  \defaultfontfeatures{}
\fi

\endinput