On Sun, 20 Nov 2016 01:12:59 +0100 Thomas Morley <thomasmorle...@gmail.com> wrote:
> Hi, > > for now I looked only at a single problem, the meta-data. (Giving me a > royal headache) > > 2016-11-19 16:05 GMT+01:00 Antonio Ospite <a...@ao2.it>: > > > The following change fixes the issue at hand: > > > > --------------------------------------------------------------------- > > diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm > > index a404119..b2b6802 100644 > > --- a/scm/framework-ps.scm > > +++ b/scm/framework-ps.scm > > @@ -28,6 +28,9 @@ > > (scm clip-region) > > (lily)) > > > > +(if (guile-v2) > > + (use-modules(rnrs bytevectors))) > > + > > (define format ergonomic-simple-format) > > > > (define framework-ps-module (current-module)) > > @@ -518,15 +521,22 @@ > > (define (metadata-encode val) > > ;; First, call ly:encode-string-for-pdf to encode the string (Latin1 or > > ;; utf-16be), then escape all parentheses and backslashes > > - ;; FIXME guile-2.0: use (string->utf16 str 'big) instead > > + ;; With guile-2.0: use (string->utf16 str 'big) instead > > + (if (guile-v2) > > + (ps-quote (utf16->string (string->utf16 val 'big))) > > Well, the line above does not make much sense, because val is > effectively returned unchanged, before ps-quote does it's work. See: > (string=? (utf16->string (string->utf16 "ちりぬるを)" 'big)) "ちりぬるを)") > --> #t > You are right, I didn't understand that the actual representation in UTF-16 was done below when setting the port encoding, and not here. I am new to guile and I am still doing something "by coincidence". > > + (ps-quote (ly:encode-string-for-pdf val)))) > > > > - (ps-quote (ly:encode-string-for-pdf val))) > > (define (metadata-lookup-output overridevar fallbackvar field) > > (let* ((overrideval (ly:modules-lookup (list header) overridevar)) > > (fallbackval (ly:modules-lookup (list header) fallbackvar)) > > (val (if overrideval overrideval fallbackval))) > > (if val > > - (format port "/~a (~a)\n" field (metadata-encode (markup->string > > val (list header))))))) > > + (begin > > + (format port "/~a (" field) > > + (set-port-encoding! port "UTF-16") > > + (format port "~a" (metadata-encode (markup->string val (list > > header)))) > > + (set-port-encoding! port "ISO-8859-1") > > + (format port ")\n"))))) > > > > (if (module? header) > > (begin > > --------------------------------------------------------------------- > > > > This is rather ugly, but encoding only the actual _value_ of the field > > in UTF-16 allows to have exactly the same output as with guile-1.8. > > Well, this example gives a gs-error again: > > \header { title = "ちりぬるを)" } \markup \null > The problem here is that, when writing to the postscript file, the escaping is (mistakenly) done before the encoding, so the escaped "\)" gets represented in UTF-16 as "^@\^@)" which makes the ')' not really escaped anymore and ghostscript fails. I'll try to come up with a better solution for this problem. Ciao, Antonio -- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing? _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel