Debian Codegraph @

texk/gregorio/gregorio-src/tex/gregoriotex.tex

raw
1 % GregorioTeX boostrap file for Plain TeX
2 %
3 % Copyright (C) 2015-2025 The Gregorio Project (see CONTRIBUTORS.md)
4 %
5 % This file is part of Gregorio.
6 %
7 % Gregorio is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % Gregorio is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
19
20 % this file contains definitions for lines, initial, fonts, etc.
21
22
23 % This file needs to be marked with the version number. For now I've done this with the following comment, but we should check to see if PlainTeX has something similar to the version declaration of LaTeX and use that if it does.
24 % [2025/02/28 v6.1.0 GregorioTeX system.]% PARSE_VERSION_DATE_LTX
25
26 \input iftex.sty
27 \RequireLuaTeX%
28
29 \edef\greoldcatcode{\the\catcode`@}
30 \catcode`\@=11
31
32 \input luatexbase.sty%
33 \input luamplib.sty%
34 \input luaotfload.sty%
35 \input xstring.tex%
36 \input color.tex%
37 \input graphicx.tex % for \resizebox
38
39 \def\gre@error#1{\begingroup%
40 \def\MessageBreak{^^J}%
41 \let\protect\string%
42 \errmessage{GregorioTeX error: #1}%
43 \endgroup}%
44
45 \def\gre@warning#1{\begingroup%
46 \def\MessageBreak{^^J}%
47 \let\protect\string%
48 \message{GregorioTeX warning: #1}%
49 \endgroup}%
50
51 \def\gre@bug#1{\begingroup%
52 \def\MessageBreak{^^J}%
53 \let\protect\string%
54 \errmessage{GregorioTeX bug: #1 !! This is a bug in Gregorio. Please report it at https://github.com/gregorio-project/gregorio/issues}%
55 \endgroup}%
56
57 \def\gre@typeout#1{\begingroup%
58 \def\MessageBreak{^^J}%
59 \let\protect\string%
60 \message{#1}%
61 \endgroup}%
62
63 \ifcsname gre@debug\endcsname%
64 \else%
65 \def\gre@debug{}%
66 \fi%
67
68 \ifcsname f@size\endcsname%
69 \else%
70 \def\f@size{\directlua{gregoriotex.font_size()}}%
71 \fi%
72
73 \newif\ifgre@allowdeprecated%
74 \gre@allowdeprecatedtrue%
75
76 \long\def\gre@metapost#1{{%
77 \gre@localleftbox{}%
78 \gre@localrightbox{}%
79 \mplibcode
80 #1
81 \endmplibcode%
82 }}%
83
84 %% This is \strip@pt from LaTeX
85 \begingroup%
86 \catcode`P=12%
87 \catcode`T=12%
88 \lowercase{%
89 \def\x{\def\gre@rem@pt##1.##2PT{##1\ifnum##2>\z@.##2\fi}}}%
90 \expandafter\endgroup\x%
91 \def\gre@strip@pt{\expandafter\gre@rem@pt\the}%
92
93 \long\def\gre@iflatex#1{}%
94 \long\def\gre@ifnotlatex#1{#1}%
95 \input gregoriotex-main.tex
96
97
98 %%%%%%%%%
99 %% Color definitions
100 %%%%%%%%%
101
102 \definecolor{grebackgroundcolor}{RGB}{255,255,255}%
103 \definecolor{gregoriocolor}{RGB}{229,53,44}%
104
105 %%%%%%%%%
106 %% PlainTeX specific definitions for fonts
107 %%%%%%%%%
108
109 \def\GreBold#1{%
110 {\bf #1}%
111 \relax %
112 }%
113
114 \def\GreItalic#1{%
115 {\it #1}%
116 %\relax
117 }%
118
119 % Since small caps in PlainTeX requires loading another font, it is not defined by default. This command maintains compatibility by checking to see if \sc has been defined and raising a warning when it hasn’t
120 \def\GreSmallCaps#1{%
121 \ifdefined\sc%
122 {\sc #1}%
123 \else%
124 \gre@warning{Small caps (\protect\sc) is not defined}%
125 {#1}%
126 \fi%
127 \relax %
128 }%
129
130 \def\GreTypewriter#1{%
131 {\tt #1}%
132 \relax %
133 }%
134
135 \def\GreColored#1{%
136 {%
137 \color{gregoriocolor}#1%
138 }%
139 }%
140
141 \def\GreUnderline#1{%
142 $\underline{\rm #1}$
143 \relax %
144 }%
145
146 %%%%%%%%%%%%%%%
147 %% Line color
148 %%%%%%%%%%%%%%%
149
150 % Colors don't work in PlainTeX, but we need these functions for interoperability with LaTeX.
151
152 \def\gresetlinecolor#1{%
153 \gre@changestyle{normalstafflines}{\color{#1}}[\relax]%
154 }
155
156
157 %%%%%%%%%%%%%%%%%%%%
158 %% Formatting environments
159 %%%%%%%%%%%%%%%%%%%%
160
161 \font\gre@font@initial=pncr at 40pt\relax%
162
163 \def\gre@style@initial{%
164 \begingroup%
165 \gre@font@initial%
166 \relax %
167 }%
168 \def\endgre@style@initial{\endgroup}%
169
170 \def\gre@style@translation{%
171 \begingroup%
172 \it%
173 }%
174 \def\endgre@style@translation{\endgroup}%
175
176 \def\gre@style@abovelinestext{%
177 \begingroup%
178 \it%
179 }%
180 \def\endgre@style@abovelinestext{\endgroup}%
181
182 \def\gre@style@normalstafflines{%
183 \begingroup%
184 \relax%
185 }%
186 \def\endgre@style@normalstafflines{\endgroup}%
187
188 \def\gre@style@additionalstafflines{%
189 \begingroup%
190 \gre@style@normalstafflines%
191 }%
192 \def\endgre@style@additionalstafflines{%
193 \endgre@style@normalstafflines%
194 \endgroup%
195 }%
196
197 \def\gre@style@lowchoralsign{%
198 \begingroup%
199 \relax%
200 }%
201 \def\endgre@style@lowchoralsign{\endgroup}%
202
203 \def\gre@style@highchoralsign{%
204 \begingroup%
205 \relax%
206 }%
207 \def\endgre@style@highchoralsign{\endgroup}%
208
209 \def\gre@style@firstsyllableinitial{%
210 \begingroup%
211 \relax%
212 }%
213 \def\endgre@style@firstsyllableinitial{\endgroup}%
214
215 \def\gre@style@firstsyllable{%
216 \begingroup%
217 \relax%
218 }%
219 \def\endgre@style@firstsyllable{\endgroup}%
220
221 \def\gre@style@firstword{%
222 \begingroup%
223 \relax%
224 }%
225 \def\endgre@style@firstword{\endgroup}%
226
227 \def\gre@style@modeline{%
228 \begingroup%
229 \bf%
230 \relax%
231 }%
232 \def\endgre@style@modeline{\endgroup}%
233
234 \def\gre@style@modemodifier{%
235 \begingroup%
236 \bf%
237 \it%
238 \relax%
239 }%
240 \def\endgre@style@modemodifier{\endgroup}%
241
242 \def\gre@style@modedifferentia{%
243 \begingroup%
244 \bf%
245 \relax%
246 }%
247 \def\endgre@style@modedifferentia{\endgroup}%
248
249 \def\gre@style@commentary{%
250 \begingroup%
251 \it%
252 % footnotesize in LaTeX, but nothing here since changing font size is so hard
253 \relax%
254 }%
255 \def\endgre@style@commentary{\endgroup}%
256
257 \def\gre@style@elision{%
258 \begingroup%
259 \it%
260 % small in LaTeX, but nothing here since changing font size is so hard
261 \relax%
262 }%
263 \def\endgre@style@elision{\endgroup}%
264
265 \def\gre@style@annotation{%
266 \begingroup%
267 \relax%
268 }%
269 \def\endgre@style@annotation{\endgroup}%
270
271 \def\gre@style@nabc{%
272 \begingroup%
273 \color{gregoriocolor}%
274 }
275 \def\endgre@style@nabc{\endgroup}%
276
277 \def\gre@changestyle#1#2[#3]{%
278 \expandafter\gdef\csname gre@style@#1\endcsname{\begingroup#2}%
279 \expandafter\gdef\csname endgre@style@#1\endcsname{#3\endgroup}%
280 }%
281
282 %%%%%%%%%%%%%%%
283 %% Default Mode Numbering style
284 %%%%%%%%%%%%%%%
285
286 \gresetmodenumbersystem{roman-majuscule}%
287
288 \catcode`\@=\greoldcatcode