From clkunzang at gmail.com Thu Jun 4 19:51:05 2009 From: clkunzang at gmail.com (Chhi'med Kunzang) Date: Thu, 4 Jun 2009 13:51:05 -0600 Subject: [cl-typesetting-devel] apparent hyphenation-related bug and fix Message-ID: I have encountered a weird bug, which is that when using some fonts at some sizes ("Times-Roman" at 12.0 for example), I get extra spacing inserted in the middle of words. I haven't worked out exactly when this happens and why it sometimes doesn't, but it certainly does happen sometimes. As it turns out the place where these spaces appear is where hyphens *would* appear if the line needed to be hyphenated. A quick tour through the code led me to believe that the placeholders for the hyphens were being left in and rendered as spaces. However, the code is complex, and I don't pretend to completely understand it. I came up with a simple solution which fixes my immediate problem, but I do not yet know if it may introduce new problems. I am including the relevant information here so that someone more knowledgeable can verify this is the correct solution and can incorporate it (or a better solution) into the source at some point. As far as I know, I am using the most recent version of the cl- typesetting. My version is 0.8. The solution was a simple conditional which prevents pushing the unneeded HYPHEN-BOX onto the current LINE-BOXES. From layout.lisp: (defmethod fit-lines ((content text-content) dx dy &optional (v- align :top)(advance t)) ; ((<= next-x last-x) (push box line-boxes)) ((<= next-x last-x) (unless (typep box 'hyphen-box) (push box line-boxes))) (return-lines)))) I hope that helps, if correct, and that if incorrect someone else might be able to suggest a better workaround. Thanks, Chhi'm?d From ch-lisp at bobobeach.com Tue Jun 9 05:29:49 2009 From: ch-lisp at bobobeach.com (Cyrus Harmon) Date: Mon, 8 Jun 2009 22:29:49 -0700 Subject: [cl-typesetting-devel] Fwd: make-image vs. make-jpeg-image in cl-typesetting References: <8CAA8030-F652-4320-83C8-6F028F38FC8F@bobobeach.com> Message-ID: <411D80CF-6F58-4929-BDE5-27D3F8A50825@bobobeach.com> This change doesn't seem to have hit the repo. Any interest in adding this on the part of the maintainers? thanks, cyrus Begin forwarded message: > From: Cyrus Harmon > Date: September 28, 2008 5:58:20 PM PDT > To: cl-typesetting-devel at common-lisp.net, cl-pdf-devel at common-lisp.net > Subject: [cl-typesetting-devel] make-image vs. make-jpeg-image in cl- > typesetting > > In graphics.lisp/stroke there's a call to pdf:make-jpeg-image that > could just as easily (and better yet) be call to pdf::make-image, > which unfortunately isn't exported. This would allow me to embed > PNGs in my pdfs. Any chance of seeing this changed to make-image and > exporting make-image from cl-pdf? > > thanks, > > Cyrus > > _______________________________________________ > cl-typesetting-devel site list > cl-typesetting-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-typesetting-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From divanov at aha.ru Tue Jun 9 07:48:45 2009 From: divanov at aha.ru (Dmitriy Ivanov) Date: Tue, 9 Jun 2009 11:48:45 +0400 Subject: [cl-typesetting-devel] Fwd: make-image vs. make-jpeg-image incl-typesetting References: <8CAA8030-F652-4320-83C8-6F028F38FC8F@bobobeach.com> <411D80CF-6F58-4929-BDE5-27D3F8A50825@bobobeach.com> Message-ID: <001001c9e8d6$bc1aad00$8100a8c0@digo> Cyrus Harmon wrote on Mon, 8 Jun 2009 22:29:49 -0700 09:29: | This change doesn't seem to have hit the repo. Any interest in adding | this on the part of the maintainers? | | Begin forwarded message: | | In graphics.lisp/stroke there's a call to pdf:make-jpeg-image that could | just as easily | (and better yet) be call to pdf::make-image, which unfortunately isn't | exported. This | would allow me to embed PNGs in my pdfs. Any chance of seeing this | changed to make-image and exporting make-image from cl-pdf? I use the following "versions of my own". In cl-pdf/pdf-base.lisp: (defun read-bitmap-image-file (pathname &key (type (pathname-type pathname)) header-only) (cond ((member type '("jpeg" "jpg") :test #'equalp) (read-jpeg-file pathname)) ((equalp type "png") (read-png-file pathname :header-only header-only)) (t (error "Unsupported image file type ~s." type)))) (defmethod make-image ((object pathname) &rest args &key (type (pathname-type object))) (apply 'make-image (read-bitmap-image-file object :type type) args)) In cl-typesetting/graphics.lisp: (defclass image-box (soft-box) ((file :accessor file :initform nil :initarg :file) ; pathname or ; bitmap-image (pdf-image :accessor pdf-image :initarg :pdf-image :initform nil))) (defmethod stroke ((box image-box) x y) (let ((pdf-image (or (pdf-image box) (setf (pdf-image box) (pdf:make-image (file box)))))) (pdf:add-images-to-page pdf-image) (pdf:draw-image pdf-image x (+ (- y (dy box))(offset box)) (dx box)(dy box) 0 t))) This staff has been waiting for "official approval" much longer :-) -- Sincerely, Dmitriy Ivanov lisp.ystok.ru