@check_page<EOL><INDENT>def multi_cell(self, w, h, txt='<STR_LIT>', border=<NUM_LIT:0>, align='<STR_LIT>', fill=<NUM_LIT:0>, split_only=False):<DEDENT>
txt = self.normalize_text(txt)<EOL>ret = [] <EOL>cw=self.current_font['<STR_LIT>']<EOL>if(w==<NUM_LIT:0>):<EOL><INDENT>w=self.w-self.r_margin-self.x<EOL><DEDENT>wmax=(w-<NUM_LIT:2>*self.c_margin)*<NUM_LIT>/self.font_size<EOL>s=txt.replace("<STR_LIT:\r>",'<STR_LIT>')<EOL>nb=len(s)<EOL>if(nb><NUM_LIT:0> and s[nb-<NUM_LIT:1>]=="<STR_LIT:\n>"):<EOL><INDENT>nb-=<NUM_LIT:1><EOL><DEDENT>b=<NUM_LIT:0><EOL>if(border):<EOL><INDENT>if(border==<NUM_LIT:1>):<EOL><INDENT>border='<STR_LIT>'<EOL>b='<STR_LIT>'<EOL>b2='<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>b2='<STR_LIT>'<EOL>if('<STR_LIT:L>' in border):<EOL><INDENT>b2+='<STR_LIT:L>'<EOL><DEDENT>if('<STR_LIT:R>' in border):<EOL><INDENT>b2+='<STR_LIT:R>'<EOL><DEDENT>if ('<STR_LIT:T>' in border):<EOL><INDENT>b=b2+'<STR_LIT:T>'<EOL><DEDENT>else:<EOL><INDENT>b=b2<EOL><DEDENT><DEDENT><DEDENT>sep=-<NUM_LIT:1><EOL>i=<NUM_LIT:0><EOL>j=<NUM_LIT:0><EOL>l=<NUM_LIT:0><EOL>ns=<NUM_LIT:0><EOL>nl=<NUM_LIT:1><EOL>while(i<nb):<EOL><INDENT>c=s[i]<EOL>if(c=="<STR_LIT:\n>"):<EOL><INDENT>if(self.ws><NUM_LIT:0>):<EOL><INDENT>self.ws=<NUM_LIT:0><EOL>if not split_only:<EOL><INDENT>self._out('<STR_LIT>')<EOL><DEDENT><DEDENT>if not split_only:<EOL><INDENT>self.cell(w,h,substr(s,j,i-j),b,<NUM_LIT:2>,align,fill)<EOL><DEDENT>else:<EOL><INDENT>ret.append(substr(s,j,i-j))<EOL><DEDENT>i+=<NUM_LIT:1><EOL>sep=-<NUM_LIT:1><EOL>j=i<EOL>l=<NUM_LIT:0><EOL>ns=<NUM_LIT:0><EOL>nl+=<NUM_LIT:1><EOL>if(border and nl==<NUM_LIT:2>):<EOL><INDENT>b=b2<EOL><DEDENT>continue<EOL><DEDENT>if(c=='<STR_LIT:U+0020>'):<EOL><INDENT>sep=i<EOL>ls=l<EOL>ns+=<NUM_LIT:1><EOL><DEDENT>if self.unifontsubset:<EOL><INDENT>l += self.get_string_width(c) / self.font_size*<NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>l += cw.get(c,<NUM_LIT:0>)<EOL><DEDENT>if(l>wmax):<EOL><INDENT>if(sep==-<NUM_LIT:1>):<EOL><INDENT>if(i==j):<EOL><INDENT>i+=<NUM_LIT:1><EOL><DEDENT>if(self.ws><NUM_LIT:0>):<EOL><INDENT>self.ws=<NUM_LIT:0><EOL>if not split_only:<EOL><INDENT>self._out('<STR_LIT>')<EOL><DEDENT><DEDENT>if not split_only:<EOL><INDENT>self.cell(w,h,substr(s,j,i-j),b,<NUM_LIT:2>,align,fill)<EOL><DEDENT>else:<EOL><INDENT>ret.append(substr(s,j,i-j))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if(align=='<STR_LIT>'):<EOL><INDENT>if ns><NUM_LIT:1>:<EOL><INDENT>self.ws=(wmax-ls)/<NUM_LIT>*self.font_size/(ns-<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>self.ws=<NUM_LIT:0><EOL><DEDENT>if not split_only:<EOL><INDENT>self._out(sprintf('<STR_LIT>',self.ws*self.k))<EOL><DEDENT><DEDENT>if not split_only:<EOL><INDENT>self.cell(w,h,substr(s,j,sep-j),b,<NUM_LIT:2>,align,fill)<EOL><DEDENT>else:<EOL><INDENT>ret.append(substr(s,j,sep-j))<EOL><DEDENT>i=sep+<NUM_LIT:1><EOL><DEDENT>sep=-<NUM_LIT:1><EOL>j=i<EOL>l=<NUM_LIT:0><EOL>ns=<NUM_LIT:0><EOL>nl+=<NUM_LIT:1><EOL>if(border and nl==<NUM_LIT:2>):<EOL><INDENT>b=b2<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i+=<NUM_LIT:1><EOL><DEDENT><DEDENT>if(self.ws><NUM_LIT:0>):<EOL><INDENT>self.ws=<NUM_LIT:0><EOL>if not split_only:<EOL><INDENT>self._out('<STR_LIT>')<EOL><DEDENT><DEDENT>if(border and '<STR_LIT:B>' in border):<EOL><INDENT>b+='<STR_LIT:B>'<EOL><DEDENT>if not split_only:<EOL><INDENT>self.cell(w,h,substr(s,j,i-j),b,<NUM_LIT:2>,align,fill)<EOL>self.x=self.l_margin<EOL><DEDENT>else:<EOL><INDENT>ret.append(substr(s,j,i-j))<EOL><DEDENT>return ret<EOL>
Output text with automatic or explicit line breaks