[cl-typesetting-devel] Hyphenation config
Klaus Weidner
kw at w-m-p.com
Sat Apr 24 03:00:14 UTC 2004
Hello,
just two minor patches today:
- make the hyphenation table selectable via nix:*active-hyphenation-table*
instead of always using the american one. (Oops, I forgot to add it
to the export list. Make that nix::*active-hyphenation-table*. Or
maybe it should be a tt:* variable anyway for consistency.)
Setting it to NIL turns hyphenation off completely. Adding
a "with-hyphenation-table" macro would make it easy to support
multilanguage text...
- the char decorations produced fairly ugly results on whitespace, since
that doesn't have proper boxes. The patch restricts those functions to
just characters.
Next, I plan to take a look at handling at least simple CSS2/FO font
handling - not being able to individually configure weight and slant
is a bit restrictive and would require extra bookkeeping in client code.
Also, the table model is turning into a bit of a nuisance, and I have to
keep table support switched off for almost all HTML pages to avoid the
dreaded "can't fit anything" fatal error. I consider this as a challenge ;-)
Another challenge is that the code uses around 300 MB working memory for
a simple 60-page document; this will need some tuning to be able to
handle more complex or longer ones on affordable hardware. But that fits
the Lisp philosophy, first get it working and then worry about
efficiency...
-Klaus
-------------- next part --------------
diff -burN q/cl-typesetting/hyphenation-fp.lisp cl-typesetting/hyphenation-fp.lisp
--- q/cl-typesetting/hyphenation-fp.lisp Sun Mar 7 16:30:35 2004
+++ cl-typesetting/hyphenation-fp.lisp Thu Apr 22 12:29:19 2004
@@ -298,5 +298,7 @@
(read-hyphen-file *american-hyphen-trie*)
(read-hyphen-file *french-hyphen-trie*)
+(defvar *active-hyphenation-table* *american-hyphen-trie*)
+
;;(trace compile-hyphen-patterns)
(setq *print-level* nil *print-length* nil)
diff -burN q/cl-typesetting/hyphenation.lisp cl-typesetting/hyphenation.lisp
--- q/cl-typesetting/hyphenation.lisp Fri Dec 19 15:37:16 2003
+++ cl-typesetting/hyphenation.lisp Thu Apr 22 12:28:29 2004
@@ -4,7 +4,7 @@
(in-package typeset)
(defun hyphenate-string (string)
-(when (> (length string) 4)
+(when (and nix::*active-hyphenation-table* (> (length string) 4))
(loop with hyphen-points
for start = 0 then (position-if #'alpha-char-p string :start (1+ end))
for end = (when start (position-if-not #'alpha-char-p string :start (1+ start)))
@@ -12,4 +12,4 @@
when (> (- end start) 4)
nconc (mapcar #'(lambda (n) (+ start n))
(nix::hyphen-find-hyphen-points
- nix::*american-hyphen-trie* (subseq string start end))))))
+ nix::*active-hyphenation-table* (subseq string start end))))))
-------------- next part --------------
diff -burN q/cl-typesetting/stroke.lisp cl-typesetting/stroke.lisp
--- q/cl-typesetting/stroke.lisp Thu Apr 22 05:23:18 2004
+++ cl-typesetting/stroke.lisp Thu Apr 22 00:41:40 2004
@@ -7,10 +7,10 @@
(defmethod stroke (box x y)
)
+;; Run these just on char boxes, the box geometry is different on whitespace.
(defmethod stroke :before ((box box) x y)
(if (and (functionp *pre-decoration*)
- (or (typep box 'char-box)
- (typep box 'white-char-box)))
+ (typep box 'char-box))
(funcall *pre-decoration*
box
x (+ y (baseline box) (offset box))
@@ -18,13 +18,11 @@
(defmethod stroke :after ((box box) x y)
(if (and (functionp *post-decoration*)
- (or (typep box 'char-box)
- (typep box 'white-char-box)))
+ (typep box 'char-box))
(funcall *post-decoration*
box
x (+ y (baseline box) (offset box))
(dx box) (- (dy box)))))
-
(defmethod stroke ((hbox hbox) x y)
(decf x (baseline hbox))
More information about the cl-typesetting-devel
mailing list