[cl-typesetting-devel] Serious hyphenation bug
Peter Heslin
pj at heslin.eclipse.co.uk
Thu Mar 30 21:52:26 UTC 2006
On Thu, Mar 30, 2006 at 09:53:12PM +0200, Marc Battyani wrote:
> BTW even though my interest in cl-typesetting/cl-pdf has not faded, don't
> be surprised if I don't reply very fast. I have an incredible amount of
> work to do these days with several deadlines at the end of April.
> Nevertheless I plan to make a new release with all the
> patches/modifications I've got before May.
No problem. For the May release, here's a fix for the bug I reported
earlier, where hyphenations are not found for words without whitespace
after them:
(in-package :tt)
(defparameter *hyphen-trie* nix::*american-hyphen-trie*)
(defun hyphenate-string (string)
(let ((min-word-size (+ nix::*left-hyphen-minimum* nix::*right-hyphen-minimum*)))
(when (>= (length string) min-word-size)
(loop
for prev-word-end = 0 then word-end
for word-start = (position-if #'alpha-char-p string :start prev-word-end)
for word-end = (when word-start (or (position-if-not #'alpha-char-p string :start word-start)
(length string)))
while word-start
when (>= (- word-end word-start) min-word-size)
nconc (mapcar #'(lambda (n) (+ word-start n))
(nix::hyphen-find-hyphen-points
*hyphen-trie* (subseq string word-start word-end)))))))
In addition to fixing the bug, I have added the *hyphen-trie*
parameter, so that american hyphenation is not hard-coded into the
function, and you can switch languages on the fly.
In the meantime, if anyone knows how to work around the problem with
full justification and nested enumerate environments that I mentioned
in an e-mail of a few days ago, I'd be grateful to hear of it.
--
Peter Heslin (http://www.dur.ac.uk/p.j.heslin)
More information about the cl-typesetting-devel
mailing list