summaryrefslogtreecommitdiff
path: root/fonts/erewhon/tex/erewhon.sty
blob: 384bfe73dea1204117bbf3201a1ee858a70b7e8f (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
%% erewhon.sty
%%
\NeedsTeXFormat{LaTeX2e}
\def\fileversion{1.119}
\def\filedate{2022/01/31}
\ProvidesPackage{erewhon}
    [\filedate\space v\fileversion]
    
\message{`erewhon' v\fileversion, \filedate\space  Style file for erewhon (m_sharpe), based on Heuristica (a_panov) and, ultimately,  Utopia.}

%\RequirePackage[T2A,T2B,T2C,LY1,T1]{fontenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{scalefnt} % only for \textruble
\DeclareEncodingSubset{TS1}{erewhon-*}{0}
\RequirePackage{xstring,ifthen} % for \textfrac
\IfFileExists{mweights.sty}{\RequirePackage{mweights}}{}
\RequirePackage{etoolbox}
\IfFileExists{fontaxes.sty}{
    \RequirePackage{fontaxes}
    \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
    \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
    \def\sufigures{\@nomath\sufigures%
        \fontfigurestyle{superior}\selectfont}
    \DeclareTextFontCommand{\textsu}{\sufigures}
    \let\textsuperior\textsu

    \fa@naming@exception{figures}{{inferior}{proportional}}{Inf}
    \fa@naming@exception{figures}{{inferior}{tabular}}{Inf}
    \def\infigures{\@nomath\infigures%
        \fontfigurestyle{inferior}\selectfont}
    \DeclareTextFontCommand{\textin}{\infigures}
    \let\textinferior\textin
    \fa@naming@exception{figures}{{numerators}{proportional}}{Numr}
    \fa@naming@exception{figures}{{numerators}{tabular}}{Numr}
    \def\nufigures{\@nomath\nufigures%
        \fontfigurestyle{numerators}\selectfont}
    \DeclareTextFontCommand{\textnu}{\nufigures}
    \let\textnumerator\textnu
    \let\nustyle\nufigures

    \fa@naming@exception{figures}{{denominators}{proportional}}{Dnom}
    \fa@naming@exception{figures}{{denominators}{tabular}}{Dnom}
    \def\defigures{\@nomath\defigures%
        \fontfigurestyle{denominators}\selectfont}
    \DeclareTextFontCommand{\textde}{\defigures}
    \let\textdenominator\textde
    \let\destyle\defigures
}{}
%\providecommand*{\textfrac}[2]{%
%    \textnu{#1}\kern0em{\fontencoding{TS1}\selectfont\char"2F}\kern0em\textde{#2}} %\textfractionsolidus does not work here
\newcommand{\textfrac}[3][]{% like \textfrac[1]{7}{8}
  \mbox{%
    \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1]
      {\textlf{#1}\kern.05em}{}%         
    \textnu{#2}% numerator
    \StrRight{#2}{1}[\@digit@]%
    % look for  1, 2, 3, 4, 7
    \ifcase\@digit@% 0
    \or% 1
    \or\kern.02em% 2
    \or%\kern-.01em% 3
    \or%\kern-.01em% 4
    \or%\kern.01em% 5
    \or\kern.01em% 6
    \or\kern-.08em% 7
    \fi%
    \kern\Erewhon@foresolidus{\fontencoding{TS1}\selectfont\char"2F}%
    \kern\Erewhon@aftsolidus%
    \StrLeft{#3}{1}[\@digit@]%
    % look for 1, 4, 5, 7
    \ifcase\@digit@% 0
    \or%\kern -.02em% 1
    \or% 2
    \or% 3
    \or\kern -.03em% 4
    \or% 5
    \or% 6
    \or\kern .02em% 7
    \fi%
    \textde{#3}%       denominator [#3]
  }%
}

\def\erewhon@spc{.211em}
\def\erewhon@stretch{.1055em}
\def\erewhon@shrink{.0703em}
\def\erewhon@spcf{} % a factor to multiply \fontdimen2
\def\Erewhon@foresolidus{0em}
\def\Erewhon@aftsolidus{0em}

\newcommand*{\erewhon@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scale}{\renewcommand*{\erewhon@scale}{#1}}
\DeclareOptionX{scaled}{\renewcommand*{\erewhon@scale}{#1}}
\DeclareOptionX{spacing}[.25em]{\gdef\erewhon@spc{#1}}
\DeclareOptionX{stretch}[.125em]{\gdef\erewhon@stretch{#1}}
\DeclareOptionX{shrink}[.1em]{\gdef\erewhon@shrink{#1}}
\DeclareOptionX{space}[1.23]{\gdef\erewhon@spcf{#1}}
\DeclareOptionX{foresolidus}{\gdef\Erewhon@foresolidus{#1}}
\DeclareOptionX{aftsolidus}{\gdef\Erewhon@aftsolidus{#1}}

\let\orig@footnote=\thefootnote
\let\orig@makefnmark=\@makefnmark
\def\bfseries@rm{b}
\def\mdseries@rm{m}

\newif\if@Erewhon@sups
\newif\if@Erewhon@scosf
\def\useosf{\edef\Erewhon@figurestyle{OsF}}
\@onlypreamble\useosf
\def\useproportional{\edef\Erewhon@figurealign{}}
\@onlypreamble\useproportional
%\newif\ifErewhon@babel
%\ifdefined\bbl@version \Erewhon@babeltrue\fi

\DeclareOptionX{lining}{\edef\Erewhon@figurestyle{LF}}
\DeclareOptionX{lf}{\edef\Erewhon@figurestyle{LF}}
\DeclareOptionX{oldstyle}{\useosf}
\DeclareOptionX{osf}{\useosf}
\DeclareOptionX{tabular}{\edef\Erewhon@figurealign{T}}
\DeclareOptionX{p}{\useproportional}
\DeclareOptionX{proportional}{\useproportional}
\DeclareOptionX{sups}{\@Erewhon@supstrue}
\DeclareOptionX{scosf}{\@Erewhon@scosftrue}
\DeclareOptionX{looser}{%
\gdef\erewhon@spc{.25em}\gdef\erewhon@stretch{.125em}\gdef\erewhon@shrink{.1em}}
\DeclareOptionX{loosest}{%
\gdef\erewhon@spc{.28em}\gdef\erewhon@stretch{.125em}\gdef\erewhon@shrink{.13em}}
\ExecuteOptionsX{lining,tabular}
\ProcessOptionsX\relax

\ifthenelse{\equal{\erewhon@spcf}{}}{%
\DeclareRobustCommand{\erewhon@sf}{%
	\fontdimen2\font=\erewhon@spc
	\fontdimen3\font=\erewhon@stretch
	\fontdimen4\font=\erewhon@shrink}}{%
\DeclareRobustCommand{\erewhon@sf}{%
    \fontdimen2\font=\erewhon@spcf\fontdimen2\font}}
    
\DeclareRobustCommand{\lfstyle}{%
  \not@math@alphabet\lfstyle\relax
  \fontfamily{erewhon-LF}\selectfont %
}% to get lf
\DeclareRobustCommand{\tlfstyle}{%
  \not@math@alphabet\tlfstyle\relax
  \fontfamily{erewhon-TLF}\selectfont %
}% to get tlf
\DeclareRobustCommand{\osfstyle}{%
  \not@math@alphabet\osfstyle\relax
  \fontfamily{erewhon-OsF}\selectfont %
}% to get osf
\DeclareRobustCommand{\tosfstyle}{%
  \not@math@alphabet\tosfstyle\relax
  \fontfamily{erewhon-TOsF}\selectfont %
}% to get tosf
\DeclareRobustCommand{\textlf}[1]{%
  {\lfstyle #1}%
}% to get lf
\DeclareRobustCommand{\texttlf}[1]{%
  {\tlfstyle #1}%
}% to get tlf
\DeclareRobustCommand{\textosf}[1]{%
  {\osfstyle #1}%
}% to get osf
\DeclareRobustCommand{\texttosf}[1]{%
  {\tosfstyle #1}%
}% to get tosf
\if@Erewhon@scosf %
\DeclareRobustCommand{\textsc}[1]{%
{\fontfamily{erewhon-\Erewhon@figurealign%
OsF}\fontshape{sc}\selectfont #1}%
}\fi% use OsF in small caps
\renewcommand*{\rmdefault}{erewhon-TLF} % always TLF in math
\renewcommand*{\familydefault}{\rmdefault}

\DeclareRobustCommand{\textruble}{\rlap{\kern.03em\rule[.258em]{.1em}{.032em}}\rlap{\kern.03em\rule[.173em]{.41em}{.032em}}{\scalefont{.966}P}}

\DeclareTextCommand{\textcircled}{TS1}[1]{\hmode@bgroup
   \ooalign{%
      \hfil \raise .37ex\hbox {\fontencoding{T1}\fontseries{m}\fontshape{sc}\fontsize{7.2}{7.2}\selectfont \lowercase{#1}}\hfil \crcr
     \char 79 %\textbigcircle 
   }%
 \egroup}

\if@Erewhon@sups %
 \ifdefined\sufigures
  \def\f@@tn@te{footnote}
  \def\@makefnmark{%
    \ifx\@mpfn\f@@tn@te%
      \ifx\thefootnote\orig@footnote%
        \hbox{\sufigures\hspace*{.04em}\@thefnmark\hspace*{.04em}}%
      \else%
        \orig@makefnmark%
      \fi
    \else%
      \orig@makefnmark%
    \fi}%
 \fi%
\fi
\ifx\pdfglyphtounicode\@undefined \else 
	\pdfglyphtounicode{afii61664}{200B}% .. .. 
\fi
%\ifErewhon@babel
%    \renewcommand*{\rmdefault}{erewhon-\Erewhon@figurealign%
%	\Erewhon@figurestyle}
%	\normalfont
%\else
	\AtEndPreamble{%
	\renewcommand*{\rmdefault}{erewhon-\Erewhon@figurealign%
	\Erewhon@figurestyle}
	\normalfont}
%\fi
\endinput