[cl-typesetting-devel] *use-exact-char-boxes*
Marc Battyani
marc.battyani at fractalconcept.com
Fri May 12 08:10:04 UTC 2006
Dmitriy Ivanov wrote:
> | If you set *use-exact-char-boxes* to t then the characters on a line
> | will use their real bounding box like it is defined in the char
> | metrics. If it is set to t then the height of the bounding box will be
> | replaced by the value of *leading* to ensure that the lines have all
> | the same leading.
>
> Not sure. According to make-char-box, if *use-exact-char-boxes* is set to
> nil, the height is replaced by *leading*.
Yes, it's a typo in my reply, the second t should be nil instead. ;-)
> On the contrary, when it is t, the
> height is determined by ascender and descender. The same should be done
> for
> make-white-char-box, see my version below. With this approach the
> *leading*
> is really gone so I have to the following hack to fit-lines:
OK but why? I mean the *use-exact-char-boxes* is only used for the math mode
it is not supposed to be used in normal mode.
> (defmethod fit-lines ((content text-content) dx dy &optional (v-align
> :top)(advance t))
> ... ;snip
> (setf (boxes text-line)(nreverse line-boxes))
> ;; ugly hack: somehow catch and respect current *leading*
> (when *use-exact-char-boxes*
> (let ((delta-size (- *leading* (dy text-line))))
> (when (plusp delta-size)
> (incf (dy text-line) delta-size)
> (incf (internal-baseline text-line) delta-size))))
> ...)
>
> (defun make-white-char-box (char &optional (trimmable-p t))
> ;; DI: In exact mode, we must also use ascender for not making baseline
> too large.
> (if *use-exact-char-boxes*
> (multiple-value-bind (width ascender descender)
> (pdf:get-char-size char *font* *font-size*)
> (setq width (* width *text-x-scale*))
> (make-instance 'white-char-box :trimmable-p trimmable-p
> :dx width
> :dy (- ascender descender) :baseline ascender
> :max-expansion (* width 10) :max-compression (*
> width
> 0.7)
> :expansibility (* width 2.0) :compressibility
> width))
> (let ((width (* (pdf:get-char-width char *font* *font-size*)
> *text-x-scale*)))
> (make-instance 'white-char-box :trimmable-p trimmable-p
> :dx width
> :dy *leading* :baseline *font-size*
> :max-expansion (* width 10) :max-compression (*
> width
> 0.7)
> :expansibility (* width 2.0) :compressibility
> width))))
>
> | In fact generally you want to have the same leading for all the lines.
> | I added *use-exact-char-boxes* for the math mode to deal with the
> | special math characters.
>
> It would be better to have both *use-exact-char-boxes* and *leading*
> working
> together :-)
OK but again why? Using *use-exact-char-boxes* when not in math mode will
give non homogeneous leading for lines.
For instance a line with "man" will have a much smaller leading than one
with "Man p".
Marc
More information about the cl-typesetting-devel
mailing list