[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Aligning custom-dynamic-scripts using dynamic-string?
From: |
harm6 |
Subject: |
Aligning custom-dynamic-scripts using dynamic-string? |
Date: |
Sun, 3 Jul 2011 07:18:06 -0700 (PDT) |
Hi,
inspired by the Thread
http://old.nabble.com/Dynamic-%2B-text-aligned%3A-BEST-solution--td31881932.html
"Dynamic + text aligned: BEST solution?" I tried some definitions using
http://git.savannah.gnu.org/cgit/opus-libre.git/tree/bin/markup-commands.scm
dynamic-string
in order to get new custom-dynamic-scripts featering left and right-align
with the first (last) dynamic centered
on the parent-note.
makeNewDynamicScriptLeft works fine!
The new defined markup-command dynamicStringRight works well in a common
markup, but trying to use it in makeNewDynamicScriptRight fails!
The log:
attFFFF = #
(makeNewDynamicScriptRight "mp,_quasi_mf_ma più dolce,
attacca_ffff")
Wrong type (expecting character): "mp,_quasi_mf_ma più dolce, attacca_ffff"
I can't see the essential difference between the dynamic-scripts or what's
wrong with dynamicStringRight.
How to improve?
Regards,
Harm
Please excuse my rusty english!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Code:
\version "2.14.1"
#(define-public (char-punctuation? ch)
(char-set-contains? char-set:punctuation ch))
#(define-public char-set:dynamics
(char-set #\f #\m #\p #\r #\s #\z))
#(define-markup-command (dynamic-string layout props str) (string?)
(let ((composite-chars (char-set-union
char-set:dynamics
char-set:whitespace
char-set:punctuation))
(split (lambda (s) (string-index s #\_ )))
(str-list '())
(dyn-markup (lambda (s)
(make-whiteout-markup
(make-dynamic-markup s))))
(text-markup (lambda (s)
(make-whiteout-markup
(make-normal-text-markup
(make-italic-markup s))))))
(do ((current-str (string-append str "_")))
((not (split current-str)))
(begin
(set! str-list
(append str-list (list
(string-take current-str (split
current-str)))))
(set! current-str
(string-drop current-str (+ (split current-str) 1)))))
(interpret-markup layout props
(make-line-markup
(map (lambda (word)
(if (string-every composite-chars word)
(if (string-every char-set:dynamics word)
(dyn-markup word)
(let ((word-lst (string->list word)))
(make-concat-markup
(map (lambda (ch)
(let ((print-ch (string
ch)))
(if (char-punctuation? ch)
(text-markup print-ch)
(dyn-markup
print-ch))))
word-lst))))
(text-markup word)))
str-list)))))
#(define-markup-command (dynamicStringRight layout props dyn)(string)
(let* (
(composite-chars (char-set-union
char-set:dynamics
char-set:whitespace
char-set:punctuation))
(markUp (markup #:dynamic-string dyn))
(textStencil (interpret-markup layout props markUp))
(textExt (ly:stencil-extent textStencil X))
(textLength (interval-length textExt))
(str-list (string-split dyn #\_))
(lastPos (car (last-pair str-list)))
(mrkp (if (string-every char-set:dynamics lastPos)
(markup #:dynamic-string lastPos)
(markup #:normal-text #:italic lastPos)))
(text-Stencil (interpret-markup layout props mrkp))
(text-Ext (ly:stencil-extent text-Stencil X))
(text-Length (interval-length text-Ext))
(alignX (* -1 (- textLength (/ text-Length 2))))
)
(ly:stencil-translate-axis textStencil alignX X )
))
#(define (makeNewDynamicScriptLeft text)
(make-music 'AbsoluteDynamicEvent
'tweaks
(list (cons 'X-offset -1.5))
'text
(markup #:dynamic-string text)))
mpquasimf = #(makeNewDynamicScriptLeft "mp,_quasi_mf_ma più dolce,
attacca_ffff")
#(define (makeNewDynamicScriptRight dyn)
(make-music 'AbsoluteDynamicEvent
'tweaks
(list (cons 'X-offset 0))
'text
(markup #:dynamicStringRight dyn)))
%attFFFF = #(makeNewDynamicScriptRight "mp,_quasi_mf_ma più dolce,
attacca_ffff")
%-------------------------- Test
-----------------------------------------------
\relative c' {
a'1 bes-\markup { \dynamicStringRight #"mp,_quasi_mf_ma più
dolce,
attacca_ffff" }
\break
a bes\mpquasimf
\break
a bes%\attFFFF
}
--
View this message in context:
http://old.nabble.com/Aligning-custom-dynamic-scripts-using-dynamic-string--tp31983828p31983828.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.
- Aligning custom-dynamic-scripts using dynamic-string?,
harm6 <=