<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Hi Andrey,<br>
<br>
This is a very good idea but I think it needs some polish. :)<br>
<br>
Having a while clause before for clauses is not compliant even if most
loop implementations are OK with this.<br>
<br>
Using a line count and then multiplying by dy at each iteration is not
very efficient, it would be better to have a current-height and add dy
at each iteration or even simply to substract dy from max-height until
it goes negative (with a default huge value for max-height)<br>
<br>
BTW as the draw-...-text functions all call split text, in fact it
would be much more efficient to limit the number of lines directly in
split-text. After all what is the point of splitting a text in n lines
if we only want 2 lines for instance.<br>
<br>
Anyway, it's an interesting feature so could you rework its
implementation?<br>
<br>
Thanks,<br>
<br>
Marc <br>
<br>
</font></font>Andrey Moskvitin wrote:
<blockquote
 cite="mid:e0c33b910903260311j7cf9db77t8a202756313352e2@mail.gmail.com"
 type="cite">
  <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>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
cl-pdf-devel site list
<a class="moz-txt-link-abbreviated" href="mailto:cl-pdf-devel@common-lisp.net">cl-pdf-devel@common-lisp.net</a>
<a class="moz-txt-link-freetext" href="http://common-lisp.net/mailman/listinfo/cl-pdf-devel">http://common-lisp.net/mailman/listinfo/cl-pdf-devel</a></pre>
</blockquote>
</body>
</html>