summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/novel/novel-FontDefaults.sty
blob: 28d948e9dd73a2de59bb814638c77facbb5f4def (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
%%
%% This is file `novel-FontDefaults.sty', part of class `novel'.
%% Copyright 2017 Robert Allgeyer.
%%
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%%
\ProvidesFile{novel-FontDefaults.sty}%
[2017/11/17 v1.46 LaTeX file (default fonts)]
%%


%%
%% This file is loaded \AtEndPreamble.
%%

%%%%%

%% Most TeX installations will use Latin Modern or Computer Modern
%%   as default fonts. These are unsuitable for commercial fiction.
%% But `novel' class uses Libertinus as defaults.
%% Change them using \SetParentFont and other fontspec commands, in Preamble.
% Libertinus Serif has Regular, Italic, Bold, Bold Italic.
%   But here, Semibold over-rides Bold.
%
%% Now to activate the font definitions:
%% The parent font, ancestor of the main font, and some others:
\if@parentfontset\else % fixed in v. 1.43.1
  \ifthenelse{\equal{\rmdefault}{lmr}}{%
    % At this point, if \rmdefault is lmr, it means that the user did not choose
    %   a different font. Then, Libertinus Serif or Latin Modern Roman
    %   will be automatically set as \rmdefault:
    \IfFontExistsTF{Libertinus Serif}{ % preferred default
      \SetParentFont[%
        BoldFont=libertinusserif-semibold.otf,%
        BoldItalicFont=libertinusserif-semibolditalic.otf,%
      ]{Libertinus Serif}
    }{ % backup default:
      \SetParentFont[%
        SmallCapsFont={Latin Modern Roman Caps}%
        ]{Latin Modern Roman}% only because it comes with LaTeX
      \let\scshape\oldscshape % or small caps won't work
      \let\smcp\oldscshape % ditto
    }%
  }{% However, if \rmdefault is not lmr, it means that the user chose the font.
    % If the choice was made via \SetParentFont, no problem. But if done by
    %   incorrect method such as \setmainfont, \renewcommand\rmdefault,
    %   or \usepackage{fontname}, then an error is thrown (warning prior to v 1.44):
    \if@parentfontset\else
      \ClassError{novel}{Wrong command used to set main font}%
      {You attempted to define the main document font using a command such as^^J%
      \string\renewcommand\string\rmdefault\space or \string\usepackage^^J%
      or \string\setmainfont. These are incorrect in `novel' class.^^J%
      Use \string\SetParentFont\space instead. See `novel' documentation.^^J}%
    \fi
  }%
\fi
% Now we are ready to set the main font:
\setmainfont[\parentfontfeatures]{\parentfontname}
\let\mainfont\rmfamily\relax % compatibility
%%

% The mono font:
\ifthenelse{\equal{\ttdefault}{lmtt}}{% over-ride:
  \IfFontExistsTF{Libertinus Mono}{
    \setmonofont[%
      ItalicFont={},% Doesn't have these.
      BoldFont={},%
      BoldItalicFont={},%
    ]{Libertinus Mono}
  }{
    \setmonofont{Latin Modern Mono}% Eeek! Only because you have it!
  }
}{} % User \setmonofont, so leave alone.
%%
% The sans font:
\ifthenelse{\equal{\sfdefault}{lmss}}{ % override:
  \IfFontExistsTF{Libertinus Sans}{
    \setsansfont{Libertinus Sans}
  }{
    \setsansfont{Latin Modern Sans}% Eeek! Only because you have it!
  }
}{} % User \setsansfont, so leave alone.
%%

%%
% New in version 1.38, \straightquote and \straightdblquote:
\gdef\straightquote{{\addfontfeature{Ligatures=ResetAll}'}}
\gdef\straightdblquote{{\addfontfeature{Ligatures=ResetAll}"}}
%%

%% The novel-specific fonts:
\if@chapterfontset\else
  \SetChapterFont[\parentfontfeatures,Scale=1.6]{\parentfontname}
\fi
\newfontfamily\chapterfont[\@chapterfontfeatures]{\@chapterfontname}
%%
\if@subchfontset\else
  \SetSubchFont[\parentfontfeatures,Scale=1.2]{\parentfontname}
\fi
\newfontfamily\subchfont[\@subchfontfeatures]{\@subchfontname}
%%
\newif \if@headfontdefault
\if@headfontset\else
  \SetHeadFont[Letters=SmallCaps,\parentfontfeatures,Scale=0.92]{\parentfontname}
  \global\@headfontdefaulttrue
\fi
\newfontfamily\headfont[\@headfontfeatures]{\@headfontname}
%%
%% The decofont must be NovelDeco.otf or a user modification of that font:
\if@decofontset\else
  \IfFontExistsTF{NovelDeco.otf}{
    \SetDecoFont{NovelDeco}
  }{}
\fi
%%
\gdef\acronym#1{#1}% Re-defined below, if decofont available.
%%
%% Now to get the decofont activated:
% Decorative glyphs, only in this font. Should not be re-set by user:
\gdef\decoglyph#1{~}% If NovelDeco not found, nonbreaking space in main text.
%
\if@gotdeco % NovelDeco or a user-defined alternative was found:
  \newfontface\@decoglyph[%
    \@decofontfeatures,%
  ]{\@decofontname}
  \newfontface\@decoglypha[%
    \@decofontfeatures,RawFeature=+ss01,%
  ]{\@decofontname}
  \newfontface\@decoglyphb[%
    \@decofontfeatures,RawFeature=+ss02,%
  ]{\@decofontname}
  \newfontface\@decoglyphc[%
    \@decofontfeatures,RawFeature=+ss03,%
  ]{\@decofontname}
  %
  \gdef\decoglyph#1{% Be sure to use % without preceding space:
    \IfBeginWith{#1}{n}{% normal weight symbol (same as regular)
     \StrBehind{#1}{n}[\@tempdecoglyph]{\@decoglyph\symbol{\@tempdecoglyph}}%
    }{}%
    \IfBeginWith{#1}{r}{% regular weight symbol
     \StrBehind{#1}{r}[\@tempdecoglyph]{\@decoglyph\symbol{\@tempdecoglyph}}%
    }{}%
    \IfBeginWith{#1}{l}{% light weight symbol
    \StrBehind{#1}{l}[\@tempdecoglyph]{\@decoglypha\symbol{\@tempdecoglyph}}%
    }{}%
    \IfBeginWith{#1}{e}{% extra light weight symbol
    \StrBehind{#1}{e}[\@tempdecoglyph]{\@decoglyphb\symbol{\@tempdecoglyph}}%
    }{}%
    \IfBeginWith{#1}{t}{% thin weight symbol
    \StrBehind{#1}{t}[\@tempdecoglyph]{\@decoglyphc\symbol{\@tempdecoglyph}}%
    }{}%
  }% end gdef decoglyph
  %
  % The trouble with acronyms is that they look too big in regular capitals,
  % and too small in small caps. Command \acronym{} tries to provide an
  % intermediate size. The letters were drawn from Linux Libertine, scaled,
  % weights adjusted, the placed in NovelDeco.otf.
  \gdef\acronym#1{{\decofont{#1}}}
  %
\fi% end \if@gotdeco
%
% Math font is not needed, because `novel' does not typeset math.
% If you have the Libertinus fonts installed, might as will specify for math.
% Then Latin Modern Math if installed.
% If not, NovelDeco.otf "fakes" math capability, just to fool the fontloader:
\IfFontExistsTF{Libertinus Math}{
  \setmathfont[BoldFont={libertinusmath-regular.otf}]{libertinusmath-regular.otf}
}{
  \IfFontExistsTF{Latin Modern Math}{}{% already set as default by unicode-math.
  }{
    \setmathfont[BoldFont={NovelDeco.otf}]{NovelDeco.otf}
  }
}%
%%


%
%% This provides default microtype settings, allows the user to over-ride,
%    and hopefully prevents the user from choosing inappropriate settings:
\let\microtypesetup\relax % fake command no longer needed
\if@setmicrotype % user wrote \microtypesetup{} in Preamble
  \IfSubStr{\@mymicrotypesetup}{config}{% user specified own config file
    \gdef\@mymicrotypeset{\@mymicrotypesetup}
  }{ % default to novel's config file
    \gdef\@mymicrotypeset{%
      config=novel-microtype,final,\@mymicrotypesetup}
  }
\else % user did not write \microtypesetup{} in Preamble
  \gdef\@mymicrotypeset{%
    config=novel-microtype,final,stretch=20,shrink=20}
\fi
\if@mtoff\else
  \RequirePackage[\@mymicrotypeset]{microtype}
\fi
%
%%



%
%% End of file `novel-FontDefaults.sty'