summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/gregoriotex/gregoriotex.sty
blob: 6f8eff2456a246874553646391ccb5156bce635f (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
218
219
220
221
222
223
224
%GregorioTeX LaTeX style.
%
% Copyright (C) 2007-2021 The Gregorio Project (see CONTRIBUTORS.md)
%
% This file is part of Gregorio.
%
% Gregorio is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Gregorio is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Gregorio.  If not, see <http://www.gnu.org/licenses/>.

\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{gregoriotex}%
		[2021/02/23 v6.0.0-beta1 GregorioTeX system.]% PARSE_VERSION_DATE_LTX

\RequirePackage{iftex}%
\RequireLuaTeX

% If gregoriosyms has been loaded then there are going to be some conflicts in the definitions made in that package and this one.  In order to provide for a more informative error message, we check for that conflict right away
\ifcsname gregoriotex@symbols@loaded\endcsname\gre@error{Loading gregoriotex after\MessageBreak gregoriosyms is not supported.  Please remove the\MessageBreak loading of gregoriosyms (its contents are loaded\MessageBreak by gregoriotex)}\fi%

\RequirePackage{xcolor}%
\RequirePackage{luacolor}%
\RequirePackage{kvoptions}%
\RequirePackage{graphicx}% for \resizebox
\RequirePackage{luatexbase}%
\RequirePackage{luaotfload}%
\RequirePackage{luamplib}%
\RequirePackage{xstring}%

\def\gre@error#1{\PackageError{GregorioTeX}{#1}{}}%
\def\gre@warning#1{\PackageWarning{GregorioTeX}{#1}}%
\def\gre@bug#1{\PackageError{GregorioTeX}{#1 !! This is a bug in Gregorio.  Please report it at https://github.com/gregorio-project/gregorio/issues}{}}%
\def\gre@typeout{\typeout}
\long\def\gre@metapost#1{{%
	\gre@localleftbox{}%
	\gre@localrightbox{}%
	\begin{mplibcode}
	#1
	\end{mplibcode}%
}}%

\SetupKeyvalOptions{prefix=gre@}
\DeclareStringOption{debug}[all]

% This option allows the user to transform all deprecation messages
% into errors.  Allowing one to determine if the TeX file is compliant
% with future versions of gregoriotex. To enable, use gregoriotex with
% this option: allowdeprecated=false
\DeclareBoolOption[true]{allowdeprecated}

% Define these at first to do nothing because they need to manipulate
% flags which are declared in the package.
\DeclareVoidOption{nevercompile}{}
\DeclareVoidOption{forcecompile}{}
\DeclareVoidOption{autocompile}{}

\ProcessKeyvalOptions*

\let\gre@strip@pt\strip@pt

\long\def\gre@iflatex#1{#1}
\long\def\gre@ifnotlatex#1{}
\input gregoriotex-main.tex

% Now redefine these after loading the package because the options
% manipulate flags which are declared in the package.
\let\gre@nevercompile\undefined
\let\gre@forcecompile\undefined
\let\gre@autocompile\undefined

% These options control the global behavior of \includescore.  The default, forceinclude, is the old behavior (no attempt to compile the score with gregorio is made, it is simply included as is).  forcecompile is at the opposite end of the spectrum: all scores are compiled through gregorio at time of inclusion.  autocompile strikes a balance by checking to see if the score needs to be recompiled and only doing so if it needs it (see the definition of \includescore in gregoriotex.tex for more details).
\DeclareVoidOption{nevercompile}{\gresetcompilegabc{never}}
\DeclareVoidOption{forcecompile}{\gresetcompilegabc{force}}
\DeclareVoidOption{autocompile}{\gresetcompilegabc{auto}}

\ExecuteOptions{autocompile}

\ProcessKeyvalOptions*

% we need to do this again because we processed the keyval options again
\gre@fixdebug%

% we hide lines only under LaTeX
\gresetlinesbehindalteration{invisible}
\gresetlinesbehindpunctumcavum{invisible}

%%%%%%%%%
%% Color definitions
%%%%%%%%%

\definecolor{grebackgroundcolor}{RGB}{255,255,255}%
\definecolor{gregoriocolor}{RGB}{229,53,44}%

%%%%%%%%%
%% LaTeX specific definitions for fonts
%%%%%%%%%

\def\GreItalic#1{%
	{\itshape #1}%
	\relax %
}

\def\GreSmallCaps#1{%
	{\scshape #1}%
	\relax %
}

\def\GreBold#1{%
	{\bfseries #1}%
	\relax %
}

\def\GreTypewriter#1{%
	{\ttfamily #1}%
	\relax %
}

\def\GreUnderline#1{%
	\underline{#1}%
	\relax %
}

\def\GreColored#1{%
	{%
		\color{gregoriocolor}#1%
	}%
}


\def\gresetlinecolor#1{%
	\gre@changestyle{normalstafflines}{\color[named]{#1}}[\relax]%
}


%%%%%%%%%%%%%%%%%%%%
%% Formatting environments
%%%%%%%%%%%%%%%%%%%%

\newenvironment{gre@style@initial}%
	{\begingroup\fontsize{40}{40}\selectfont}%
	{\endgroup}%

\newenvironment{gre@style@translation}%
	{\begingroup\itshape}%
	{\endgroup}%

\newenvironment{gre@style@abovelinestext}%
	{\begingroup\small\itshape}%
	{\endgroup}%

\newenvironment{gre@style@normalstafflines}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@additionalstafflines}%
	{\begingroup\begin{gre@style@normalstafflines}}%
	{\end{gre@style@normalstafflines}\endgroup}%

\newenvironment{gre@style@lowchoralsign}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@highchoralsign}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@firstsyllableinitial}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@firstsyllable}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@firstword}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@modeline}%
	{\begingroup\begin{scshape}\begin{bfseries}}%
	{\end{bfseries}\end{scshape}\endgroup}%

\newenvironment{gre@style@modemodifier}%
	{\begingroup\begin{bfseries}\itshape\@@italiccorr}%
	{\@@italiccorr\end{bfseries}\endgroup}%

\newenvironment{gre@style@modedifferentia}%
	{\begingroup\begin{bfseries}}%
	{\end{bfseries}\endgroup}%

\newenvironment{gre@style@annotation}%
	{\begingroup}%
	{\endgroup}%

\newenvironment{gre@style@commentary}%
	{\begingroup\footnotesize\itshape}%
	{\endgroup}%

\newenvironment{gre@style@elision}%
	{\begingroup\small\itshape\@@italiccorr}%
	{\@@italiccorr\endgroup}%

\newenvironment{gre@style@nabc}%
	{\begingroup\color{gregoriocolor}}%
	{\endgroup}%

\def\gre@changestyle#1#2[#3]{%
	\renewenvironment{gre@style@#1}{\begingroup#2}{#3\endgroup}%
}%

%%%%%%%%%%%%%%%
%% Default Mode Numbering style
%%%%%%%%%%%%%%%

\gresetmodenumbersystem{roman-minuscule}%