Автор: | Гость |
Дата: | 27 мар 2009 12:16 |
Заголовок сообщения: | Simple patch for draw-...-text |
Отправил письмо в рассылку, но что-то не вижу, что бы оно там появилось. Поэтому повторяю здесь: I need to draw text in bounded rect. However, functions of draw-...- text does not allow it. So, I made minor changes in this functions. Here is my patch: Код: diff --git a/text.lisp b/text.lisp
index 8fbddf3..30736bd 100644 --- a/text.lisp +++ b/text.lisp @@ -36,36 +36,39 @@ with Lisps that read source files in UTF-8 encoding.") finally (push (string-trim *delimiter-chars* (subseq string start)) result)) (nreverse result)))) -(defun draw-centered-text (x y string font font-size &optional max-width) +(defun draw-centered-text (x y string font font-size &optional max-width max-height) (pdf:in-text-mode (pdf:move-text x y) (pdf:set-font font font-size) (loop with dy = (* -1.2 font-size) for (str . rest) on (if max-width (split-text string font font-size max-width) (list string)) + for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t) for last-x = 0 then offset for offset = (* -0.5 (text-width str font font-size)) do (move-text (- offset last-x) 0) (show-text str) (when rest (pdf:move-text 0 dy))))) -(defun draw-left-text (x y string font font-size &optional max-width) +(defun draw-left-text (x y string font font-size &optional max-width max-height) (pdf:in-text-mode (pdf:move-text x y) (pdf:set-font font font-size) (loop with dy = (* -1.2 font-size) for (str . rest) on (if max-width (split-text string font font-size max-width) (list string)) + for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t) for last-x = 0 then offset for offset = (- (text-width str font font-size)) do (move-text (- offset last-x) 0) (show-text str) (when rest (pdf:move-text 0 dy))))) -(defun draw-right-text (x y string font font-size &optional max-width) +(defun draw-right-text (x y string font font-size &optional max-width max-height) (pdf:in-text-mode (pdf:move-text x y) (pdf:set-font font font-size) (loop with dy = (* -1.2 font-size) for (str . rest) on (if max-width (split-text string font font-size max-width) (list string)) + for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t) do (show-text str) (when rest (move-text 0 dy))))) | |
стр. 1 из 1 | Часовой пояс: UTC + 3 часа |
Разработка сайта Исток-Системы (www.ystok.ru) | Powered by phpBB (www.phpbb.com) |