[cl-pdf-devel] Unicode issue

Marc Battyani marc.battyani at fractalconcept.com
Sun Jan 20 22:06:40 UTC 2008


Andrey Moskvitin wrote:
> >>/ The example uses a unicode font and simply puts a string into the
> />>/ output document which contains #\Space #\(  #\) and a few other
> />>/ characters. Both parenthesis and space are needed to produce the wrong
>
> />>/ pdf./
>
> > Unfortunately, the unicode integration is still in an alpha state as
> > I've never found the time to continue it :(
> > I will look at your example to see if I can make a fix for it.
>
>
> I encountered the same problem with unbalanced parentheses in text.
>
> Sample code (Gentoo Linux, sbcl-1.0.12):
>
> (pdf:load-ttu-font #P"/usr/local/fonts/arial.ufm" #P"/usr/local/fonts/arial.ttf")
>
>
> (with-open-file (out #P"/tmp/bad.pdf" :direction :output :if-exists :supersede :element-type :default :external-format :latin-1)
>   (pdf:with-document ()
>     (pdf:with-page ()
>       (pdf:in-text-mode
>
>         (pdf:move-text 20 20)
>         (pdf:set-font (pdf:get-font "ArialMT") 12)
>         (pdf::show-text "hello (")))
>     (pdf:write-document out)))
>
> The problem in the function of write-cid-string. I change it and solved the problem:
>
>   
> --- /usr/share/common-lisp/source/cl-pdf/pdf-base.lisp  2007-10-10 12:50:45.000000000 +0000
> +++ pdf-base.lisp       2007-12-29 16:38:18.000000000 +0000
> @@ -25,11 +25,14 @@
>    (write-char #\( *page-stream*)
>
>    (if (and *font* (typep (font-metrics *font*) 'ttu-font-metrics))
>        (loop for c across string do
> -          (let* ((code (char-code c))
> -                 (hi (ldb (byte 8 8) code))
> -                 (lo (ldb (byte 8 0) code)))
>
> -            (write-char (code-char hi) *page-stream*)
> -            (write-char (code-char lo) *page-stream*)))
> +           (let* ((code (char-code c))
> +              (hi (ldb (byte 8 8) code))
> +              (lo (ldb (byte 8 0) code))
>
> +              (is-bracket (or (eql c #\() (eql c #\)))))
> +             (if is-bracket (write-char #\\ *page-stream*))
> +             (write-char (code-char hi) *page-stream*)
> +             (if is-bracket (write-char #\\ *page-stream*))
>
> +             (write-char (code-char lo) *page-stream*)))
>        (princ string *page-stream*))
>    (write-string ") " *page-stream*))
>
>   
Hi Andrey,

Thanks for this.
IIRC, I corrected this in revision 152 (october 14). Is this fix a
complement to that fix or an alternative fix?

Marc





More information about the cl-pdf-devel mailing list