From: Han-Wen Nienhuys Date: Tue, 7 Jun 2005 11:29:30 +0000 (+0000) Subject: (fill-line): handle text-widths = X-Git-Tag: release/2.5.29~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=117b8c86aa6d1f926b267a7993c92ca7207375d6;p=lilypond.git (fill-line): handle text-widths = '() case. --- diff --git a/ChangeLog b/ChangeLog index 7843c35841..f71c4bf795 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-06-07 Han-Wen Nienhuys + + * scm/define-markup-commands.scm (fill-line): handle text-widths = + '() case. + 2005-06-07 Jan Nieuwenhuizen * scm/ps-to-png.scm (make-ps-images): Bugfix: `Pages: 1\n' is not diff --git a/VERSION b/VERSION index 17d3159e6b..b53029edd0 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=5 -PATCH_LEVEL=28 +PATCH_LEVEL=29 MY_PATCH_LEVEL= diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 9502c2c89e..4c62c02615 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -194,6 +194,37 @@ gsave /ecrm10 findfont The markups are spaced/flushed to fill the entire line. If there are no arguments, return an empty stencil. " + + + (define (get-fill-space word-count line-width text-widths) + "Calculate the necessary paddings between each two adjacent texts. + The lengths of all texts are stored in @var{text-widths}. + The normal formula for the padding between texts a and b is: + padding = line-width/(word-count - 1) - (length(a) + length(b))/2 + The first and last padding have to be calculated specially using the + whole length of the first or last text. + Return a list of paddings. +" + (cond + ((null? text-widths) '()) + + ;; special case first padding + ((= (length text-widths) word-count) + (cons + (- (- (/ line-width (1- word-count)) (car text-widths)) + (/ (car (cdr text-widths)) 2)) + (get-fill-space word-count line-width (cdr text-widths)))) + ;; special case last padding + ((= (length text-widths) 2) + (list (- (/ line-width (1- word-count)) + (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0)) + (else + (cons + (- (/ line-width (1- word-count)) + (/ (+ (car text-widths) (car (cdr text-widths))) 2)) + (get-fill-space word-count line-width (cdr text-widths)))))) + + (let* ((orig-stencils (map (lambda (x) (interpret-markup layout props x)) markups)) @@ -241,32 +272,6 @@ gsave /ecrm10 findfont empty-stencil (stack-stencils-padding-list X RIGHT fill-space-normal line-stencils)))) -(define (get-fill-space word-count line-width text-widths) - "Calculate the necessary paddings between each two adjacent texts. - The lengths of all texts are stored in @var{text-widths}. - The normal formula for the padding between texts a and b is: - padding = line-width/(word-count - 1) - (length(a) + length(b))/2 - The first and last padding have to be calculated specially using the - whole length of the first or last text. - Return a list of paddings. -" - (cond - ;; special case first padding - ((= (length text-widths) word-count) - (cons - (- (- (/ line-width (1- word-count)) (car text-widths)) - (/ (car (cdr text-widths)) 2)) - (get-fill-space word-count line-width (cdr text-widths)))) - ;; special case last padding - ((= (length text-widths) 2) - (list (- (/ line-width (1- word-count)) - (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0)) - (else - (cons - (- (/ line-width (1- word-count)) - (/ (+ (car text-widths) (car (cdr text-widths))) 2)) - (get-fill-space word-count line-width (cdr text-widths)))))) - (define (font-markup qualifier value) (lambda (layout props arg) (interpret-markup layout (prepend-alist-chain qualifier value props) arg)))