[cl-typesetting-devel] multi-page documents

Peter Seibel peter at javamonkey.com
Wed Feb 4 23:27:52 UTC 2004


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

> "Peter Seibel" <peter at javamonkey.com> wrote:
> 
> > > 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.)
> 
> Nil in a style value means that this value is not changed by this style
> I looked again at the with-text-content macro. The style is saved at the end
> and re-used at the beginning.
> The text-style in the text-content is there precisely for this.
> 
> Have you tried the last version (rev 5) ?

Just tried it. With my patch I didn't see any instances where it
formatted things incorrectly. Without my patch, same old problem.
Below is a patch against rev 5. If you want to look at my code that is
using cl-typesetting to see if I'm doing something wrong, it's
available at:

 <http://www.gigamonkeys.com/book/my-typeset.lisp>

-Peter


Index: layout.lisp
===================================================================
--- layout.lisp	(revision 5)
+++ 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