[cl-typesetting-devel] multi-page documents

Peter Seibel peter at javamonkey.com
Mon Jan 19 23:46:04 UTC 2004


"Marc Battyani" <marc.battyani at fractalconcept.com> writes:

> "Peter Seibel" <peter at javamonkey.com> writes:
> 
> ...
> > Cool. Thanks. That got me going. One oddity I noticed, at least when
> > viewing these docs with xpdf on GNU/Linux: if a paragraph gets broken
> > across a page, the text on the second page isn't colored. Any idea
> > what's up with that?
> 
> Yes it's a bug ;-)
> At the end of a draw box, the graphic state should be saved and restored for
> the next draw box.
> 
> > <time passes>
> >
> > On a probably related note, check out my first crack at typesetting my
> > book with cl-typesetting.
> >
> >   <http://www.gigamonkeys.com/book/chap1.pdf>
> 
> Great! A Lisp book in Lisp following the good old meta stuff tradition. :)
> 
> > Notice how the beginning of each page loses it's formatting. The code
> > that generates this is at:
> 
> Yes, not very pretty.
> 
> >   <http://www.gigamonkeys.com/book/my-typeset.lisp>
> >
> > The problem seems to be related to the way I'm adding the header in
> > draw-page. Poking around a bit I came up with theory that the
> > make-filled-vbox function is grabbing boxes from the main contents but
> > if the styles switch in the middle of a paragraph (as they do here
> > because of the header) they don't get put back when the lines
> > containing the rest of the paragraph are emitted. Of course that could
> > be totally wrong--just a guess really.
> >
> > Anyway, if there's some better way to add a header, please let me
> > know.
> 
> I will try to find some time to correct this. It should work.

Here's what I hacked up. Seems to fix my problem but I don't know if
it's The Right Thing.


Index: layout.lisp
===================================================================
--- layout.lisp	(revision 3)
+++ layout.lisp	(working copy)
@@ -195,8 +195,16 @@
   (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)
+	  (setf (boxes content) (and boxes-left (cons last-style 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)
+	when (style-p element) do (setf last-style element)
+	when (eql cons boxes-left) return last-style))


-Peter

-- 
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