-
Notifications
You must be signed in to change notification settings - Fork 0
/
lilytex.py
executable file
·77 lines (69 loc) · 1.86 KB
/
lilytex.py
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
#!/usr/bin/env python3
import os, sys
from configparser import ConfigParser
from subprocess import Popen
from string import Template
def main():
lil = ConfigParser()
lil.read(sys.argv[1])
path = lil.get('General', 'filename')
dirname = os.path.dirname(path)
basename = os.path.basename(path)
columnwidth = lil.get('General', 'columnwidth')[:-2]
staffsize = lil.get('Options', 'staffsize')[:-2]
Staffsize = ''
if staffsize != '0.0':
Staffsize = '''
#(set-global-staff-size %s)
''' % staffsize
betweensystemspace = lil.get('Options', 'between-system-space')[:-2]
config = Template(
'''%% Automatically generated by lilytex
%% staff size: set by option
%% no indent
%% line-width = LaTeX \columnwidth
%% no titles
%% between-system-space (distance between systems): set by option
%% betweeb-system-padding: ???
%% lines justified
%%
$Staffsize
\paper {
indent = 0\mm
line-width = $columnwidth\pt
oddFooterMarkup = ##f
oddHeaderMarkup = ##f
bookTitleMarkup = ##f
scoreTitleMarkup = ##f
between-system-space = $bss\pt
between-system-padding = #1
ragged-right = ##f
}
%% no bar numbers
\layout {
\context {
\Score
\\remove "Bar_number_engraver"
}
}
''')
f = open(os.path.join(dirname, 'config.ly'), 'w')
f.write(config.substitute(
columnwidth=columnwidth,
Staffsize=Staffsize,
bss=betweensystemspace))
f.close()
# See:
# http://lilypond.org/doc/v2.22/Documentation/usage/other-programs
# and
# https://lists.gnu.org/archive/html/lilypond-user/2022-11/msg00047.html
#args = ['lilypond', '-dbackend=eps', '-dno-gs-load-fonts',
args = ['lilypond', '--eps', '-dno-gs-load-fonts',
'-dinclude-eps-fonts', basename]
if dirname == '':
p = Popen(args)
else:
p = Popen(args, cwd=dirname)
p.wait()
if __name__ == '__main__':
main()