@@ 233-314 (lines=82) @@ | ||
230 | parent::Write($h,$txt,$link); |
|
231 | } |
|
232 | ||
233 | function MBWrite($h,$txt,$link) |
|
234 | { |
|
235 | //Multi-byte version of Write() |
|
236 | $cw=&$this->CurrentFont['cw']; |
|
237 | $w=$this->w-$this->rMargin-$this->x; |
|
238 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
239 | $s=str_replace("\r",'',$txt); |
|
240 | $nb=strlen($s); |
|
241 | $sep=-1; |
|
242 | $i=0; |
|
243 | $j=0; |
|
244 | $l=0; |
|
245 | $nl=1; |
|
246 | while($i<$nb) |
|
247 | { |
|
248 | //Get next character |
|
249 | $c=$s[$i]; |
|
250 | //Check if ASCII or MB |
|
251 | $ascii=(ord($c)<128); |
|
252 | if($c=="\n") |
|
253 | { |
|
254 | //Explicit line break |
|
255 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
256 | $i++; |
|
257 | $sep=-1; |
|
258 | $j=$i; |
|
259 | $l=0; |
|
260 | if($nl==1) |
|
261 | { |
|
262 | $this->x=$this->lMargin; |
|
263 | $w=$this->w-$this->rMargin-$this->x; |
|
264 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
265 | } |
|
266 | $nl++; |
|
267 | continue; |
|
268 | } |
|
269 | if(!$ascii or $c==' ') |
|
270 | $sep=$i; |
|
271 | $l+=$ascii ? $cw[$c] : 1000; |
|
272 | if($l>$wmax) |
|
273 | { |
|
274 | //Automatic line break |
|
275 | if($sep==-1 or $i==$j) |
|
276 | { |
|
277 | if($this->x>$this->lMargin) |
|
278 | { |
|
279 | //Move to next line |
|
280 | $this->x=$this->lMargin; |
|
281 | $this->y+=$h; |
|
282 | $w=$this->w-$this->rMargin-$this->x; |
|
283 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
284 | $i++; |
|
285 | $nl++; |
|
286 | continue; |
|
287 | } |
|
288 | if($i==$j) |
|
289 | $i+=$ascii ? 1 : 2; |
|
290 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
291 | } |
|
292 | else |
|
293 | { |
|
294 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
|
295 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
|
296 | } |
|
297 | $sep=-1; |
|
298 | $j=$i; |
|
299 | $l=0; |
|
300 | if($nl==1) |
|
301 | { |
|
302 | $this->x=$this->lMargin; |
|
303 | $w=$this->w-$this->rMargin-$this->x; |
|
304 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
305 | } |
|
306 | $nl++; |
|
307 | } |
|
308 | else |
|
309 | $i+=$ascii ? 1 : 2; |
|
310 | } |
|
311 | //Last chunk |
|
312 | if($i!=$j) |
|
313 | $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link); |
|
314 | } |
|
315 | ||
316 | function _putfonts() |
|
317 | { |
@@ 203-284 (lines=82) @@ | ||
200 | parent::Write($h,$txt,$link); |
|
201 | } |
|
202 | ||
203 | function MBWrite($h,$txt,$link) |
|
204 | { |
|
205 | //Multi-byte version of Write() |
|
206 | $cw=&$this->CurrentFont['cw']; |
|
207 | $w=$this->w-$this->rMargin-$this->x; |
|
208 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
209 | $s=str_replace("\r",'',$txt); |
|
210 | $nb=strlen($s); |
|
211 | $sep=-1; |
|
212 | $i=0; |
|
213 | $j=0; |
|
214 | $l=0; |
|
215 | $nl=1; |
|
216 | while($i<$nb) |
|
217 | { |
|
218 | //Get next character |
|
219 | $c=$s[$i]; |
|
220 | //Check if ASCII or MB |
|
221 | $ascii=(ord($c)<128); |
|
222 | if($c=="\n") |
|
223 | { |
|
224 | //Explicit line break |
|
225 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
226 | $i++; |
|
227 | $sep=-1; |
|
228 | $j=$i; |
|
229 | $l=0; |
|
230 | if($nl==1) |
|
231 | { |
|
232 | $this->x=$this->lMargin; |
|
233 | $w=$this->w-$this->rMargin-$this->x; |
|
234 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
235 | } |
|
236 | $nl++; |
|
237 | continue; |
|
238 | } |
|
239 | if(!$ascii or $c==' ') |
|
240 | $sep=$i; |
|
241 | $l+=$ascii ? $cw[$c] : 1000; |
|
242 | if($l>$wmax) |
|
243 | { |
|
244 | //Automatic line break |
|
245 | if($sep==-1 or $i==$j) |
|
246 | { |
|
247 | if($this->x>$this->lMargin) |
|
248 | { |
|
249 | //Move to next line |
|
250 | $this->x=$this->lMargin; |
|
251 | $this->y+=$h; |
|
252 | $w=$this->w-$this->rMargin-$this->x; |
|
253 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
254 | $i++; |
|
255 | $nl++; |
|
256 | continue; |
|
257 | } |
|
258 | if($i==$j) |
|
259 | $i+=$ascii ? 1 : 2; |
|
260 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
261 | } |
|
262 | else |
|
263 | { |
|
264 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
|
265 | $i=($s[$sep]==' ') ? $sep+1 : $sep; |
|
266 | } |
|
267 | $sep=-1; |
|
268 | $j=$i; |
|
269 | $l=0; |
|
270 | if($nl==1) |
|
271 | { |
|
272 | $this->x=$this->lMargin; |
|
273 | $w=$this->w-$this->rMargin-$this->x; |
|
274 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
275 | } |
|
276 | $nl++; |
|
277 | } |
|
278 | else |
|
279 | $i+=$ascii ? 1 : 2; |
|
280 | } |
|
281 | //Last chunk |
|
282 | if($i!=$j) |
|
283 | $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link); |
|
284 | } |
|
285 | ||
286 | function _putfonts() |
|
287 | { |