[cl-pdf-devel] cl-pdf multi-platform support
Marc Battyani
marc.battyani at fractalconcept.com
Sun Mar 31 23:47:49 UTC 2013
Hi Carlos,
Thanks for your compatibility fixes.
I pushed them to github.
Marc
On 31/3/13 17:52 , Carlos Ungil wrote:
> Hello,
>
> I was able to make cl-pdf work on many lisps (tested on macos and windows only) using the following definitions for +external-format+ and *default-charset* in config.lisp (CMUCL is not listed explicitly, but it works as well):
>
> (defconstant +external-format+
> #-(or sbcl lispworks clisp allegro ccl abcl ecl) :default
> #+abcl '(:iso-8859-1 :eol-style :lf)
> #+ecl '(:latin-1 :lf)
> #+ccl :latin1
> #+sbcl :latin-1
> #+allegro :octets
> #+lispworks '(:latin-1 :eol-style :lf)
> #+clisp (ext:make-encoding :charset 'charset:iso-8859-1 :line-terminator :unix))
>
> (defvar *default-charset*
> #+(and lispworks5 win32) (ef::ef-coded-character-set win32:*multibyte-code-page-ef*)
> #-(and lispworks5 win32) *char-single-byte-codes*) ; last resort
>
> It seems that the form #+clisp (setf *default-file-encoding* ...) be safely removed. By the way, the code recently added to set data directories at runtime raises an error in clisp (probe-file can't handle directories on that platform).
>
>
> Adding :use-salza2-zlib to *features* compressed files can be created in all the implementations (ECL tested only on macos) if string-to-octets is defined in zlib.lisp as follows:
>
> #+use-salza2-zlib
> (defun string-to-octets (string start end)
> "Convert STRING to a sequence of octets, if possible."
> (declare (type string string)
> (type buffer-offset start end)
> (optimize (speed 3) (safety 0)))
> #+(and sbcl (not octet-characters))
> (sb-ext:string-to-octets string :external-format :iso-8859-1 :start start :end end)
> #+(and allegro (not octet-characters))
> (excl:string-to-octets string :external-format :octets :start start :end end :null-terminate nil)
> #+(and clisp (not octet-characters))
> (ext:convert-string-to-bytes string custom:*default-file-encoding* :start start :end end)
> #+(and ccl (not octet-characters))
> (ccl:encode-string-to-octets string :external-format :latin-1 :start start :end end)
> #+(and cmu (not octet-characters))
> (ext:string-to-octets string :external-format :iso-8859-1 :start start :end end)
> #+(or octet-characters lispworks abcl ecl)
> (let* ((length (- end start))
> (result (make-array length :element-type 'salza2::octet)))
> (loop for i fixnum from start below end
> for j fixnum from 0
> do (setf (aref result j) (char-code (aref string i))))
> result)
> #+(and (not octet-characters) (not (or sbcl allegro clisp ccl cmu lispworks abcl ecl)))
> (error "Do not know how to convert a string to octets."))
>
>
> ECL support requires as well making a couple of changes to pdf.lisp to make the conditionals #+allegro, #-allegro refer to (or allegro ecl) instead:
>
> #-(or allegro ecl) ;; line 575
> (defmethod write-document ((filename pathname) &optional (document *document*))
>
> #+(or allegro ecl) ;; line 585
> (defmethod write-document ((filename pathname) &optional (document *document*))
>
>
> I also found a minor bug in example10 (the write-document is inside the dolist loop):
> examples/examples.lisp
> @@ -551,5 +551,5 @@
> (apply #'pdf:set-rgb-fill (hsv->rgb (/ x 9.1) 1 1))
> (pdf:set-transparency (/ y 9.0) bm)
> (pdf:circle (* x 50) (* y 80) 30)
> - (pdf:fill-path))))))
> - (pdf:write-document file))))
> + (pdf:fill-path)))))))
> + (pdf:write-document file)))
>
>
> Best regards,
>
> Carlos
> _______________________________________________
> cl-pdf-devel site list
> cl-pdf-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cl-pdf-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-pdf-devel/attachments/20130331/f13ed381/attachment.html>
More information about the cl-pdf-devel
mailing list