- (space-left (- line-width (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
- line-stencils))))
-
- (line-word-space (cond
- ((not justify) space)
-
- ;; don't stretch last line of paragraph.
- ;; hmmm . bug - will overstretch the last line in some case.
- ((null? (cdr line-break))
- base-space)
- ((null? line-stencils) 0.0)
- ((null? (cdr line-stencils)) 0.0)
- (else (/ space-left (1- (length line-stencils))))))
-
- (line (stack-stencil-line
- line-word-space
- (if (= text-dir RIGHT)
- (reverse line-stencils)
- line-stencils))))
-
- (if (pair? (cdr line-break))
- (loop (cons line lines)
- (cdr line-break))
-
- (begin
- (if (= text-dir LEFT)
- (set! line
- (ly:stencil-translate-axis line
- (- line-width (interval-end (ly:stencil-extent line X)))
- X)))
- (reverse (cons line lines))
-
- )))
-
- ))
-
+ (space-left (- line-width
+ (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
+ line-stencils))))
+ (line-word-space (cond ((not justify) space)
+ ;; don't stretch last line of paragraph.
+ ;; hmmm . bug - will overstretch the last line in some case.
+ ((null? (cdr line-break))
+ base-space)
+ ((null? line-stencils) 0.0)
+ ((null? (cdr line-stencils)) 0.0)
+ (else (/ space-left (1- (length line-stencils))))))
+ (line (stack-stencil-line line-word-space
+ (if (= text-dir RIGHT)
+ (reverse line-stencils)
+ line-stencils))))
+ (if (pair? (cdr line-break))
+ (loop (cons line lines)
+ (cdr line-break))
+ (begin
+ (if (= text-dir LEFT)
+ (set! line
+ (ly:stencil-translate-axis
+ line
+ (- line-width (interval-end (ly:stencil-extent line X)))
+ X)))
+ (reverse (cons line lines)))))))
+
+(define-builtin-markup-list-command (wordwrap-internal layout props justify args)
+ (boolean? markup-list?)
+ ((line-width #f)
+ (word-space)
+ (text-direction RIGHT))
+ "Internal markup list command used to define @code{\\justify} and @code{\\wordwrap}."
+ (wordwrap-stencils (remove ly:stencil-empty?
+ (interpret-markup-list layout props args))
+ justify
+ word-space
+ (or line-width
+ (ly:output-def-lookup layout 'line-width))
+ text-direction))
+
+(define-builtin-markup-command (justify layout props args)
+ (markup-list?)
+ align
+ ((baseline-skip)
+ wordwrap-internal-markup-list)
+ "
+@cindex justifying text