[cl-pdf-devel] Character encoding?

Roland Lohner lohner.roland at gmail.com
Wed Mar 5 11:47:14 UTC 2008


Hi Peter,

I am not subscribed on cl-typesetting list, so don't know if you got any answer.

Cl-pdf actually knows the font being used at the moment, and does this
translation on demand automatically. The special cl-pdf::*font* is
bound to the font being used. Pdf:get-kerning, pdf:get-char-width,
pdf:draw-spaced-strings and other functions in cl-pdf use
pdf::char-external-code indirectly, in case of a single byte encoding
and non standard character. Char-external-code does the translation
according the given character and character set. The character set is
computed as (charset (encoding *font*)). If you use tt:put-string and
tt:draw-pages, these functions call the three pdf functions mentioned
above, so there should be no encoding problems. (on sbcl I don't have
any at the moment)

This problem can occur if you try to put a character to the document,
which character is not contained in the used encoding. If you are
sure, this is not the case, than you can try to avoid encoding
problems by setting up encoding directly by font selection. For
example:

(paragraph (:font (pdf::get-font "my font name" pdf::*latin-2-encoding*))
                    (put-string "ő and ű are contained in latin-2") :eop)

Hope, I could help.

Regards,
Roland Lohner


2008/2/24, Peter Seibel <peter at gigamonkeys.com>:
> So let's say I'm using a Lisp that uses Unicode strings. I have some
>  strings that contain characters such as u+2018 and u+2019 (i.e. curly
>  quotes). If I'm using a non-Unicode font there are no font metrics for
>  those code points and I get an array index error if I try to render
>  those strings. But if I translate those to the corresponding cp-1252
>  code points. On the other hand if I *am* using a Unicode font, I want to
>  leave the strings alone. Would it make sense for cl-pdf, knowing what
>  font is being used at the moment, to do this translation for me or not,
>  as needed? If so, where's the best place for that to happen? In PUT-STRING?
>
>  -Peter
>
>
>  --
>
> Peter Seibel                     : peter at gigamonkeys.com
>  A Billion Monkeys Can't be Wrong : http://www.gigamonkeys.com/blog/
>  Practical Common Lisp            : http://www.gigamonkeys.com/book/
>  Coders at Work                   : http://www.codersatwork.com/
>  _______________________________________________
>  cl-pdf-devel site list
>  cl-pdf-devel at common-lisp.net
>  http://common-lisp.net/mailman/listinfo/cl-pdf-devel
>


More information about the cl-pdf-devel mailing list