<div style="text-align: left;" id="result_box" dir="ltr">Hi,<br><br>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. <br>Here is my patch:<br>
<br>diff --git a/text.lisp b/text.lisp<br>index 8fbddf3..30736bd 100644<br>--- a/text.lisp<br>+++ b/text.lisp<br>@@ -36,36 +36,39 @@ with Lisps that read source files in UTF-8 encoding.")<br> finally (push (string-trim *delimiter-chars* (subseq string start)) result))<br>
(nreverse result))))<br> <br>-(defun draw-centered-text (x y string font font-size &optional max-width)<br>+(defun draw-centered-text (x y string font font-size &optional max-width max-height)<br> (pdf:in-text-mode<br>
(pdf:move-text x y)<br> (pdf:set-font font font-size)<br> (loop with dy = (* -1.2 font-size)<br> for (str . rest) on (if max-width (split-text string font font-size max-width) (list string))<br>+ for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t)<br>
for last-x = 0 then offset<br> for offset = (* -0.5 (text-width str font font-size)) do<br> (move-text (- offset last-x) 0)<br> (show-text str)<br> (when rest (pdf:move-text 0 dy)))))<br> <br>-(defun draw-left-text (x y string font font-size &optional max-width)<br>
+(defun draw-left-text (x y string font font-size &optional max-width max-height)<br> (pdf:in-text-mode<br> (pdf:move-text x y)<br> (pdf:set-font font font-size)<br> (loop with dy = (* -1.2 font-size)<br> for (str . rest) on (if max-width (split-text string font font-size max-width) (list string))<br>
+ for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t)<br> for last-x = 0 then offset<br> for offset = (- (text-width str font font-size)) do<br> (move-text (- offset last-x) 0)<br>
(show-text str)<br> (when rest (pdf:move-text 0 dy)))))<br> <br>-(defun draw-right-text (x y string font font-size &optional max-width)<br>+(defun draw-right-text (x y string font font-size &optional max-width max-height)<br>
(pdf:in-text-mode<br> (pdf:move-text x y)<br> (pdf:set-font font font-size)<br> (loop with dy = (* -1.2 font-size)<br> for (str . rest) on (if max-width (split-text string font font-size max-width) (list string))<br>
+ for line-count from 0 while (if max-height (> max-height (* -1 dy line-count)) t)<br> do<br> (show-text str)<br> (when rest (move-text 0 dy)))))<br><br><br>Moskvitin Andrey<br></div>