Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cl-pdf: Small fixes for SBCL warning [Christian Lynbech], Salsa2 [Dan…

…iel Herring], Changed the default to no-zlib

git-svn-id: http://www.fractalconcept.com:8000/public/open-source/cl-pdf@177 9d29c65d-f3d6-0310-ab0c-b43ff62e96ec
  • Loading branch information...
commit 9d0274e921ab144c3657937ec7b9bd83fbc1c2c8 1 parent fd24e80
marc.battyani authored
View
6 chart.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -79,6 +79,8 @@
(defclass horizontal-histo-axis (histo-axis)
())
+(defgeneric axis-size (axis))
+
(defmethod axis-size (axis)
(width axis))
@@ -88,6 +90,8 @@
(defmethod axis-size ((axis vertical-histo-axis))
(height axis))
+(defgeneric draw-object (obj))
+
(defmethod draw-object (obj)
(declare (ignore obj)))
View
11 cl-pdf.asd
@@ -1,6 +1,6 @@
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -13,13 +13,14 @@
;;;Choose the zlib implementation you want to use (only one!)
(eval-when (:load-toplevel :compile-toplevel :execute)
- (pushnew :use-salza-zlib *features*)
+ ;;(pushnew :use-salza2-zlib *features*)
+ ;;(pushnew :use-salza-zlib *features*)
;;(pushnew :use-uffi-zlib *features*)
;;(pushnew :use-abcl-zlib *features*)
- ;;(pushnew :use-no-zlib *features*)
+ (pushnew :use-no-zlib *features*)
)
-#-(or use-uffi-zlib use-salza-zlib use-abcl-zlib use-no-zlib)
+#-(or use-uffi-zlib use-salza-zlib use-salza2-zlib use-abcl-zlib use-no-zlib)
(error "You must choose which zlib implementation you want to use!")
#+(and (not uffi) use-uffi-zlib)
@@ -63,4 +64,4 @@
(:file "text" :depends-on ("pdf-base"))
(:file "bar-codes" :depends-on ("pdf-geom"))
(:file "chart" :depends-on ("text" "pdf-geom")))
- :depends-on (:iterate #+use-salza-zlib :salza))
+ :depends-on (:iterate #+use-salza-zlib :salza #+use-salza2-zlib :salza2))
View
8 font-metrics.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -8,6 +8,10 @@
(defvar *font-metrics* (make-hash-table :test #'equal))
+(defgeneric font-descriptor (font-metrics &key embed errorp))
+
+(defgeneric font-type (font-metrics))
+
(defclass char-metrics ()
((code :accessor code :initarg :code)
(name :accessor name :initarg :name)
@@ -332,6 +336,8 @@
(error "Generic fonts do not have descriptors.")
nil))
+(defgeneric make-dictionary (thing &key &allow-other-keys))
+
(defmethod make-dictionary ((fm font-metrics)
&key font (encoding (encoding font)) (embed *embed-fonts*)
&allow-other-keys)
View
4 font.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -12,8 +12,6 @@
(defvar *font-cache* (make-hash-table :test #'equal))
-(defgeneric font-descriptor (font-metrics &key embed errorp))
-
(defclass font ()
((name :accessor name :initform "helvetica" :initarg :name)
(encoding :accessor encoding :initform *standard-encoding*)
View
4 pdf-base.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -385,6 +385,8 @@
(make-instance 'jpeg-image :nb-components nb-components
:width width :height height :data data))))
+(defgeneric make-jpeg-image (jpeg))
+
(defmethod make-jpeg-image (jpeg)
(make-image jpeg))
View
10 pdf.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -21,8 +21,6 @@
(defun gen-name (prefix)
(format nil "~a~d" prefix (incf *name-counter*)))
-(defgeneric make-dictionary (thing &key &allow-other-keys))
-
(defclass dictionary ()
((dict-values :accessor dict-values :initform nil :initarg :dict-values)))
@@ -434,6 +432,8 @@
:dict-values `(("/Type" . "/Annot")("/Subtype" . "/Text")
("/Rect" . ,rect)("/Contents" . ,text)))))
+(defgeneric write-object (obj &optional root-level))
+
(defmethod write-object ((obj null) &optional root-level)
(declare (ignorable root-level))
(write-string "null" *pdf-stream*))
@@ -449,6 +449,8 @@
(write-char #\Newline *pdf-stream*))
(write-line " >>" *pdf-stream*))
+(defgeneric write-stream-content (content))
+
(defmethod write-stream-content ((content string))
;; Args: content Base string, may include
;; - either one-byte codes (already converted to external format if needed)
@@ -543,6 +545,8 @@
(declare (ignorable root-level))
(write-object (reference obj)))
+(defgeneric write-document (target &optional document))
+
(defmethod write-document ((s stream) &optional (document *document*))
(let ((*xrefs* (make-array 10 :adjustable t :fill-pointer 0))
startxref
View
49 zlib.lisp
@@ -1,4 +1,4 @@
-;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details
+;;; cl-pdf copyright 2002-2009 Marc Battyani see license.txt for the details
;;; You can reach me at marc.battyani@fractalconcept.com or marc@battyani.net
;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html
@@ -102,6 +102,53 @@
(salza::finish-zlib-stream zlib-stream)
(nreverse chunks)))))
+;;; salza2 zlib
+
+#+use-salza2-zlib
+(defun load-zlib (&optional force)
+ (declare (ignore force))
+ (setf *compress-streams* t))
+
+;; string-to-octets copied from the original salza
+#+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 :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)
+ #+(or octet-characters lispworks)
+ (let* ((length (- end start))
+ (result (make-array length :element-type '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 lispworks)))
+ (error "Do not know how to convert a string to octets."))
+
+#+use-salza2-zlib
+(defun compress-string (string)
+ (let ((input (if (stringp string)
+ (string-to-octets string 0 (length string))
+ string))
+ (chunks ()))
+ (flet ((cb (octet-vector end)
+ (push (subseq octet-vector 0 end)
+ chunks)))
+ (let ((compressor
+ (make-instance 'salza2:zlib-compressor
+ :callback #'cb)))
+ (salza2:compress-octet-vector input compressor)
+ (salza2:finish-compression compressor)))
+ (reverse chunks)))
+
+
;;; no-zlib
#+use-no-zlib
(defun load-zlib (&optional force)
Please sign in to comment.
Something went wrong with that request. Please try again.