Reviewers: ,
Message:
Does this one need a convert-rule?
If so, I'd need some help. My python-skill is more or less zero.
Description:
Fix underline-markup to make multiple calls have nice output
Amend regtest markup-commands.ly with an example for it.
Please review this at https://codereview.appspot.com/559150043/
Affected files (+47, -9 lines):
M input/regression/markup-commands.ly
M scm/define-markup-commands.scm
Index: input/regression/markup-commands.ly
diff --git a/input/regression/markup-commands.ly
b/input/regression/markup-commands.ly
index
60d1f2f843f54a7077b24a05dd68e0cb6caffa3e..047a902759862abdfeabb1958bb3daf90eb87440
100644
--- a/input/regression/markup-commands.ly
+++ b/input/regression/markup-commands.ly
@@ -32,6 +32,7 @@
draw-line: \draw-line #'(5 . 3)
\underline "underlined"
+ \underline \underline \underline "multiple underlines"
}
}
}
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index
a4be8d9d82db190bb51c410075243cac47342d0e..0684c27c7e178e96faf833d597df4e67786a97af
100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -667,29 +667,66 @@ Create a beam with the specified parameters.
(define-markup-command (underline layout props arg)
(markup?)
#:category font
- #:properties ((thickness 1) (offset 2))
+ #:properties ((thickness 1) (underline-offset 2) (underline-distance 2))
"
@cindex underlining text
Underline @var{arg}. Looks at @code{thickness} to determine line
-thickness, and @code{offset} to determine line y-offset.
+thickness, @code{underline-offset} to determine line y-offset from
@var{arg} and
+@code{underline-distance} to determine the distance of additional lines
from the
+others.
@lilypond[verbatim,quote]
\\markup \\fill-line {
\\underline \"underlined\"
- \\override #'((offset . 5) (thickness . 1))
+ \\override #'(underline-offset . 5)
+ \\override #'(thickness . 1)
\\underline \"underlined\"
- \\override #'((offset . 1) (thickness . 5))
+ \\override #'(underline-offset . 1)
+ \\override #'(thickness . 5)
\\underline \"underlined\"
+ \\override #'(underline-offset . 5)
+ \\override #'(underline-distance . 4)
+ \\underline \\underline \\underline \"multiple underlined\"
}
@end lilypond"
(let* ((thick (ly:output-def-lookup layout 'line-thickness))
(underline-thick (* thickness thick))
- (m (interpret-markup layout props arg))
- (x1 (car (ly:stencil-extent m X)))
- (x2 (cdr (ly:stencil-extent m X)))
- (y (* thick (- offset)))
- (line (make-line-stencil underline-thick x1 y x2 y)))
+ (m (interpret-markup
+ layout
+ ;; For multiple calls of underline-markup, this will result
in
+ ;; the innermost underline ending up lowest.
+ (prepend-alist-chain
+ 'underline-offset
+ (+ underline-offset underline-distance)
+ props)
+ arg))
+ (arg-x-ext (ly:stencil-extent m X))
+ (x1 (car arg-x-ext))
+ (x2 (cdr arg-x-ext))
+ (y (* thick (- underline-offset)))
+ (raw-line-stil (make-line-stencil underline-thick x1 y x2 y))
+ (line
+ (ly:make-stencil
+ (ly:stencil-expr raw-line-stil)
+ ;; We use x-extent of the arg-stencil instead of the
line-stencil
+ ;; to avoid increasing lines with multiple calls of underline.
+ ;; As a consequence the line sticks out a bit into the space
+ ;; between elements of continuing text, without affecting it.
+ ;; For huge values of thickness this may cause undesired
output,
+ ;; we regard this a very rare case, though.
+ ;; Alternatively we could have shortened the underline by its
+ ;; thickness, i.e. raw-line-stil would have been:
+ ;; (make-line-stencil
+ ;; underline-thick
+ ;; (+ x1 (/ underline-thick 2))
+ ;; y
+ ;; (- x2 (/ underline-thick 2))
+ ;; y))
+ ;; without need to reset x-extent, this causes a different
ugliness
+ ;; for huge thickness, though.
+ arg-x-ext
+ (ly:stencil-extent raw-line-stil Y))))
(ly:stencil-add m line)))
(define-markup-command (tie layout props arg)
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel