| @@ -35,8 +35,11 @@ | ||
| 35 | 35 | $l=0; |
| 36 | 36 | $nl=1; |
| 37 | 37 | if (!$this->mpdf->usingCoreFont) { |
| 38 | 38 | if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $txt)) { $this->mpdf->biDirectional = true; } // *RTL* |
| 39 | + $checkCursive=false; | |
| 40 | + if ($this->mpdf->biDirectional) { $checkCursive=true; } // *RTL* | |
| 41 | + else if (isset($this->mpdf->CurrentFont['indic']) && $this->mpdf->CurrentFont['indic']) { $checkCursive=true; } // *INDIC* | |
| 39 | 42 | while($i<$nb) { |
| 40 | 43 | //Get next character |
| 41 | 44 | $c = mb_substr($s,$i,1,$this->mpdf->mb_enc ); |
| 42 | 45 | if($c == "\n") { |
| @@ -43,8 +46,10 @@ | ||
| 43 | 46 | // WORD SPACING |
| 44 | 47 | $this->mpdf->ResetSpacing(); |
| 45 | 48 | //Explicit line break |
| 46 | 49 | $tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc)); |
| 50 | + if ($directionality == 'rtl' && $align == 'J') { $align = 'R'; } // *RTL* | |
| 51 | + $this->mpdf->magic_reverse_dir($tmp, true, $directionality); // *RTL* | |
| 47 | 52 | $this->mpdf->Cell($w, $h, $tmp, 0, 2, $align, $fill, $link); |
| 48 | 53 | $i++; |
| 49 | 54 | $sep = -1; |
| 50 | 55 | $j = $i; |
| @@ -77,12 +82,16 @@ | ||
| 77 | 82 | continue; |
| 78 | 83 | } |
| 79 | 84 | if($i==$j) { $i++; } |
| 80 | 85 | $tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc)); |
| 86 | + if ($directionality == 'rtl' && $align == 'J') { $align = 'R'; } // *RTL* | |
| 87 | + $this->mpdf->magic_reverse_dir($tmp, true, $directionality); // *RTL* | |
| 81 | 88 | $this->mpdf->Cell($w, $h, $tmp, 0, 2, $align, $fill, $link); |
| 82 | 89 | } |
| 83 | 90 | else { |
| 84 | 91 | $tmp = rtrim(mb_substr($s,$j,$sep-$j,$this->mpdf->mb_enc)); |
| 92 | + if ($directionality == 'rtl' && $align == 'J') { $align = 'R'; } // *RTL* | |
| 93 | + $this->mpdf->magic_reverse_dir($tmp, true, $directionality); // *RTL* | |
| 85 | 94 | |
| 86 | 95 | if($align=='J') { |
| 87 | 96 | ////////////////////////////////////////// |
| 88 | 97 | // JUSTIFY J using Unicode fonts (Word spacing doesn't work) |
| @@ -92,10 +101,11 @@ | ||
| 92 | 101 | $len_ligne = $this->mpdf->GetStringWidth($tmp ); |
| 93 | 102 | $nb_carac = mb_strlen( $tmp , $this->mpdf->mb_enc ) ; |
| 94 | 103 | $nb_spaces = mb_substr_count( $tmp ,' ', $this->mpdf->mb_enc ) ; |
| 95 | 104 | $inclCursive=false; |
| 96 | - if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 97 | - if (preg_match("/([".$this->mpdf->pregCURSchars."])/u", $tmp)) { $inclCursive = true; } | |
| 105 | + if ($checkCursive) { | |
| 106 | + if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $tmp)) { $inclCursive = true; } // *RTL* | |
| 107 | + if (preg_match("/([".$this->mpdf->pregHIchars.$this->mpdf->pregBNchars.$this->mpdf->pregPAchars."])/u", $tmp)) { $inclCursive = true; } // *INDIC* | |
| 98 | 108 | } |
| 99 | 109 | list($charspacing,$ws) = $this->mpdf->GetJspacing($nb_carac,$nb_spaces,((($w-2) - $len_ligne) * _MPDFK),$inclCursive); |
| 100 | 110 | $this->mpdf->SetSpacing($charspacing,$ws); |
| 101 | 111 | ////////////////////////////////////////// |
| @@ -166,10 +176,10 @@ | ||
| 166 | 176 | else { |
| 167 | 177 | $tmp = substr($s, $j, $sep-$j); |
| 168 | 178 | if($align=='J') { |
| 169 | 179 | ////////////////////////////////////////// |
| 170 | - // JUSTIFY J using Unicode fonts | |
| 171 | - // WORD SPACING is not fully supported for complex scripts | |
| 180 | + // JUSTIFY J using Unicode fonts (Word spacing doesn't work) | |
| 181 | + // WORD SPACING | |
| 172 | 182 | // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly |
| 173 | 183 | $tmp = str_replace(chr(160),chr(32),$tmp ); |
| 174 | 184 | $len_ligne = $this->mpdf->GetStringWidth($tmp ); |
| 175 | 185 | $nb_carac = strlen( $tmp ) ; |
| @@ -203,16 +213,20 @@ | ||
| 203 | 213 | if($i!=$j) { |
| 204 | 214 | if ($currentx != 0) $this->mpdf->x=$currentx; |
| 205 | 215 | else $this->mpdf->x=$this->mpdf->lMargin; |
| 206 | 216 | if ($this->mpdf->usingCoreFont) { $tmp = substr($s,$j,$i-$j); } |
| 207 | - else { $tmp = mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc); } | |
| 217 | + else { | |
| 218 | + $tmp = mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc); | |
| 219 | + if ($directionality == 'rtl' && $align == 'J') { $align = 'R'; } // *RTL* | |
| 220 | + $this->mpdf->magic_reverse_dir($tmp, true, $directionality); // *RTL* | |
| 221 | + } | |
| 208 | 222 | $this->mpdf->Cell($w,$h,$tmp,0,0,$align,$fill,$link); |
| 209 | 223 | } |
| 210 | 224 | } |
| 211 | 225 | |
| 212 | 226 | |
| 213 | -function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsizePt=0, $fontstyle='', $kerning=120, $fontwidth=100, $divider='') { | |
| 214 | - if ($fontfamily || $fontstyle || $fontsizePt) $this->mpdf->SetFont($fontfamily,$fontstyle,$fontsizePt); | |
| 227 | +function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsizePt=0, $fontstyle='', $kerning=120, $fontwidth=100, $divider='') { // mPDF 5.5.23 | |
| 228 | + if ($font || $fontstyle || $fontsizePt) $this->mpdf->SetFont($fontfamily,$fontstyle,$fontsizePt); | |
| 215 | 229 | $kerning/=100; |
| 216 | 230 | $fontwidth/=100; |
| 217 | 231 | if($kerning==0) $this->mpdf->Error('Please use values unequal to zero for kerning (CircularText)'); |
| 218 | 232 | if($fontwidth==0) $this->mpdf->Error('Please use values unequal to zero for font width (CircularText)'); |
| @@ -218,8 +232,9 @@ | ||
| 218 | 232 | if($fontwidth==0) $this->mpdf->Error('Please use values unequal to zero for font width (CircularText)'); |
| 219 | 233 | $text=str_replace("\r",'',$text); |
| 220 | 234 | //circumference |
| 221 | 235 | $u=($r*2)*M_PI; |
| 236 | + // mPDF 5.5.23 | |
| 222 | 237 | $checking = true; |
| 223 | 238 | $autoset = false; |
| 224 | 239 | while($checking) { |
| 225 | 240 | $t=0; |
| @@ -336,42 +351,24 @@ | ||
| 336 | 351 | $this->mpdf->StopTransform(); |
| 337 | 352 | } |
| 338 | 353 | } |
| 339 | 354 | |
| 340 | -function Shaded_box( $text,$font='',$fontstyle='B',$szfont='',$width='70%',$style='DF',$radius=2.5,$fill='#FFFFFF',$color='#000000',$pad=2 ) { | |
| 341 | - // F (shading - no line),S (line, no shading),DF (both) | |
| 355 | +function Shaded_box( $text,$font='',$fontstyle='B',$szfont='',$width='70%',$style='DF',$radius=2.5,$fill='#FFFFFF',$color='#000000',$pad=2 ) | |
| 356 | +{ | |
| 357 | +// F (shading - no line),S (line, no shading),DF (both) | |
| 342 | 358 | if (!$font) { $font= $this->mpdf->default_font; } |
| 343 | 359 | if (!$szfont) { $szfont = ($this->mpdf->default_font_size * 1.8); } |
| 344 | 360 | |
| 345 | - $text = ' '.$text.' '; | |
| 346 | - $this->mpdf->SetFont( $font, $fontstyle, $szfont, false ); | |
| 347 | - | |
| 348 | 361 | $text = $this->mpdf->purify_utf8_text($text); |
| 349 | 362 | if ($this->mpdf->text_input_as_HTML) { |
| 350 | 363 | $text = $this->mpdf->all_entities_to_utf8($text); |
| 351 | 364 | } |
| 352 | 365 | if ($this->mpdf->usingCoreFont) { $text = mb_convert_encoding($text,$this->mpdf->mb_enc,'UTF-8'); } |
| 353 | - | |
| 354 | - | |
| 355 | 366 | // DIRECTIONALITY |
| 356 | - if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $text)) { $this->mpdf->biDirectional = true; } // *RTL* | |
| 357 | - | |
| 358 | - $textvar = 0; | |
| 359 | - $save_OTLtags = $this->mpdf->OTLtags; | |
| 360 | - $this->mpdf->OTLtags = array(); | |
| 361 | - if ($this->mpdf->useKerning) { | |
| 362 | - if ($this->mpdf->CurrentFont['haskernGPOS']) { $this->mpdf->OTLtags['Plus'] .= ' kern'; } | |
| 363 | - else { $textvar = ($textvar | FC_KERNING); } | |
| 364 | - } | |
| 365 | - // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 366 | - if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 367 | - $text = $this->mpdf->otl->applyOTL($text, $this->mpdf->CurrentFont['useOTL']); | |
| 368 | - $OTLdata = $this->mpdf->otl->OTLdata; | |
| 369 | - } | |
| 370 | - $this->mpdf->OTLtags = $save_OTLtags ; | |
| 371 | - | |
| 372 | - $this->mpdf->magic_reverse_dir($text, $this->mpdf->directionality, $OTLdata); | |
| 373 | - | |
| 367 | + $this->mpdf->magic_reverse_dir($text, true, $this->mpdf->directionality); // *RTL* | |
| 368 | + // Font-specific ligature substitution for Indic fonts | |
| 369 | + if (isset($this->mpdf->CurrentFont['indic']) && $this->mpdf->CurrentFont['indic']) $this->mpdf->ConvertIndic($text); // *INDIC* | |
| 370 | + $text = ' '.$text.' '; | |
| 374 | 371 | if (!$width) { $width = $this->mpdf->pgwidth; } else { $width=$this->mpdf->ConvertSize($width,$this->mpdf->pgwidth); } |
| 375 | 372 | $midpt = $this->mpdf->lMargin+($this->mpdf->pgwidth/2); |
| 376 | 373 | $r1 = $midpt-($width/2); //($this->mpdf->w / 2) - 40; |
| 377 | 374 | $r2 = $r1 + $width; //$r1 + 80; |
| @@ -382,16 +379,15 @@ | ||
| 382 | 379 | $loop = 0; |
| 383 | 380 | |
| 384 | 381 | while ( $loop == 0 ) |
| 385 | 382 | { |
| 386 | - $this->mpdf->SetFont( $font, $fontstyle, $szfont, false ); | |
| 387 | - $sz = $this->mpdf->GetStringWidth( $text, true, $OTLdata, $textvar ); | |
| 383 | + $this->mpdf->SetFont( $font, $fontstyle, $szfont ); | |
| 384 | + $sz = $this->mpdf->GetStringWidth( $text ); | |
| 388 | 385 | if ( ($r1+$sz) > $r2 ) |
| 389 | 386 | $szfont --; |
| 390 | 387 | else |
| 391 | 388 | $loop ++; |
| 392 | 389 | } |
| 393 | - $this->mpdf->SetFont( $font, $fontstyle, $szfont, true, true ); | |
| 394 | 390 | |
| 395 | 391 | $y2 = $this->mpdf->FontSize+($pad*2); |
| 396 | 392 | |
| 397 | 393 | $this->mpdf->SetLineWidth(0.1); |
| @@ -400,9 +396,9 @@ | ||
| 400 | 396 | $this->mpdf->SetFColor($fc); |
| 401 | 397 | $this->mpdf->SetTColor($tc); |
| 402 | 398 | $this->mpdf->RoundedRect($r1, $y1, ($r2 - $r1), $y2, $radius, $style); |
| 403 | 399 | $this->mpdf->SetX( $r1); |
| 404 | - $this->mpdf->Cell($r2-$r1, $y2, $text, 0, 1, "C",0,'',0,0,0,'M', 0, false, $OTLdata, $textvar ); | |
| 400 | + $this->mpdf->Cell($r2-$r1, $y2, $text, 0, 1, "C" ); | |
| 405 | 401 | $this->mpdf->SetY($y1+$y2+2); // +2 = mm margin below shaded box |
| 406 | 402 | $this->mpdf->Reset(); |
| 407 | 403 | } |
| 408 | 404 | |