summaryrefslogtreecommitdiff
path: root/fonts/spectral/latex/spectral.sty
blob: 8b4e28378e5591a3cb968f1ac7a9a3189a6eeb8a (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{spectral}
    [2021/01/01 (Bob Tennent and autoinst)  Style file for Spectral fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifspectral@ttf 
\ifxetex
  \spectral@ttftrue
\else\ifluatex
  \spectral@ttftrue
\else  % [pdf]LaTeX
  \spectral@ttffalse
\fi\fi

\newif\ifspectral@lining \spectral@liningfalse
\newif\ifspectral@tabular \spectral@tabularfalse
\newif\ifspectral@extralight \spectral@extralightfalse
\newif\ifspectral@light \spectral@lightfalse
\newif\ifspectral@medium \spectral@mediumfalse
\newif\ifspectral@semibold \spectral@semiboldfalse
\newif\ifspectral@extrabold \spectral@extraboldfalse

\newcommand*{\Spectral@scale}{1}
\newcommand*{\SpectralInitials@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\Spectral@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\Spectral@scale}{#1}}
\DeclareOptionX{type1}{\spectral@ttffalse}
\DeclareOptionX{lining}{\spectral@liningtrue}
\DeclareOptionX{lf}{\spectral@liningtrue}
\DeclareOptionX{oldstyle}{\spectral@liningfalse}
\DeclareOptionX{osf}{\spectral@liningfalse}
\DeclareOptionX{tabular}{\spectral@tabulartrue}
\DeclareOptionX{t}{\spectral@tabulartrue}
\DeclareOptionX{proportional}{\spectral@tabularfalse}
\DeclareOptionX{p}{\spectral@tabularfalse}
\DeclareOptionX{medium}{\spectral@mediumtrue}
\DeclareOptionX{m}{\spectral@mediumtrue}
\DeclareOptionX{light}{\spectral@lighttrue}
\DeclareOptionX{l}{\spectral@lighttrue}
\DeclareOptionX{el}{\spectral@extralighttrue}
\DeclareOptionX{extralight}{\spectral@extralighttrue}
\DeclareOptionX{semibold}{\spectral@semiboldtrue}
\DeclareOptionX{sb}{\spectral@semiboldtrue}
\DeclareOptionX{extrabold}{\spectral@extraboldtrue}
\DeclareOptionX{eb}{\spectral@extraboldtrue}


\ExecuteOptionsX{oldstyle,proportional}
\ProcessOptionsX\relax

\ifspectral@ttf
  \ifspectral@lining
    \def\spectral@figurestyle{Lining}
  \else
    \def\spectral@figurestyle{OldStyle} 
  \fi
  \ifspectral@tabular
    \def\spectral@figurealign{Monospaced} 
  \else
    \def\spectral@figurealign{Proportional} 
  \fi
  \ifspectral@medium
    \def\spectral@regularstyle{Medium}
  \else\ifspectral@light
    \def\spectral@regularstyle{Light}
  \else\ifspectral@extralight
    \def\spectral@regularstyle{ExtraLight}
  \else
    \def\spectral@regularstyle{Regular}
  \fi\fi\fi
  \ifspectral@semibold
    \def\spectral@boldstyle{SemiBold}
  \else\ifspectral@extrabold
    \def\spectral@boldstyle{ExtraBold}
  \else
    \def\spectral@boldstyle{Bold}
  \fi\fi
    
\else % type1
  \ifspectral@lining
    \def\spectral@figurestyle{LF}
  \else
    \def\spectral@figurestyle{OsF}
  \fi
  \ifspectral@tabular
    \def\spectral@figurealign{T}
  \else
    \def\spectral@figurealign{}
  \fi
  \ifspectral@medium
    \def\mdseries@rm{medium}
  \else\ifspectral@light
    \def\mdseries@rm{l}
  \else\ifspectral@extralight
    \def\mdseries@rm{el}
  \else
    \def\mdseries@rm{m}
  \fi\fi\fi
  \def\seriesdefault{\mdseries@rm}
  \ifspectral@semibold
    \def\bfseries@rm{sb}
  \else\ifspectral@extrabold
    \def\bfseries@rm{eb}
  \else
    \def\bfseries@rm{b}
  \fi\fi

\fi

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

\ifspectral@ttf
  \ifxetex\XeTeXtracingfonts=1\fi
  \def\spectral@regular{Regular}

  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Spectral@scale ,
        SmallCapsFeatures={\ifluatex Renderer=Basic\fi},
        Extension = .ttf }
  \setmainfont
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-\spectral@regularstyle ,
        ItalicFont     = *-\ifx\spectral@regularstyle\spectral@regular Italic\else\spectral@regularstyle Italic\fi,
        BoldFont    = *-\spectral@boldstyle ,
        BoldItalicFont     = *-\spectral@boldstyle Italic ,
      ]
      {Spectral}
  \newfontfamily\spectralextralight
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-ExtraLight ,
        ItalicFont     = *-ExtraLightItalic ,
        BoldFont    = *-\spectral@boldstyle ,
        BoldItalicFont     = *-\spectral@boldstyle Italic ,
      ]
      {Spectral}
  \newfontfamily\spectrallight
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-Light ,
        ItalicFont     = *-LightItalic ,
        BoldFont    = *-\spectral@boldstyle ,
        BoldItalicFont     = *-\spectral@boldstyle Italic ,
      ]
      {Spectral}
  \newfontfamily\spectralmedium
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-Medium ,
        ItalicFont     = *-MediumItalic ,
        BoldFont    = *-\spectral@boldstyle ,
        BoldItalicFont     = *-\spectral@boldstyle Italic ,
      ]
      {Spectral}
  \newfontfamily\spectralsemibold
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-SemiBold ,
        ItalicFont     = *-SemiBoldItalic ,
      ]
      {Spectral}
  \newfontfamily\spectralextrabold
      [ Numbers = {\spectral@figurealign,\spectral@figurestyle},
        UprightFont    = *-ExtraBold ,
        ItalicFont     = *-ExtraBoldItalic ,
      ]
      {Spectral}
  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}
  \DeclareTextFontCommand{\oldstylenums}{\addfontfeatures{Numbers=OldStyle}}
  \DeclareTextFontCommand{\liningnums}{\addfontfeatures{Numbers=Lining}}

\else % type1

  \def\spectral@family{Spectral-\spectral@figurealign\spectral@figurestyle}
  \renewcommand*\rmdefault{\spectral@family}

  \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
  \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
  \def\sufigures{\@nomath\sufigures\fontfigurestyle{superior}\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\spectralextralight{\fontfamily{\spectral@family}\fontseries{el}\selectfont}
  \def\spectrallight{\fontfamily{\spectral@family}\fontseries{l}\selectfont}
  \def\spectralmedium{\fontfamily{\spectral@family}\fontseries{medium}\selectfont}
  \def\spectralsemibold{\fontfamily{\spectral@family}\fontseries{sb}\selectfont}
  \def\spectralextrabold{\fontfamily{\spectral@family}\fontseries{eb}\selectfont}

  \DeclareTextFontCommand{\oldstylenums}{\fontfamily{Spectral-\spectral@figurealign OsF}\selectfont}
  \DeclareTextFontCommand{\liningnums}{\fontfamily{Spectral-\spectral@figurealign LF}\selectfont}

\fi

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

\ifspectral@ttf
  \DeclareTextFontCommand{\tabularnums}{\addfontfeatures{Numbers=Tabular}}
  \DeclareTextFontCommand{\proportionalnums}{\addfontfeatures{Numbers=Proportional}}
\else % type1
  \DeclareTextFontCommand{\tabularnums}{\fontfamily{Spectral-T\spectral@figurestyle}\selectfont}
  \DeclareTextFontCommand{\proportionalnums}{\fontfamily{Spectral-\spectral@figurestyle}\selectfont}
\fi

\ifspectral@ttf
  \defaultfontfeatures{}
\fi

\endinput