[cl-typesetting-devel] multi-page documents
Peter Seibel
peter at javamonkey.com
Tue Jan 20 01:15:26 UTC 2004
Peter Seibel <peter at javamonkey.com> writes:
> Peter Seibel <peter at javamonkey.com> writes:
>
> > Peter Seibel <peter at javamonkey.com> writes:
> >
> > > Here's what I hacked up. Seems to fix my problem but I don't know if
> > > it's The Right Thing.
> >
> > Hmmm. I could of sworn this was working. But now it's not. (Or there's
> > something else wrong that manifests in the same way.)
>
> Okay, looks like something else that manifests in the same way. With
> my fix in 3/4 pages are formatted properly. One page, however, still
> has the old problem--the remainder of a paragraph that crosses a page
> boundary loses it's formatting. I have no theories unless you are
> doing something about widow-and-orphans because the remainder happens
> to be two lines.
More hacking has revealed that sometimes there are styles with NIL
fonts which tends to screw things up. I'm not sure where they come
from. But this patch at least makes my stuff work again. (To replace
the previous patch.)
-Peter
Index: layout.lisp
===================================================================
--- layout.lisp (revision 3)
+++ layout.lisp (working copy)
@@ -195,8 +195,18 @@
(with-text-content (content)
(multiple-value-bind (lines boxes-left) (split-lines (boxes content) dx dy v-align)
(when lines
- (let* ((box (make-instance 'vbox :dx dx :dy dy :boxes lines :fixed-size t)))
+ (let* ((box (make-instance 'vbox :dx dx :dy dy :boxes lines :fixed-size t))
+ (last-style (find-last-style (boxes content) boxes-left)))
(do-layout box)
- (setf (boxes content) boxes-left)
- box)))))
+ (setf (boxes content) (and boxes-left (if last-style (cons last-style boxes-left) boxes-left)))
+ box))))))
+(defun find-last-style (orig-boxes boxes-left)
+ "Find the last style element in orig-boxes prior to boxes-left"
+ (loop with last-style = nil
+ for cons on orig-boxes
+ for element = (car cons)
+ while (not (eql cons boxes-left))
+ when (and (style-p element) (font element)) do
+ (setf last-style element)
+ finally (return last-style)))
--
Peter Seibel peter at javamonkey.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
More information about the cl-typesetting-devel
mailing list