From: Marc Battyani
Subject: cl-typesetting version 0.3 preview
Date: 
Message-ID: <blcu2g$uo6@library2.airnews.net>
New in cl-typesetting:
    some cleansing, new commands
    In table : col-span, color for tables, rows and cells.
    user-drawn-box to draw directly with cl-pdf.

As usual, the new even fancier example is here:
http://www.fractalconcept.com/ex.pdf

As for the new name for cl-typesetting. I think I need 2 names:

The first one for the library which is destined to the Lisp community so it
should include "cl" (so why not cl-typesetting finally...).

The second one for naming the typesetting application (with several user
friendly syntaxes) which could be used by lots of people, even non
developers, like it's the case with TeX. This application name should not
include "cl" or "lisp" to avoid scaring the masses... Common Lisp will come
in stealthy steps ;-)

Marc

The source for the example:

(defparameter *par1*
  "Lisp is a family...")

(defparameter *par2*
  "MacLisp improved...")

(defun draw-block (content x y dx dy rotation &optional (v-align :top))
  (pdf:with-saved-state
      (pdf:translate x y)
    (pdf:rotate rotation)
    (pdf:set-gray-fill 1)
    (pdf:basic-rect -5 0 (+ dx 10) (- dy))
    (pdf:fill-and-stroke)
    (pdf:set-gray-fill 0)
    (let ((box (make-filled-vbox content dx dy v-align)))
      (stroke box 0 0))))

;; example of extension

(defclass rotated-char-box (soft-box h-mode-mixin)
  ((boxed-char :accessor boxed-char :initarg :boxed-char)
   (rotation :accessor rotation :initarg :rotation)))

(defun put-rotated-char-string (string)
  (loop for char across string
 do (add-box (make-instance 'rotated-char-box :dx *font-size*
       :dy *font-size* :boxed-char char :offset *font-size*
       :rotation (- (random 120) 60)))))

(defmethod stroke ((box rotated-char-box) x y)
  (let ((dx (dx box))(dy (dy box))
 (width (pdf:get-char-width (boxed-char box) *font* *font-size*)))
    (pdf:with-saved-state
      (pdf:translate (+ x (* dx 0.5)) (- y (* dy 0.6)))
      (pdf:set-line-width 0.5)
      (pdf:set-gray-fill 0.8)
      (pdf:circle 0 0 (* dx 0.45))
      (pdf:fill-and-stroke)
      (pdf:set-gray-fill 0)
      (pdf:rotate (rotation box))
      (pdf:in-text-mode
       (pdf:move-text (* -0.5 width)(* -0.18 *font-size*))
       (pdf:set-font *font* (* *font-size* 0.8))
       (pdf::show-text (make-string 1 :initial-element (boxed-char box)))))))

;; a draw function for the functional rule...

(defun draw-wavelet-rule (box x0 y0)
  (let ((dx/2 (* (dx box) 0.5))
 (dy/2 (* (dy box) 0.5)))
    (pdf:with-saved-state
      (pdf:translate (+ x0 dx/2) (- y0 dy/2))
      (pdf:set-line-width 1)
      (pdf:set-color-stroke (color box))
      (pdf:move-to (- dx/2) 0)
      (loop for x from (- dx/2) by 0.2
     for y = (* dy/2 (cos (* x 0.8)) (exp (* x x -0.006)))
     while (< x dx/2)
     do (pdf:line-to x y))
      (pdf:stroke))))

;; stupid user-drawn box

(defun user-drawn-demo (box x y)
  (draw-block (compile-text ()
       (paragraph (:h-align :justified :top-margin 5 :first-line-indent 10
       :font "Times-Italic" :font-size 6.5)
           *par1*))
       x (- y (dy box)) (- (dy box) 10) (dx box) 90))

;; a chart (I will have to change this in cl-pdf: it's a real mess!)

(defun draw-pie (box x y)
  (pdf:draw-object (make-instance
      'pdf:pie-chart :x (+ x 30) :y (- y 100) :width 90 :height 90
      :serie '(12 23 65 33)
      :labels&colors
      '(("Winter" (1.0 0.0 0.0))
        ("Spring" (0.0 1.0 0.0))
        ("Summer" (0.0 0.0 1.0))
        ("Autumn" (0.0 1.0 1.0))))))

;;example document

(defun ex (&optional (file #P"/tmp/ex.pdf"))
  (pdf:with-document ()
    (pdf:with-page ()
      (pdf:with-outline-level ("Example" (pdf:register-page-reference))
 (pdf:set-line-width 0.1)
 (let ((content
        (compile-text ()
   (paragraph (:h-align :centered :font "Helvetica-Bold" :font-size 30 :color
'(0.0 0 0.8))
       "cl-typesetting" :eol
       (v-space 2)
       (hrule :dy 1)
       (with-style (:font "Times-Italic" :font-size 13)
         "The cool Common Lisp typesetting system"))
   (paragraph (:h-align :justified :top-margin 10 :first-line-indent 10
          :font "Times-Italic" :font-size 10)
         "This typesetting system's goal is to be an alternative to the TeX
typesetting system. It is written in Common Lisp and uses cl-pdf as its
backend. This will enable it to be powerful, extensible and fast. Though it
is not considered very difficult, it is already better than Word...")
   (paragraph (:h-align :centered :font "Helvetica-BoldOblique" :font-size 20
:color '(1.0 0 0))
       "Now in Color!")
   (paragraph (:h-align :centered :font "Times-Italic" :font-size 12 :color
'(0.0 0.6 0.3))
       "With user defined "
       (put-rotated-char-string "extensions") :eol
       (with-style (:font "Times-Italic" :font-size 11)
         "Support for images and functional rules" :eol
         (image :file #P"/tmp/banner.jpg" :dx 100 :dy 20)))
   (hrule :dy 15 :stroke-fn 'draw-wavelet-rule)
   (v-space 3)
   (table (:col-widths '(60 80 80) :border 0.5 :background-color '(1 1 0.8)
         :cell-padding 1 :padding 2)
   (row ()
        (cell (:background-color '(0.8 1 0.8) :col-span 3)
       (paragraph (:h-align :centered :font "Times-Italic" :font-size 12)
      "Title with a col-span of 3")))
   (row ()
        (cell (:background-color '(0.8 0.8 0.8))
       (paragraph (:h-align :left :font "Times-Italic" :font-size 9)
      "Left aligned"))
        (cell (:background-color '(0.8 0.8 0.8))
       (paragraph (:h-align :centered :font "Times-Roman" :font-size 9)
      "Centered cell content"))
        (cell (:background-color '(0.8 0.8 0.8))
       (paragraph (:h-align :right :font "Times-Bold" :font-size 9)
      "Right cell content")))
   (row ()
        (cell ()(paragraph (:h-align :left :font "Times-Italic" :font-size 9)
      "This cell content should take three lines."))
        (cell (:background-color '(1 1 1))
       (paragraph (:h-align :centered :font "Times-Italic" :font-size 9)
      "A jpeg "
      (image :file #P"/tmp/fractal.jpg" :dx 15 :dy 15 :inline t :offset 9)
      " in the text"))
        (cell ()(paragraph (:h-align :left :font "Times-Italic" :font-size
11)
      (put-rotated-char-string "common lisp is cool"))))
   (row ()
        (cell ()(paragraph (:h-align :left :font "Times-Italic" :font-size 9)
      "An example of table inside a cell"))
        (cell (:background-color '(1 1 1))
       (table (:col-widths '(14 14 21) :border 0.2
        :background-color '(0.4 0.4 0.8))
         (row () (cell () "12")(cell () "34")(cell () "567"))
         (row () (cell () "ab")(cell () "cd")(cell () "efg"))))
        (cell ()(paragraph (:h-align :left :font "Times-Italic" :font-size 9)
      "You can nest as many tables as you want, like you do in HTML."))))
   (paragraph (:h-align :justified :top-margin 5 :first-line-indent 10 :color
'(0 0 0)
          :font "Times-Roman" :font-size 10)
       *par1*)
   (user-drawn-box :dx 210 :dy 100 :stroke-fn 'user-drawn-demo) :eol
   (paragraph (:h-align :justified :top-margin 9 :first-line-indent 10
          :left-margin 20 :right-margin 20 :font "Helvetica" :font-size 9)
       *par2*)
   (paragraph (:h-align :justified :top-margin 9 :font "Helvetica-Oblique"
          :font-size 9 :first-line-indent 20)
      *par1*)
   (user-drawn-box :dx 240 :dy 100 :stroke-fn 'draw-pie) :eol
   (paragraph (:h-align :centered :font "Times-Italic" :font-size 8)
       "An example of cl-pdf pie chart inserted.")
   (paragraph (:h-align :justified :top-margin 9 :font "Helvetica-Oblique"
:font-size 9
          :left-margin 20 :right-margin 20)
       *par2*)
   (paragraph (:h-align :centered :top-margin 20 :font "Times-Bold"
:font-size 20)
       "Kerning test" :eol
       (with-style (:font "Helvetica" :font-size 40 :left-margin 20
:right-margin 20)
         "Yes, AWAY"))
   (paragraph (:h-align :centered :top-margin 20 :font "Helvetica"
          :font-size 40 :color '(0.8 0 0))
       "Warning!" :eol
       (with-style (:font "Times-Italic" :font-size 12)
         "This test pdf file has been made with an early version 0.3 of
cl-typesetting. A lot of basic features, like a correct hyphenation, are
still missing..." :eol
         (v-space 10)
         "Marc Battyani"))
   :vfill
   (hrule :dy 20 :stroke-fn 'draw-wavelet-rule :color '(0.8 0 0))
   :vfill
   (paragraph (:h-align :centered :font "Helvetica-Oblique" :font-size 8)
       "This project needs contributors. So if you are interested contact "
       (with-style (:font "Times-Italic" :font-size 9)
         ··············@fractalconcept.com") "."
       ))))
   (draw-block content 40 800 250 380 5)
   (draw-block content 50 425 250 380 -5)
   (draw-block content 330 800 250 380 -2)
   (draw-block content 310 400 250 380 2 :justified))))
    (pdf:write-document file)))

From: Pascal Costanza
Subject: Re: cl-typesetting version 0.3 preview
Date: 
Message-ID: <bld1ta$s1v$1@newsreader2.netcologne.de>
Marc Battyani wrote:

> New in cl-typesetting:
>     some cleansing, new commands
>     In table : col-span, color for tables, rows and cells.
>     user-drawn-box to draw directly with cl-pdf.
> 
> As usual, the new even fancier example is here:
> http://www.fractalconcept.com/ex.pdf
> 
> As for the new name for cl-typesetting. I think I need 2 names:
> 
> The first one for the library which is destined to the Lisp community so it
> should include "cl" (so why not cl-typesetting finally...).
> 
> The second one for naming the typesetting application (with several user
> friendly syntaxes) which could be used by lots of people, even non
> developers, like it's the case with TeX. This application name should not
> include "cl" or "lisp" to avoid scaring the masses... Common Lisp will come
> in stealthy steps ;-)

Well, what about "Stealthy Step"? ;)

(just brainstorming)


Pascal
From: Stefan Scholl
Subject: Re: cl-typesetting version 0.3 preview
Date: 
Message-ID: <10agzxzcclji8.dlg@parsec.no-spoon.de>
Name? Why not "Johannes" after Johannes Gensfleisch Gutenberg?
From: Rob Warnock
Subject: Re: cl-typesetting version 0.3 preview
Date: 
Message-ID: <NDudnYSbK-gKHueiXTWc-g@speakeasy.net>
Marc Battyani <·············@fractalconcept.com> wrote:
+---------------
| As for the new name for cl-typesetting. I think I need 2 names:
| The first one for the library which is destined to the Lisp community
| so it should include "cl" (so why not cl-typesetting finally...).
+---------------

In that case, I think "cl-typeset" would be adequate.
[Ungrammatical, perhaps, but short & sweet.]


-Rob

-----
Rob Warnock, PP-ASEL-IA		<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607