From cd481bdd451490f0af8c7ee9cab5341d8a6c8cbb Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 19 Mar 2004 12:20:35 +0000 Subject: [PATCH] * lily/lily-guile.cc (ly:number->string): Do not leave space at end, prepend zeros. * scm/output-ps.scm (define-fonts): Always scale by designsize. Fixes feta-nummer, feta-din scaling. --- ChangeLog | 6 ++++++ lily/lily-guile.cc | 13 +++++-------- lily/paper-outputter.cc | 6 +++--- scm/output-lib.scm | 12 ++++++------ scm/output-pdf.scm | 20 ++++++++++---------- scm/output-pdftex.scm | 6 +++--- scm/output-ps.scm | 34 +++++++++++++++++----------------- scm/output-sketch.scm | 10 +++++----- scm/output-sodipodi.scm | 4 ++-- scm/output-tex.scm | 8 ++++---- 10 files changed, 61 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b2bba0b1f..f7dd3e48dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2004-03-19 Jan Nieuwenhuizen + * lily/lily-guile.cc (ly:number->string): Do not leave space at + end, prepend zeros. + + * scm/output-*.scm: Use ly:number->string rather than + number->string. Makes for saner output. + * scm/output-ps.scm (define-fonts): Always scale by designsize. Fixes feta-nummer, feta-din scaling. diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 954ef38c58..3b2b856402 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -314,10 +314,9 @@ ly_scm2offset (SCM s) } -LY_DEFINE (ly_number2string, "ly:number->string", 1, 0,0, - (SCM s), - " converts @var{num} to a string without generating many decimals. It " -"leaves a space at the end.") +LY_DEFINE (ly_number2string, "ly:number->string", + 1, 0, 0, (SCM s), + "Convert @var{num} to a string without generating many decimals.") { SCM_ASSERT_TYPE (gh_number_p (s), s, SCM_ARG1, __FUNCTION__, "number"); @@ -333,12 +332,10 @@ LY_DEFINE (ly_number2string, "ly:number->string", 1, 0,0, r = 0.0; } - sprintf (str, "%8.4f ", r); + sprintf (str, "%08.4f", r); } else - { - sprintf (str, "%d ", gh_scm2int (s)); - } + sprintf (str, "%d", gh_scm2int (s)); return scm_makfrom0str (str); } diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index a5a4205530..e544f472cf 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -67,11 +67,11 @@ Paper_outputter::Paper_outputter (String name) "ly:gulp-file", "ly:number->string", - "number-pair->string", /* output-lib.scm */ - "numbers->string", + "ly:number-pair->string", /* output-lib.scm */ + "ly:numbers->string", + "ly:inexact->string", "assoc-get", - "inexact->string", /* insecure guile? */ #if IMPORT_LESS "string-index", /* from srfi srfi-13 */ "regexp-substitute/global", /* from (ice9 regex) */ diff --git a/scm/output-lib.scm b/scm/output-lib.scm index b31d0bed13..e4a9557b46 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -88,7 +88,7 @@ ) (define-public (arg->string arg) - (cond ((number? arg) (inexact->string arg 10)) + (cond ((number? arg) (ly:inexact->string arg 10)) ((string? arg) (string-append "\"" arg "\"")) ((symbol? arg) (string-append "\"" (symbol->string arg) "\"")))) @@ -107,8 +107,9 @@ ;; do nothing in .scm output (define-public (comment s) "") -(define-public (numbers->string lst) - (apply string-append (map ly:number->string lst))) +(define-public (ly:numbers->string lst) + (apply string-append + (map (lambda (x) (string-append (ly:number->string x) " ")) lst))) (define (number->octal-string x) (let* ((n (inexact->exact x)) @@ -119,12 +120,11 @@ (number->string n8) (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8))))) -(define-public (inexact->string x radix) +(define-public (ly:inexact->string x radix) (let ((n (inexact->exact x))) (number->string n radix))) - -(define-public (number-pair->string c) +(define-public (ly:number-pair->string c) (string-append (ly:number->string (car c)) " " (ly:number->string (cdr c)) " ")) diff --git a/scm/output-pdf.scm b/scm/output-pdf.scm index 051d29d751..81ffdb0489 100644 --- a/scm/output-pdf.scm +++ b/scm/output-pdf.scm @@ -24,7 +24,7 @@ (define currentpoint (cons 0 0)) (define (showcp) - (string-append (number-pair->string currentpoint) " ")) + (string-append (ly:number-pair->string currentpoint) " ")) (define (moveto x y) (set! currentpoint (cons x y)) (string-append (showcp) "m ")) @@ -41,15 +41,15 @@ (lineto (+ x (car currentpoint)) (+ y (cdr currentpoint)))) (define (curveto x1 y1 x2 y2 x y) (set! currentpoint (cons x y)) - (string-append (ly:number->string x1) (ly:number->string y1) - (ly:number->string x2) (ly:number->string y2) - (ly:number->string x) (ly:number->string y) "c ")) + (string-append (ly:number->string x1) " " (ly:number->string y1) " " + (ly:number->string x2) " " (ly:number->string y2) " " + (ly:number->string x) " " (ly:number->string y) " c ")) (define (curveto-pairs pt1 pt2 pt) (curveto (car pt1) (cdr pt1) (car pt2) (cdr pt2) (car pt) (cdr pt))) (define (closefill) "h f ") (define (closestroke) "S ") -(define (setlinewidth w) (string-append (ly:number->string w) "w ")) -(define (setgray g) (string-append (ly:number->string g) "g ")) +(define (setlinewidth w) (string-append (ly:number->string w) " w ")) +(define (setgray g) (string-append (ly:number->string g) " g ")) (define (setlineparams) "1 j 1 J ") (define (beam width slope thick blot) @@ -136,9 +136,9 @@ (define (experimental-on) "") (define (filledbox breadth width depth height) - (string-append (ly:number->string (- breadth)) - (ly:number->string (- depth)) - (ly:number->string (+ breadth width)) + (string-append (ly:number->string (- breadth)) " " + (ly:number->string (- depth)) " " + (ly:number->string (+ breadth width)) " " (ly:number->string (+ depth height)) " re f ")) @@ -188,7 +188,7 @@ (define (invoke-char s i) (string-append - "(\\" (inexact->string i 8) ") " s " " )) + "(\\" (ly:inexact->string i 8) ") " s " " )) (define (placebox x y s) "") diff --git a/scm/output-pdftex.scm b/scm/output-pdftex.scm index 68425da5c6..d7e6e259dd 100644 --- a/scm/output-pdftex.scm +++ b/scm/output-pdftex.scm @@ -58,7 +58,7 @@ (embedded-pdf (list 'dashed-slur thick dash l))) (define (char i) - (string-append "\\char" (inexact->string i 10) " ")) + (string-append "\\char" (ly:inexact->string i 10) " ")) (define (dashed-line thick on off dx dy) (embedded-pdf (list 'dashed-line thick on off dx dy))) @@ -68,7 +68,7 @@ "\\font\\" command "=" (car name-mag) " scaled " - (ly:number->string (inexact->exact (* 1000 (cdr name-mag)))) + (ly:number->string (inexact->exact (* 1000 (cdr name-mag)))) "\n")) (define (ez-ball c l b) @@ -172,7 +172,7 @@ (define (invoke-char s i) (string-append - "\n\\" s "{" (inexact->string i 10) "}" )) + "\n\\" s "{" (ly:inexact->string i 10) "}" )) ;; FIXME: explain ploblem: need to do something to make this really safe. (define (output-tex-string s) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 4ad9a06802..b3de105c1c 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -105,8 +105,8 @@ (define (ps-number-def prefix key val) (let ((s (if (integer? val) - (number->string val) - (number->string (exact->inexact val))))) + (ly:number->string val) + (ly:number->string (exact->inexact val))))) (string-append "/" prefix (symbol->string key) " " s " def\n"))) (define (tex-font? fontname) @@ -120,24 +120,24 @@ ;;; Output-interface functions (define (beam width slope thick blot) (string-append - (numbers->string (list slope width thick blot)) " draw_beam" )) + (ly:numbers->string (list slope width thick blot)) " draw_beam" )) ;; two beziers (define (bezier-sandwich l thick) (string-append - (apply string-append (map number-pair->string l)) + (apply string-append (map ly:number-pair->string l)) (ly:number->string thick) " draw_bezier_sandwich ")) (define (bracket arch_angle arch_width arch_height height arch_thick thick) (string-append - (numbers->string + (ly:numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket")) (define (char i) (string-append - "(\\" (inexact->string i 8) ") show " )) + "(\\" (ly:inexact->string i 8) ") show " )) (define (comment s) (string-append "% " s "\n")) @@ -158,7 +158,7 @@ ;; what the heck is this interface ? (define (dashed-slur thick dash l) (string-append - (apply string-append (map number-pair->string l)) + (apply string-append (map ly:number-pair->string l)) (ly:number->string thick) " [ " (ly:number->string dash) @@ -240,7 +240,7 @@ (scaling (cdr value))) (cons key (cons value (string-append - "lilyfont" fontname "-" (number->string scaling)))))) + "lilyfont" fontname "-" (ly:number->string scaling)))))) (set! font-name-alist (map ps-encoded-fontswitch internal-external-name-mag-pairs)) @@ -251,7 +251,7 @@ (define (dot x y radius) (string-append " " - (numbers->string + (ly:numbers->string (list x y radius)) " draw_dot")) (define (draw-line thick x1 y1 x2 y2) @@ -275,12 +275,12 @@ (define (ez-ball ch letter-col ball-col) (string-append " (" ch ") " - (numbers->string (list letter-col ball-col)) + (ly:numbers->string (list letter-col ball-col)) " /Helvetica-Bold " ;; ugh " draw_ez_ball")) (define (filledbox breapth width depth height) - (string-append (numbers->string (list breapth width depth height)) + (string-append (ly:numbers->string (list breapth width depth height)) " draw_box")) (define (fontify name-mag-pair exp) @@ -398,31 +398,31 @@ (define (polygon points blotdiameter) (string-append " " - (numbers->string points) + (ly:numbers->string points) (ly:number->string (/ (length points) 2)) (ly:number->string blotdiameter) " draw_polygon")) (define (repeat-slash wid slope thick) (string-append - (numbers->string (list wid slope thick)) + (ly:numbers->string (list wid slope thick)) " draw_repeat_slash")) (define (round-filled-box x y width height blotdiam) (string-append " " - (numbers->string + (ly:numbers->string (list x y width height blotdiam)) " draw_round_box")) (define (new-start-system origin dim) (string-append - "\n" (number-pair->string origin) " start-system\n" + "\n" (ly:number-pair->string origin) " start-system\n" "{\n" "set-ps-scale-to-lily-scale\n")) (define (stem breapth width depth height) (string-append - (numbers->string (list breapth width depth height)) + (ly:numbers->string (list breapth width depth height)) " draw_box" )) (define (stop-system) @@ -432,7 +432,7 @@ (define (symmetric-x-triangle thick w h) (string-append - (numbers->string (list h w thick)) + (ly:numbers->string (list h w thick)) " draw_symmetric_x_triangle")) (define (text s) diff --git a/scm/output-sketch.scm b/scm/output-sketch.scm index 94a1383c81..89f7dc6ef7 100644 --- a/scm/output-sketch.scm +++ b/scm/output-sketch.scm @@ -99,7 +99,7 @@ ;;; urg. (define (sketch-numbers->string l) (string-append - (number->string (car l)) + (ly:number->string (car l)) (if (null? (cdr l)) "" (string-append "," (sketch-numbers->string (cdr l)))))) @@ -206,7 +206,7 @@ (define (bracket arch_angle arch_width arch_height height arch_thick thick) (string-append - (numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket" )) + (ly:numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket" )) (define (char x y i) (string-append @@ -227,7 +227,7 @@ ;; what the heck is this interface ? (define (dashed-slur thick dash l) (string-append - (apply string-append (map number-pair->string l)) + (apply string-append (map ly:number-pair->string l)) (ly:number->string thick) " [ " (ly:number->string dash) @@ -249,7 +249,7 @@ " ] 0 draw_dashed_line")) (define (repeat-slash wid slope thick) - (string-append (numbers->string (list wid slope thick)) + (string-append (ly:numbers->string (list wid slope thick)) " draw_repeat_slash")) (define (end-output) @@ -327,7 +327,7 @@ layer('Layer 1',1,1,0,0,(0,0,0)) (define (ez-ball ch letter-col ball-col) (string-append " (" ch ") " - (numbers->string (list letter-col ball-col)) + (ly:numbers->string (list letter-col ball-col)) " /Helvetica-Bold " ;; ugh " draw_ez_ball")) diff --git a/scm/output-sodipodi.scm b/scm/output-sodipodi.scm index 68a878d5e6..5d79103a5f 100644 --- a/scm/output-sodipodi.scm +++ b/scm/output-sodipodi.scm @@ -130,12 +130,12 @@ (define (control-flip-y c) (cons (car c) (* -1 (cdr c)))) -(define (numbers->string l) +(define (ly:numbers->string l) (string-append (number->string (car l)) (if (null? (cdr l)) "" - (string-append "," (numbers->string (cdr l)))))) + (string-append "," (ly:numbers->string (cdr l)))))) (define (svg-bezier l close) (let* ((c0 (car (list-tail l 3))) diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 32aa45778e..7f8259d4a4 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -182,7 +182,7 @@ (embedded-ps (list 'dashed-slur thick dash `(quote ,l)))) (define (char i) - (string-append "\\char" (inexact->string i 10) " ")) + (string-append "\\char" (ly:inexact->string i 10) " ")) (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) @@ -198,7 +198,7 @@ "\\font\\" command "=" (car name-mag) " scaled " - (ly:number->string (inexact->exact (round (* 1000 (cdr name-mag))))) + (ly:number->string (inexact->exact (round (* 1000 (cdr name-mag))))) "\n")) (define (ez-ball c l b) @@ -274,7 +274,7 @@ (define (invoke-char s i) (string-append - "\n\\" s "{" (inexact->string i 10) "}" )) + "\n\\" s "{" (ly:inexact->string i 10) "}" )) ;; FIXME: explain ploblem: need to do something to make this really safe. (define-public (output-tex-string s) @@ -327,7 +327,7 @@ (define (filledbox breapth width depth height) (if (and #f (defined? 'ps-testing)) (embedded-ps - (string-append (numbers->string (list breapth width depth height)) + (string-append (ly:numbers->string (list breapth width depth height)) " draw_box" )) (string-append "\\lyvrule{" (ly:number->string (- breapth)) "}{" -- 2.39.2