[cl-pdf-devel] Unicode issue

Levente Mészáros levente.meszaros at gmail.com
Thu Oct 11 08:15:07 UTC 2007


Hi Marc,

We have looked at this issue more deeply and got to the point:

(defmethod write-to-page ((string string) (encoding unicode-encoding)
&optional escape)
  (declare (ignore escape))
  (loop for char across string
        for code = (char-code char)
        do (write-char (code-char (ldb (byte 8 8) code)) *page-stream*)
           (write-char (code-char (ldb (byte 8 0) code)) *page-stream*)))

This method does not seem to handle escaping unbalanced parenthesis. I
have tried several ways to fix this. Escaping parenthesis by a
backslash either in unicode or latin-1, etc but without success. I was
looking at the resulting pdf in binary form and saw that the string is
split into two parts separated by a horizontal spacing. This causes
the unbalanced parenthesis to be present in both parts and thus
displaying those boxes.

Unfortunately I don't know much about pdf format. I had a look at the
horrible thousand pages spec, but was unable to find out how to solve
this.

A workaround for this problem is to switch to a non-unicode font when
displaying a parenthesis, because cl-pdf will write them in separate
text chunk wihtout unicode encoding and with proper escaping. This is
not so nice but works.

levy

-- 
There's no perfectoin



More information about the cl-pdf-devel mailing list