summaryrefslogtreecommitdiff
path: root/fonts/ebgaramond/latex/ebgaramond.sty
blob: 351b1b90a7616e8f3c45cf2f691276033309b2fa (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ebgaramond}
    [2022/09/10 (Bob Tennent and autoinst)  Style file for EB Garamond fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifebgaramond@otf 
\ifxetex
  \ebgaramond@otftrue
\else\ifluatex
  \ebgaramond@otftrue
\else  % [pdf]LaTeX
  \ebgaramond@otffalse
\fi\fi

\newif\ifebgaramond@lining \ebgaramond@liningfalse
\newif\ifebgaramond@tabular \ebgaramond@tabularfalse
\newif\ifebgaramond@medium \ebgaramond@mediumfalse
\newif\ifebgaramond@semibold \ebgaramond@semiboldfalse
\newif\ifebgaramond@extrabold \ebgaramond@extraboldfalse

\newcommand*{\EBGaramond@scale}{1}
\newcommand*{\EBGaramondInitials@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\EBGaramond@scale}{#1}\renewcommand*{\EBGaramondInitials@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\EBGaramond@scale}{#1}\renewcommand*{\EBGaramondInitials@scale}{#1}}
\DeclareOptionX{type1}{\ebgaramond@otffalse}
\DeclareOptionX{lining}{\ebgaramond@liningtrue}
\DeclareOptionX{nf}{\ebgaramond@liningtrue}
\DeclareOptionX{lf}{\ebgaramond@liningtrue}
\DeclareOptionX{oldstyle}{\ebgaramond@liningfalse}
\DeclareOptionX{osf}{\ebgaramond@liningfalse}
\DeclareOptionX{tabular}{\ebgaramond@tabulartrue}
\DeclareOptionX{t}{\ebgaramond@tabulartrue}
\DeclareOptionX{proportional}{\ebgaramond@tabularfalse}
\DeclareOptionX{p}{\ebgaramond@tabularfalse}
\DeclareOptionX{medium}{\ebgaramond@mediumtrue}
\DeclareOptionX{m}{\ebgaramond@mediumtrue}
\DeclareOptionX{semibold}{\ebgaramond@semiboldtrue}
\DeclareOptionX{sb}{\ebgaramond@semiboldtrue}
\DeclareOptionX{extrabold}{\ebgaramond@extraboldtrue}
\DeclareOptionX{eb}{\ebgaramond@extraboldtrue}


\ExecuteOptionsX{oldstyle,proportional}
\ProcessOptionsX\relax

\ifebgaramond@otf
  \ifebgaramond@lining
    \def\ebgaramond@figurestyle{Lining}
  \else
    \def\ebgaramond@figurestyle{OldStyle} 
  \fi
  \ifebgaramond@tabular
    \def\ebgaramond@figurealign{Monospaced} 
  \else
    \def\ebgaramond@figurealign{Proportional} 
  \fi
  \ifebgaramond@medium
    \def\ebgaramond@regularstyle{Medium}
  \else
    \def\ebgaramond@regularstyle{Regular}
  \fi
  \ifebgaramond@semibold
    \def\ebgaramond@boldstyle{SemiBold}
  \else\ifebgaramond@extrabold
    \def\ebgaramond@boldstyle{ExtraBold}
  \else
    \def\ebgaramond@boldstyle{Bold}
  \fi\fi
    
\else % type1
  \ifebgaramond@lining
    \def\ebgaramond@figurestyle{LF}
  \else
    \def\ebgaramond@figurestyle{OsF}
  \fi
  \ifebgaramond@tabular
    \def\ebgaramond@figurealign{T}
  \else
    \def\ebgaramond@figurealign{}
  \fi
  \ifebgaramond@medium
    \def\mdseries@rm{medium}
  \else
    \def\mdseries@rm{m}
  \fi
  \def\seriesdefault{\mdseries@rm}
  \ifebgaramond@semibold
    \def\bfseries@rm{sb}
  \else\ifebgaramond@extrabold
    \def\bfseries@rm{eb}
  \else
    \def\bfseries@rm{b}
  \fi\fi

\fi

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

\ifebgaramond@otf
  \def\ebgaramond@regular{Regular}

  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \EBGaramond@scale ,
        SmallCapsFeatures={\ifluatex Renderer=Basic\fi},
        Extension = .otf }
  \setmainfont
      [ Numbers = {\ebgaramond@figurealign,\ebgaramond@figurestyle},
        UprightFont    = *-\ebgaramond@regularstyle ,
        ItalicFont     = *-\ifx\ebgaramond@regularstyle\ebgaramond@regular Italic\else\ebgaramond@regularstyle Italic\fi,
        BoldFont    = *-\ebgaramond@boldstyle ,
        BoldItalicFont     = *-\ebgaramond@boldstyle Italic ,
        FontFace={m}{sw}{Font=*-\ifx\ebgaramond@regularstyle\ebgaramond@regular Italic\else\ebgaramond@regularstyle Italic\fi,Style=Swash},
        FontFace={b}{sw}{Font=*-\ebgaramond@boldstyle Italic,Style=Swash},
      ]
      {EBGaramond}
  \newfontfamily\ebgaramond
      [ Numbers = {\ebgaramond@figurealign,\ebgaramond@figurestyle},
        UprightFont    = *-\ebgaramond@regularstyle ,
        ItalicFont     = *-\ifx\ebgaramond@regularstyle\ebgaramond@regular Italic\else\ebgaramond@regularstyle Italic\fi ,
        BoldFont    = *-\ebgaramond@boldstyle ,
        BoldItalicFont     = *-\ebgaramond@boldstyle Italic ,
      ]
      {EBGaramond}
  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}
  \providecommand\infigures{\addfontfeatures{VerticalPosition=ScientificInferior}}
  \newfontface\initials{EBGaramond-Initials}
  \DeclareTextFontCommand{\oldstylenums}{\addfontfeatures{Numbers=OldStyle}}
  \DeclareTextFontCommand{\liningnums}{\addfontfeatures{Numbers=Lining}}
  \DeclareTextFontCommand{\textin}{\initials}

\else % type1

  \def\ebgaramond@family{EBGaramond-\ebgaramond@figurealign\ebgaramond@figurestyle}
  \renewcommand*\rmdefault{\ebgaramond@family}
  \newcommand*\ebgaramond{\fontfamily{\ebgaramond@family}\selectfont}

  \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}

  \ifx\swshape\@undefined
    \DeclareRobustCommand\swshape{\not@math@alphabet\swshape\relax
        \fontprimaryshape\itdefault\fontsecondaryshape\swdefault\selectfont}
     \fa@naming@exception{shape}{{n}{sw}}{nw}
    \fa@naming@exception{shape}{{it}{sw}}{sw}
  \fi


  \def\initials{\fontfamily{EBGaramondInitials-TLF}\fontseries{m}\selectfont}
  \DeclareTextFontCommand{\oldstylenums}{\fontfamily{EBGaramond-\ebgaramond@figurealign OsF}\selectfont}
  \DeclareTextFontCommand{\liningnums}{\fontfamily{EBGaramond-\ebgaramond@figurealign LF}\selectfont}
  \DeclareTextFontCommand{\textin}{\initials}

\fi

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

\ifebgaramond@otf
  \DeclareTextFontCommand{\tabularnums}{\addfontfeatures{Numbers=Tabular}}
  \DeclareTextFontCommand{\proportionalnums}{\addfontfeatures{Numbers=Proportional}}
\else % type1
  \DeclareTextFontCommand{\tabularnums}{\fontfamily{EBGaramond-T\ebgaramond@figurestyle}\selectfont}
  \DeclareTextFontCommand{\proportionalnums}{\fontfamily{EBGaramond-\ebgaramond@figurestyle}\selectfont}
\fi

\ifebgaramond@lining
  \def\ebgaramondlgr@figurestyle{LF}
\else
  \def\ebgaramondlgr@figurestyle{OsF}
\fi
\ifebgaramond@tabular
  \def\ebgaramondlgr@figurealign{T}
\else
  \def\ebgaramondlgr@figurealign{}
\fi
\def\ebgaramondlgr{\fontencoding{LGR}\fontfamily{EBGaramond-\ebgaramondlgr@figurealign\ebgaramondlgr@figurestyle}\selectfont}

\ifebgaramond@otf
  \defaultfontfeatures{}
\fi

\endinput