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

Dmitriy Ivanov divanov at aha.ru
Fri Sep 7 05:25:21 UTC 2007


Hello Peter,

| I've got this simple test program which, as you can see, attempts to
| use one of the LatinModern unicode fonts and tries to render some text
| that contains a unicode emdash (code-point #x2014).
|
| (defpackage :foo (:use :cl :cl-pdf))
|
| (in-package :foo)
|
| (defun test-unicode  (&optional (file #P"foo.pdf"))
|    (pdf:with-document ()
|      (pdf:with-page ()
|        (pdf:with-outline-level ("Example"
| (pdf:register-page-reference)) (let ((font (pdf:get-font
| "LMRoman12-Regular")))   (pdf:in-text-mode
|     (pdf:set-font font 14.0)
|     (pdf:move-text 100 800)
|     (pdf:draw-text
|               (format nil "This ~c is a test." (code-char #x2014)))))))
|      (pdf:write-document file)
|      file))
|
|
| When I run this function in generates a file without error but the
| emdash is nowhere to be seen. Is this a problem with the font (which
| was loaded from an .afm file not a .ufm) or with cl-pdf or with
| something I'm doing wrong?

First, I believe that is a cl-pdf-devel question, not cl-typesetting-devel
:-)

Second, if LatinModern were a custom single-byte encoding font, I would
suggest to
map the Unicode char code to the code belonging [0-255] range as follows:

(defmethod get-char-metrics ((code (eql #x2014))
                          font (encoding custom-encoding))
  (aref (characters font) #x96))

(defmethod get-char-metrics ((char (eql #.(code-char #x2014)))
                          font (encoding custom-encoding))
  (aref (characters font) #x96))

I cannot say for Unicode fonts as I do not use ufm-files in production :-(
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru




More information about the cl-pdf-devel mailing list