lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile-2.0 and debian


From: Antonio Ospite
Subject: Re: guile-2.0 and debian
Date: Sun, 20 Nov 2016 23:23:38 +0100

On Sun, 20 Nov 2016 22:07:39 +0100
Antonio Ospite <address@hidden> wrote:

> On Sun, 20 Nov 2016 01:12:59 +0100
> Thomas Morley <address@hidden> wrote:
> 
[...]
> > 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 "address@hidden@)" which makes the ')' not 
> really
> escaped anymore and ghostscript fails.
> 
> I'll try to come up with a better solution for this problem.
>

I think I got it this time. David?

All the previous changes to scm/framework-ps.scm can be replaced by
these:

----------------------------------------------------------------------
diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm
index a404119..da341eb 100644
--- a/scm/framework-ps.scm
+++ b/scm/framework-ps.scm
@@ -28,6 +28,10 @@
              (scm clip-region)
              (lily))

+(if (guile-v2)
+  (use-modules (rnrs bytevectors)
+               (ice-9 iconv)))
+
 (define format ergonomic-simple-format)

 (define framework-ps-module (current-module))
@@ -518,9 +522,14 @@
   (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)
+      (let* ((utf16be-bom #vu8(#xFE #xFF)))
+        (ps-quote
+          (string-append (bytevector->string utf16be-bom "ISO-8859-1")
+                         (bytevector->string (string->utf16 val 'big) 
"ISO-8859-1"))))
+      (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))
                  
----------------------------------------------------------------------

This looks a lot cleaner, no messing around with the file port encoding
anymore, so now the "format" command down in the function does not need
to be split.

It looks like that no substitutions into '?' take place when
bytevector->string is called with the "ISO-8859-1" encoding.

Ciao 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]