end, prepend zeros.
* scm/output-ps.scm (define-fonts): Always scale by designsize.
Fixes feta-nummer, feta-din scaling.
2004-03-19 Jan Nieuwenhuizen <janneke@gnu.org>
2004-03-19 Jan Nieuwenhuizen <janneke@gnu.org>
+ * 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.
* scm/output-ps.scm (define-fonts): Always scale by designsize.
Fixes feta-nummer, feta-din scaling.
-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");
{
SCM_ASSERT_TYPE (gh_number_p (s), s, SCM_ARG1, __FUNCTION__, "number");
- sprintf (str, "%8.4f ", r);
+ sprintf (str, "%08.4f", r);
- {
- sprintf (str, "%d ", gh_scm2int (s));
- }
+ sprintf (str, "%d", gh_scm2int (s));
return scm_makfrom0str (str);
}
return scm_makfrom0str (str);
}
"ly:gulp-file",
"ly:number->string",
"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",
- "inexact->string", /* insecure guile? */
#if IMPORT_LESS
"string-index", /* from srfi srfi-13 */
"regexp-substitute/global", /* from (ice9 regex) */
#if IMPORT_LESS
"string-index", /* from srfi srfi-13 */
"regexp-substitute/global", /* from (ice9 regex) */
)
(define-public (arg->string arg)
)
(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) "\""))))
((string? arg) (string-append "\"" arg "\""))
((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
;; do nothing in .scm output
(define-public (comment s) "")
;; 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))
(define (number->octal-string x)
(let* ((n (inexact->exact x))
(number->string n8)
(number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
(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)))
(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)) " "))
(string-append (ly:number->string (car c)) " "
(ly:number->string (cdr c)) " "))
(define currentpoint (cons 0 0))
(define (showcp)
(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 "))
(define (moveto x y)
(set! currentpoint (cons x y))
(string-append (showcp) "m "))
(lineto (+ x (car currentpoint)) (+ y (cdr currentpoint))))
(define (curveto x1 y1 x2 y2 x y)
(set! currentpoint (cons x y))
(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 (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)
(define (setlineparams) "1 j 1 J ")
(define (beam width slope thick blot)
(define (experimental-on) "")
(define (filledbox breadth width depth height)
(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 "))
(ly:number->string (+ depth height))
" re f "))
(define (invoke-char s i)
(string-append
(define (invoke-char s i)
(string-append
- "(\\" (inexact->string i 8) ") " s " " ))
+ "(\\" (ly:inexact->string i 8) ") " s " " ))
(define (placebox x y s) "")
(define (placebox x y s) "")
(embedded-pdf (list 'dashed-slur thick dash l)))
(define (char i)
(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)))
(define (dashed-line thick on off dx dy)
(embedded-pdf (list 'dashed-line thick on off dx dy)))
"\\font\\" command "="
(car name-mag)
" scaled "
"\\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)
"\n"))
(define (ez-ball c l b)
(define (invoke-char s i)
(string-append
(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)
;; FIXME: explain ploblem: need to do something to make this really safe.
(define (output-tex-string s)
(define (ps-number-def prefix key val)
(let ((s (if (integer? val)
(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)
(string-append "/" prefix (symbol->string key) " " s " def\n")))
(define (tex-font? fontname)
;;; Output-interface functions
(define (beam width slope thick blot)
(string-append
;;; 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
;; 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
(ly:number->string thick)
" draw_bezier_sandwich "))
(define (bracket arch_angle arch_width arch_height height arch_thick thick)
(string-append
(list arch_angle arch_width arch_height height arch_thick thick))
" draw_bracket"))
(define (char i)
(string-append
(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"))
(define (comment s)
(string-append "% " s "\n"))
;; what the heck is this interface ?
(define (dashed-slur thick dash l)
(string-append
;; 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)
(ly:number->string thick)
" [ "
(ly:number->string dash)
(scaling (cdr value)))
(cons key (cons value
(string-append
(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))
(set! font-name-alist
(map ps-encoded-fontswitch internal-external-name-mag-pairs))
(define (dot x y radius)
(string-append
" "
(define (dot x y radius)
(string-append
" "
(list x y radius)) " draw_dot"))
(define (draw-line thick x1 y1 x2 y2)
(list x y radius)) " draw_dot"))
(define (draw-line thick x1 y1 x2 y2)
(define (ez-ball ch letter-col ball-col)
(string-append
" (" ch ") "
(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)
" /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)
" draw_box"))
(define (fontify name-mag-pair exp)
(define (polygon points blotdiameter)
(string-append
" "
(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
(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
" "
" draw_repeat_slash"))
(define (round-filled-box x y width height blotdiam)
(string-append
" "
(list x y width height blotdiam)) " draw_round_box"))
(define (new-start-system origin dim)
(string-append
(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
"{\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)
" draw_box" ))
(define (stop-system)
(define (symmetric-x-triangle thick w h)
(string-append
(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)
" draw_symmetric_x_triangle"))
(define (text s)
;;; urg.
(define (sketch-numbers->string l)
(string-append
;;; 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))))))
(if (null? (cdr l))
""
(string-append "," (sketch-numbers->string (cdr l))))))
(define (bracket arch_angle arch_width arch_height height arch_thick thick)
(string-append
(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
(define (char x y i)
(string-append
;; what the heck is this interface ?
(define (dashed-slur thick dash l)
(string-append
;; 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)
(ly:number->string thick)
" [ "
(ly:number->string dash)
" ] 0 draw_dashed_line"))
(define (repeat-slash wid slope thick)
" ] 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)
" draw_repeat_slash"))
(define (end-output)
(define (ez-ball ch letter-col ball-col)
(string-append
" (" ch ") "
(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"))
" /Helvetica-Bold " ;; ugh
" draw_ez_ball"))
(define (control-flip-y c)
(cons (car c) (* -1 (cdr c))))
(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
(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)))
(define (svg-bezier l close)
(let* ((c0 (car (list-tail l 3)))
(embedded-ps (list 'dashed-slur thick dash `(quote ,l))))
(define (char i)
(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)))
(define (dashed-line thick on off dx dy)
(embedded-ps (list 'dashed-line thick on off dx dy)))
"\\font\\" command "="
(car name-mag)
" scaled "
"\\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)
"\n"))
(define (ez-ball c l b)
(define (invoke-char s i)
(string-append
(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)
;; FIXME: explain ploblem: need to do something to make this really safe.
(define-public (output-tex-string s)
(define (filledbox breapth width depth height)
(if (and #f (defined? 'ps-testing))
(embedded-ps
(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)) "}{"
" draw_box" ))
(string-append "\\lyvrule{"
(ly:number->string (- breapth)) "}{"