[cl-pdf-devel] Unicode issue

Andrey Moskvitin archimag at gmail.com
Thu Jan 31 08:50:23 UTC 2008


Hi Marc

I have the problem with unbalanced parentheses when use cl-pdf library (in
revision 159).
This problem is solved in the cl-typesetting library (stroke.lisp):
  (when (find char "\\()" :test #'char=)
     (push #\\ string))
No, that decision is  wrong. The problem is in the cl-pdf library and should
be resolved there.


2008/1/20, Marc Battyani <marc.battyani at fractalconcept.com>:
>
> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-pdf-devel/attachments/20080131/28b2790b/attachment.html>


More information about the cl-pdf-devel mailing list