[cl-typesetting-devel] Re: [cl-pdf-devel] Unicode issue

Marc Battyani marc.battyani at fractalconcept.com
Sun Oct 14 15:52:15 UTC 2007


Levente Mészáros wrote:
> 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.
>   
OK BTW, sorry for the long delay for the reply. :(

This function uses the normal string representation which is not very
suitable for unicode strings. The hexadecimal string encodings is more
bullet proof for this. So I modified cl-pdf so to use that hexadecimal
encoding for unicode fonts.

Seems to work for me now. Can you test it?

BTW it's probably possible to use the normal string encoding with
unicode fonts, it's just that the escape sequence is probably needed for
the stream octets rather than the string characters. Maybe somebody has
some time to look at this.

Marc





More information about the cl-typesetting-devel mailing list