[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
asian scripts + lilypond
From: |
Werner LEMBERG |
Subject: |
asian scripts + lilypond |
Date: |
Sun, 11 Jul 2004 12:18:26 +0200 (CEST) |
Here my results typesetting a Japanese folk song (Sakura sakura) and a
Chinese children song (Xiao haizi guai guai) with version 2.2.4.
The current `lilypond' script must be extended to pass more
information:
. Two new \header fields `atbegindocument' and `atenddocument'.
While I haven't actually used the latter it makes sense to provide
it for symmetry.
I need this to set the default font family for the Asian script.
. The `latexpackages' now handles optional parameters to packages.
Example:
The following
latexpackages = "[encapsulated]CJK,pinyin,[cjkbg5]ucs"
now translates to
\usepackage[encapsulated]{CJK}
\usepackage{pinyin}
\usepackage[cjkbg5]{ucs}
See the attached diff.
BTW, the `inputencoding' \header field isn't documented in section
5.1.2 of lilypond.info, and `fontencoding' is incorrectly documented
as `fontenc'.
For my tests, I've used Dominique Unruh's `unicode' package.
Enjoy!
Werner
%
% sakura-sakura.ly
%
\version "2.2.4"
\header {
title = "さくら さくら (Sakura, sakura)"
composer = ""
copyright = ""
footer = ""
tagline = ""
latexpackages = "[encapsulated]CJK,[cjkjis]ucs"
inputencoding = "utf8"
fontencoding = "C42,OT1"
atbegindocument = "\fontfamily{min}"
}
melody = \notes \relative c'' {
a4 a b2 | a4 a b2 |
a4 b c b | a4 b8[ a] f2 |
e4 c e f | e4 e8[ c] b2 |
a'4 b c b | a4 b8[ a] f2 |
e4 c e f | e4 e8[ c] b2 |
a'4 a b2 | a4 a b2 |
d,4 e b'8[ a] f4 | e1 \bar "|."
}
text = \lyrics {
さ く ら さ く ら
の や ま も さ と も
み わ た す か ぎ り
か す み か く も か
あ さ ひ に に を う
さ く ら さ く ら
は な ざ か り
}
\score {
<<
\context Voice = one {
\set Staff.autoBeaming = ##f
\override Score.LyricText #'extra-offset = #'(1 . 0)
\melody
}
\lyricsto "one" \new Lyrics \text
>>
\paper { }
}
% Local Variables:
% coding: utf-8
% End:
% EOF
sakura-sakura.pdf
Description: Adobe PDF document
%
% xiao-haizi-guai-guai.ly
%
\version "2.2.4"
\header {
title = "小孩子乖乖 (\Xiao3 \hai2\zi5 \guai1\guai1)"
composer = ""
copyright = ""
footer = ""
tagline = ""
latexpackages = "[encapsulated]CJK,pinyin,[cjkbg5]ucs"
inputencoding = "utf8"
fontencoding = "C00,OT1"
atbegindocument = "\fontfamily{bsmi}"
}
melody = \notes \relative c'' {
g4 c8 a g4 g |
e4 g8 a g4 g |
a4 g8 e d4 d |
e4 g8[ e] d[ e] c4 |
a'8 g a g e a g4 |
e8 g e d c4 r |
a8 c d e c4 r \bar "|."
}
text = \lyrics {
小 孩 子 乖 乖
把 門 兒 開 開
快 點 兒 開 開
我 要 進 來
不 開 不 開 不 能 開
你 是 大 野 狼
不 讓 你 進 來
}
\score {
<<
\context Voice = one {
\set Staff.autoBeaming = ##f
\override Score.LyricText #'extra-offset = #'(1 . 0)
\melody
}
\lyricsto "one" \new Lyrics \text
>>
\paper { }
}
% Local Variables:
% coding: utf-8
% End:
% EOF
xiao-haizi-guai-guai.pdf
Description: Adobe PDF document
--- lilypond.old Fri Jul 9 15:22:16 2004
+++ lilypond Sun Jul 11 09:49:37 2004
@@ -198,6 +198,9 @@
'linewidth' : [],
'orientation' : [],
'unit' : ['pt'],
+
+ 'atbegindocument' : [],
+ 'atenddocument' : [],
}
extra_fields = extra_init.keys ()
@@ -412,7 +415,13 @@
if safe_mode_p:
s += '\\nofiles\n'
- s += '\\usepackage{%s}\n' % string.join (extra['latexpackages'], ',')
+ if extra['latexpackages']:
+ for i in string.split \
+ (string.join (extra['latexpackages'], ','), ','):
+ m = re.search (r'((\[.*\])*)(.*)', i)
+ if m:
+ s += '\\usepackage%s{%s}\n' \
+ % (m.group (1), m.group (3))
if extra['language']:
s += r'\usepackage[%s]{babel}' % extra['language'][-1] + '\n'
@@ -478,6 +487,8 @@
s = global_latex_preamble (extra) + '\\begin{document}\n'
+ if extra['atbegindocument']:
+ s += extra['atbegindocument'][-1] + '\n'
s += '\\parindent 0pt\n'
s += '\\thispagestyle{firstpage}\n'
@@ -488,6 +499,8 @@
s += '\n\\thispagestyle{lastpage}\n'
+ if extra['atenddocument']:
+ s += extra['atenddocument'][-1] + '\n'
s += '\\end{document}'
return s
- asian scripts + lilypond,
Werner LEMBERG <=