Re: Improvements to Postscript backend (patches included)
David Feuer schreef: On 3/31/06, Han-Wen Nienhuys [EMAIL PROTECTED] wrote: According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. Unfortunately, I can't make the utf-8 regression test work either with or without my changes, so I can't be sure I got this right. unfortunately, Ghostscript disagrees. It throws a /typecheck error from --glyphshow-- , if you load the font as a regular font. Yech. I suspect this is a bug in Ghostscript, though I could be reading the PostScript reference wrong. Could you take a look at section 5.11.3 (CIDFont Dictionaries), the entry for selectfont in the operator index (page 656, or PDF page 670), and the entry for glyphshow (page 602, PDF page 616)? I suspect you may know more about postscript than me, your guess is as good as mine; If you think it is bug, can you file a bug with ghostscript development? I can send you a file with an embedded CFF CID font. ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
On 4/1/06, Han-Wen Nienhuys [EMAIL PROTECTED] wrote: I suspect you may know more about postscript than me, your guess is as good as mine; If you think it is bug, can you file a bug with ghostscript development? I can send you a file with an embedded CFF CID font. I don't actually know _too_ much about PostScript. I write it with the reference up on my screen, and fonts are one of the parts I understand least. If I get a chance, I'll ask the Ghostscript people about it. David Feuer ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
David Feuer wrote: (format #f gsave - /~a ~a ~a output-scale div scalefont setfont\n~a grestore + /~a ~a output-scale div selectfont\n~a grestore postscript-font-name - (if cid? - /CIDFont findresource - findfont) I don't understand this? How are CID resources supposed to be loaded now? According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. Unfortunately, I can't make the utf-8 regression test work either with or without my changes, so I can't be sure I got this right. unfortunately, Ghostscript disagrees. It throws a /typecheck error from --glyphshow-- , if you load the font as a regular font. -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen LilyPond Software Design -- Code for Music Notation http://www.lilypond-design.com ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
On 3/31/06, Han-Wen Nienhuys [EMAIL PROTECTED] wrote: According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. Unfortunately, I can't make the utf-8 regression test work either with or without my changes, so I can't be sure I got this right. unfortunately, Ghostscript disagrees. It throws a /typecheck error from --glyphshow-- , if you load the font as a regular font. Yech. I suspect this is a bug in Ghostscript, though I could be reading the PostScript reference wrong. Could you take a look at section 5.11.3 (CIDFont Dictionaries), the entry for selectfont in the operator index (page 656, or PDF page 670), and the entry for glyphshow (page 602, PDF page 616)? ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
In pango-font.cc, what are ggeo.width and ggeo.x_offset? glyph-string, in output-ps.scm, adds the two together to figure out where to place the next glyph. Is ggeo.width the same as the width PostScript would use to place the next glyph? If so, it would be much cleaner not to add it in, and not have to move back over it. In detail: Current situation: place glyph - move to the left by what I'm guessing might be ggeo.width - move to the right by ggeo.width + ggeo.x_offset - place another glyph. If ggeo.width is the width PostScript uses for glyphshow, we can change it to: place glyph - move to the right by ggeo.x_offset - place another glyph. David Feuer ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
On 3/28/06, Werner LEMBERG [EMAIL PROTECTED] wrote: - (if cid? - /CIDFont findresource - findfont) I don't understand this? How are CID resources supposed to be loaded now? According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. But a CID resource is completely useless for us since we don't get the corresponding CID value, AFAIK. In case Pango does the CMap resource handling (this is, we send a Unicode value and Pango returns the CID) we can enable this again. The current code does /fontname /CIDFont findresource 17 scalefont setfont, where 17 is a random number. If I'm not mistaken, this is completely equivalent to /fontname 17 selectfont, except that it's almost certainly slower. David ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
David Feuer wrote: If ggeo.width is the width PostScript uses for glyphshow, we can change it to: ggeo.width is the kerning info that we get from pango. -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen LilyPond Software Design -- Code for Music Notation http://www.lilypond-design.com ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
But a CID resource is completely useless for us since we don't get the corresponding CID value, AFAIK. In case Pango does the CMap resource handling (this is, we send a Unicode value and Pango returns the CID) we can enable this again. The current code does /fontname /CIDFont findresource 17 scalefont setfont, where 17 is a random number. If I'm not mistaken, this is completely equivalent to /fontname 17 selectfont, except that it's almost certainly slower. You are probably right, but this code will (at least temporarily) vanish, I think, since we aren't able currently to handle CIDFont resources directly. Werner ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
David Feuer wrote: I sent this some hours ago, but haven't seen it yet. Is the mailing list broken, or just really slow? The list is a bit slow, and I have been away. Original message: I made some changes to the Postscript backend, making the output more readable (especially for text), around 10% shorter, and, at least in theory, also faster to interpret. These changes are just a start, but I hope they help. I'd like to know if it might be possible to make the backend work at a slightly higher level, which should allow much smaller files (e.g., Postscript could easily understand the concept of filled dotted quarter note in current note font with upward stem 3 staff spaces long). That's very unlikely. The internal representation is not strictly hierarchical, so it's difficult to group different objects (eg. note and stem) so they will be output together, and still be sure that all of them are processed. I'm not a master of diff, so let me know if the following aren't done right. Diffs (made with -u) against the 2.8.0 source: I'm missing a Changelog entry. --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/scm/framework-ps.scm 2006-03-20 19:45:18.0 -0500 +++ framework-ps.scm2006-03-25 18:25:43.875475200 -0500 @@ -42,8 +42,10 @@ (define font-list (ly:paper-fonts paper)) (define (define-font command fontname scaling) (string-append - / command { / fontname findfont - (ly:number-string scaling) output-scale div scalefont } bind def\n)) + / command { / fontname (ly:number-string scaling) output-scale div selectfont } bind def\n)) +;(string-append +; / command { / fontname findfont +; (ly:number-string scaling) output-scale div scalefont } bind def\n)) Hi, thanks for you patch. CAn you have a second look; there are some style issues, +/printletter { + currentpoint + 3 2 roll + glyphshow + moveto +} bind def +/printglyphs { + -1 1 + { + 3 mul -3 roll + printletter + rmoveto + }for +}bind def can you add some comment explaining in more detail that this is for kerning? Also, can you follow the naming convention, which is word_word iso. wordword for PS files. (I'd like to change this to word-word, some time) +(define (round2 num) + (/ (round (* 100 num)) 100)) + +(define (round4 num) + (/ (round (* 1 num)) 1)) + +(define (str4 num) + (format #f ~f (round4 num))) can you rename this to something more comprehensible? +;; s/\.\([0-9]\{-}\)0* /\1 /g + ? (format #f gsave - /~a ~a ~a output-scale div scalefont setfont\n~a grestore + /~a ~a output-scale div selectfont\n~a grestore postscript-font-name - (if cid? - /CIDFont findresource - findfont) I don't understand this? How are CID resources supposed to be loaded now? (define (named-glyph font glyph) (string-append - (ps-font-command font) setfont + (ps-font-command font) / glyph glyphshow )) While you're at it, I think it would improve readability of the SCM file when you try to replace string-append in cases like these. -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen LilyPond Software Design -- Code for Music Notation http://www.lilypond-design.com ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
On 3/28/06, Han-Wen Nienhuys [EMAIL PROTECTED] wrote: David Feuer wrote: thanks for you patch. CAn you have a second look; there are some style issues Sure. I can't deal with them right now, but I'll try to fix them up this evening. I'd like to know if it might be possible to make the backend work at a slightly higher level, which should allow much smaller files (e.g., Postscript could easily understand the concept of filled dotted quarter note in current note font with upward stem 3 staff spaces long). That's very unlikely. The internal representation is not strictly hierarchical, so it's difficult to group different objects (eg. note and stem) so they will be output together, and still be sure that all of them are processed. I've searched and searched, but I can't seem to figure out where notes and text turn into primitive objects sent to the backends. Could you point me in the right direction? Is there an explanation somewhere of the general process through which parsed Lilypond becomes printed music? You say the internal representation is not strictly hierarchical. What _is_ the internal representation? When objects get broken up for separate processing, might it be reasonable for the component pieces to point back to their parents? In any case, whatever structure the internal representation actually has would most likely be useful in the backend code. The image in my mind is an intermediate program of sorts that is compiled to create Postscript or TeX output and interpreted to create SVG output. can you add some comment explaining in more detail that this is for kerning? Actually, I was rather curious where those numbers were coming from. It might be a good idea to use separate routines for placing text, for placing noteheads, and for whatever else, rather than using just one glyph placer for all, as they really are rather different. Text tends to have a lot of letters on horizontal lines. Notes tend to be on lines or spaces in staves. Also, can you follow the naming convention, which is word_word iso. wordword for PS files. Sure. +(define (str4 num) + (format #f ~f (round4 num))) can you rename this to something more comprehensible? num-str4prec? I couldn't think of anything really good. +;; s/\.\([0-9]\{-}\)0* /\1 /g + ? Sorry. That's junk. (format #f gsave - /~a ~a ~a output-scale div scalefont setfont\n~a grestore + /~a ~a output-scale div selectfont\n~a grestore postscript-font-name - (if cid? - /CIDFont findresource - findfont) I don't understand this? How are CID resources supposed to be loaded now? According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. Unfortunately, I can't make the utf-8 regression test work either with or without my changes, so I can't be sure I got this right. (define (named-glyph font glyph) (string-append - (ps-font-command font) setfont + (ps-font-command font) / glyph glyphshow )) While you're at it, I think it would improve readability of the SCM file when you try to replace string-append in cases like these. Sure. David Feuer ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Improvements to Postscript backend (patches included)
- (if cid? - /CIDFont findresource - findfont) I don't understand this? How are CID resources supposed to be loaded now? According to the Postscript reference, selectfont can be used with CID resources as well as regular fonts. But a CID resource is completely useless for us since we don't get the corresponding CID value, AFAIK. In case Pango does the CMap resource handling (this is, we send a Unicode value and Pango returns the CID) we can enable this again. Werner, do we still need /CIDFont findresource ? It really depends on Pango... Werner ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Improvements to Postscript backend (patches included)
I made some changes to the Postscript backend, making the output more readable (especially for text), around 10% shorter, and, at least in theory, also faster to interpret. These changes are just a start, but I hope they help. I'd like to know if it might be possible to make the backend work at a slightly higher level, which should allow much smaller files (e.g., Postscript could easily understand the concept of filled dotted quarter note in current note font with upward stem 3 staff spaces long). I'm not a master of diff, so let me know if the following aren't done right. Diffs (made with -u) against the 2.8.0 source: --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/scm/framework-ps.scm 2006-03-20 19:45:18.0 -0500 +++ framework-ps.scm2006-03-25 18:25:43.875475200 -0500 @@ -42,8 +42,10 @@ (define font-list (ly:paper-fonts paper)) (define (define-font command fontname scaling) (string-append - / command { / fontname findfont - (ly:number-string scaling) output-scale div scalefont } bind def\n)) + / command { / fontname (ly:number-string scaling) output-scale div selectfont } bind def\n)) +;(string-append +; / command { / fontname findfont +; (ly:number-string scaling) output-scale div scalefont } bind def\n)) (define (standard-tex-font? x) (or (equal? (substring x 0 2) ms) --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/ps/music-drawing-routines.ps 2006-03-16 05:52:27.0 -0500 +++ music-drawing-routines.ps 2006-03-25 18:25:10.447408000 -0500 @@ -241,10 +241,7 @@ % JUNKME: Use color. /draw_white_text % text scale font { - %font - findfont - %scale - exch scalefont setfont + exch selectfont 1 setgray 0 0 moveto %-0.05 -0.05 moveto @@ -276,5 +273,19 @@ stroke } bind def +/printletter { + currentpoint + 3 2 roll + glyphshow + moveto +} bind def +/printglyphs { + -1 1 + { + 3 mul -3 roll + printletter + rmoveto + }for +}bind def %end music-drawing-routines.ps --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/scm/output-ps.scm 2006-03-07 13:14:23.0 -0500 +++ output-ps.scm 2006-03-25 18:25:34.061363200 -0500 @@ -54,6 +54,21 @@ (define (ps-encoding text) (escape-parentheses text)) +(define (round2 num) + (/ (round (* 100 num)) 100)) + +(define (round4 num) + (/ (round (* 1 num)) 1)) + +(define (str4 num) + (format #f ~f (round4 num))) + +(define (number-pair-string4 numpair) + (format #f ~f ~f (round4 (car numpair)) (round4 (cdr numpair + +(define (numbers-string4 numlist) + (apply string-append (map (lambda (x) (string-append (str4 x) )) numlist))) + ;; FIXME: lily-def (define-public (ps-string-def prefix key val) (string-append / prefix (symbol-string key) ( @@ -75,59 +90,61 @@ ;; two beziers (define (bezier-sandwich lst thick) (string-append - (string-join (map ly:number-pair-string lst) ) + (string-join (map number-pair-string4 lst) ) - (ly:number-string thick) + (str4 thick) draw_bezier_sandwich)) (define (char font i) (string-append - (ps-font-command font) setfont - (\\ (ly:inexact-string i 8) ) show)) + (ps-font-command font) ; +(\\ (ly:inexact-string i 8) ) show)) (define (circle radius thick fill) (format - ~a ~a ~a draw_circle radius thick + ~f ~f ~a draw_circle (round4 radius) (round4 thick) (if fill true false ))) (define (dashed-line thick on off dx dy) (string-append - (ly:number-string dx) - (ly:number-string dy) - (ly:number-string thick) + (str4 dx) + (str4 dy) + (str4 thick) [ - (ly:number-string on) - (ly:number-string off) + (str4 on) + (str4 off) ] 0 draw_dashed_line)) ;; what the heck is this interface ? (define (dashed-slur thick on off l) (string-append - (string-join (map ly:number-pair-string l) ) + (string-join (map number-pair-string4 l) ) - (ly:number-string thick) + (str4 thick) [ - (ly:number-string on) + (str4 on) - (ly:number-string off) + (str4 off) ] 0 draw_dashed_slur)) +;; s/\.\([0-9]\{-}\)0* /\1 /g + (define (dot x y radius) (string-append - (ly:numbers-string + (numbers-string4 (list x y radius)) draw_dot)) (define (draw-line thick x1 y1 x2 y2) (string-append 1 setlinecap 1 setlinejoin - (ly:number-string thick) setlinewidth - (ly:number-string x1) - (ly:number-string y1) moveto - (ly:number-string x2) - (ly:number-string y2) lineto stroke)) + (str4 thick) setlinewidth + (str4 x1) + (str4 y1) moveto + (str4 x2) + (str4 y2) lineto stroke)) (define (embedded-ps string) string) @@ -138,12 +155,10 @@ w-x-y-named-glyphs) (format #f gsave - /~a ~a ~a output-scale div scalefont setfont\n~a grestore + /~a ~a output-scale div selectfont\n~a grestore
Improvements to Postscript backend (patches included)
I sent this some hours ago, but haven't seen it yet. Is the mailing list broken, or just really slow? Original message: I made some changes to the Postscript backend, making the output more readable (especially for text), around 10% shorter, and, at least in theory, also faster to interpret. These changes are just a start, but I hope they help. I'd like to know if it might be possible to make the backend work at a slightly higher level, which should allow much smaller files (e.g., Postscript could easily understand the concept of filled dotted quarter note in current note font with upward stem 3 staff spaces long). I'm not a master of diff, so let me know if the following aren't done right. Diffs (made with -u) against the 2.8.0 source: --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/scm/framework-ps.scm 2006-03-20 19:45:18.0 -0500 +++ framework-ps.scm2006-03-25 18:25:43.875475200 -0500 @@ -42,8 +42,10 @@ (define font-list (ly:paper-fonts paper)) (define (define-font command fontname scaling) (string-append - / command { / fontname findfont - (ly:number-string scaling) output-scale div scalefont } bind def\n)) + / command { / fontname (ly:number-string scaling) output-scale div selectfont } bind def\n)) +;(string-append +; / command { / fontname findfont +; (ly:number-string scaling) output-scale div scalefont } bind def\n)) (define (standard-tex-font? x) (or (equal? (substring x 0 2) ms) --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/ps/music-drawing-routines.ps 2006-03-16 05:52:27.0 -0500 +++ music-drawing-routines.ps 2006-03-25 18:25:10.447408000 -0500 @@ -241,10 +241,7 @@ % JUNKME: Use color. /draw_white_text % text scale font { - %font - findfont - %scale - exch scalefont setfont + exch selectfont 1 setgray 0 0 moveto %-0.05 -0.05 moveto @@ -276,5 +273,19 @@ stroke } bind def +/printletter { + currentpoint + 3 2 roll + glyphshow + moveto +} bind def +/printglyphs { + -1 1 + { + 3 mul -3 roll + printletter + rmoveto + }for +}bind def %end music-drawing-routines.ps --- ../Installation Programs/lilypond-2.8.0-src/lilypond-2.8.0/scm/output-ps.scm 2006-03-07 13:14:23.0 -0500 +++ output-ps.scm 2006-03-25 18:25:34.061363200 -0500 @@ -54,6 +54,21 @@ (define (ps-encoding text) (escape-parentheses text)) +(define (round2 num) + (/ (round (* 100 num)) 100)) + +(define (round4 num) + (/ (round (* 1 num)) 1)) + +(define (str4 num) + (format #f ~f (round4 num))) + +(define (number-pair-string4 numpair) + (format #f ~f ~f (round4 (car numpair)) (round4 (cdr numpair + +(define (numbers-string4 numlist) + (apply string-append (map (lambda (x) (string-append (str4 x) )) numlist))) + ;; FIXME: lily-def (define-public (ps-string-def prefix key val) (string-append / prefix (symbol-string key) ( @@ -75,59 +90,61 @@ ;; two beziers (define (bezier-sandwich lst thick) (string-append - (string-join (map ly:number-pair-string lst) ) + (string-join (map number-pair-string4 lst) ) - (ly:number-string thick) + (str4 thick) draw_bezier_sandwich)) (define (char font i) (string-append - (ps-font-command font) setfont - (\\ (ly:inexact-string i 8) ) show)) + (ps-font-command font) ; +(\\ (ly:inexact-string i 8) ) show)) (define (circle radius thick fill) (format - ~a ~a ~a draw_circle radius thick + ~f ~f ~a draw_circle (round4 radius) (round4 thick) (if fill true false ))) (define (dashed-line thick on off dx dy) (string-append - (ly:number-string dx) - (ly:number-string dy) - (ly:number-string thick) + (str4 dx) + (str4 dy) + (str4 thick) [ - (ly:number-string on) - (ly:number-string off) + (str4 on) + (str4 off) ] 0 draw_dashed_line)) ;; what the heck is this interface ? (define (dashed-slur thick on off l) (string-append - (string-join (map ly:number-pair-string l) ) + (string-join (map number-pair-string4 l) ) - (ly:number-string thick) + (str4 thick) [ - (ly:number-string on) + (str4 on) - (ly:number-string off) + (str4 off) ] 0 draw_dashed_slur)) +;; s/\.\([0-9]\{-}\)0* /\1 /g + (define (dot x y radius) (string-append - (ly:numbers-string + (numbers-string4 (list x y radius)) draw_dot)) (define (draw-line thick x1 y1 x2 y2) (string-append 1 setlinecap 1 setlinejoin - (ly:number-string thick) setlinewidth - (ly:number-string x1) - (ly:number-string y1) moveto - (ly:number-string x2) - (ly:number-string y2) lineto stroke)) + (str4 thick) setlinewidth + (str4 x1) + (str4 y1) moveto + (str4 x2) + (str4 y2) lineto stroke)) (define (embedded-ps string) string) @@ -138,12