Lines Matching +full:font +full:- +full:size +(+path:plugin +path:dw2pdf) -(+path:plugin +path:dw2pdf +path:lang)

20  * Works in pixels as main units - converting to PDF units when outputing to PDF string and on returning size
187 $this->mpdf = $mpdf;
188 $this->otl = $otl;
189 $this->cssManager = $cssManager;
190 $this->imageProcessor = $imageProcessor;
191 $this->sizeConverter = $sizeConverter;
192 $this->colorConverter = $colorConverter;
193 $this->languageToFont = $languageToFont;
194 $this->scriptToLanguage = $scriptToLanguage;
196 $this->svg_font = []; // mPDF 6
197 $this->svg_gradient = [];
198 $this->svg_shadinglist = [];
199 $this->txt_data = [];
200 $this->svg_string = '';
201 $this->svg_info = [];
202 $this->svg_attribs = [];
203 $this->xbase = 0;
204 $this->ybase = 0;
205 $this->svg_error = false;
206 $this->subPathInit = false;
207 $this->dashesUsed = false;
209 $this->textlength = 0; // mPDF 5.7.4
210 $this->texttotallength = 0; // mPDF 5.7.4
211 $this->textoutput = ''; // mPDF 5.7.4
212 $this->textanchor = 'start'; // mPDF 5.7.4
213 $this->textXorigin = 0; // mPDF 5.7.4
214 $this->textYorigin = 0; // mPDF 5.7.4
215 $this->textjuststarted = false; // mPDF 5.7.4
216 $this->intext = false; // mPDF 5.7.4
218 $this->kp = 72 / $mpdf->img_dpi; // constant To convert pixels to pts/PDF units
219 $this->kf = 1; // constant To convert font size if re-mapped
220 $this->pathBBox = [];
222 $this->svg_style = [
225 'fill-opacity' => 1, // remplissage opaque par defaut
226 'fill-rule' => 'nonzero', // mode de remplissage par defaut
228 'stroke-linecap' => 'butt', // style de langle par defaut
229 'stroke-linejoin' => 'miter',
230 'stroke-miterlimit' => 4, // limite de langle par defaut
231 'stroke-opacity' => 1, // trait opaque par defaut
232 'stroke-width' => 1,
233 'stroke-dasharray' => 0,
234 'stroke-dashoffset' => 0,
239 $this->txt_style = [
242 'font-family' => $mpdf->default_font,
243 'font-size' => $mpdf->default_font_size, // ****** this is pts
244 'font-weight' => 'normal', // normal | bold
245 'font-style' => 'normal', // italic | normal
246 'text-anchor' => 'start', // alignment: start, middle, end
247 'fill-opacity' => 1, // remplissage opaque par defaut
248 'fill-rule' => 'nonzero', // mode de remplissage par defaut
250 'stroke-opacity' => 1, // trait opaque par defaut
251 'stroke-width' => 1,
265 // width and height are <lengths> - Required attributes
268 $w = $this->sizeConverter->convert($wset, $this->svg_info['w'] * (25.4 / $this->mpdf->dpi), $this->mpdf->FontSize, false);
269 $h = $this->sizeConverter->convert($hset, $this->svg_info['h'] * (25.4 / $this->mpdf->dpi), $this->mpdf->FontSize, false);
274 $w *= 1 / (25.4 / $this->mpdf->dpi);
275 $h *= 1 / (25.4 / $this->mpdf->dpi);
281 $srcpath = $this->mpdf->GetFullPath($srcpath);
285 // mPDF 6 Added $this->mpdf->interpolateImages
286 $info = $this->imageProcessor->getImage($srcpath, true, false, $orig_srcpath, $this->mpdf->interpolateImages);
324 $img_x += $w / 2 - $img_w / 2; // xMid
327 $img_x += $w - $img_w; // xMax
331 $img_y += $h / 2 - $img_h / 2; // yMid
333 $img_x += $w - $img_w; // xMax
334 $img_y += $h / 2 - $img_h / 2; // yMid
337 $img_y += $h - $img_h; // yMax
339 $img_x += $w / 2 - $img_w / 2; // xMid
340 $img_y += $h - $img_h; // yMax
342 $img_x += $w - $img_w; // xMax
343 $img_y += $h - $img_h; // yMax
345 $img_x += $w / 2 - $img_w / 2; // xMid
346 $img_y += $h / 2 - $img_h / 2; // yMid
353 $s .= sprintf('%.3F %.3F m ', ($x) * $this->kp, (-($y + $h)) * $this->kp); // start point TL before the arc
354 $s .= sprintf('%.3F %.3F l ', ($x) * $this->kp, (-($y)) * $this->kp); // line to BL
355 $s .= sprintf('%.3F %.3F l ', ($x + $w) * $this->kp, (-($y)) * $this->kp); // line to BR
356 $s .= sprintf('%.3F %.3F l ', ($x + $w) * $this->kp, (-($y + $h)) * $this->kp); // line to TR
357 $s .= sprintf('%.3F %.3F l ', ($x) * $this->kp, (-($y + $h)) * $this->kp); // line to TL
358 $s .= ' W n '; // Ends path no-op & Sets the clipping path
359 $this->svgWriteString($s);
362 $outstring = sprintf(" q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q ", $img_w * $this->kp, $img_h * $this->kp, $img_x * $this->kp, -($img_y + $img_h) * $this->kp, $info['i']);
363 $this->svgWriteString($outstring);
366 $this->svgWriteString(' Q ');
372 $n = count($this->mpdf->gradients) + 1;
387 $x_offset = $attribs['cx'] - $attribs['rx'];
388 $y_offset = $attribs['cy'] - $attribs['ry'];
392 $x_offset = $attribs['cx'] - $attribs['r'];
393 $y_offset = $attribs['cy'] - $attribs['r'];
407 $w = $maxr - $minl;
408 $h = $maxb - $mint;
412 if (is_array($this->pathBBox) && $this->pathBBox[2] > 0) {
413 $w = $this->pathBBox[2];
414 $h = $this->pathBBox[3];
415 $x_offset = $this->pathBBox[0];
416 $y_offset = $this->pathBBox[1];
418 preg_match_all('/([a-z]|[A-Z])([ ,\-.\d]+)*/', $attribs['d'], $commands, PREG_SET_ORDER);
446 $w = $maxr - $minl;
447 $h = $maxb - $mint;
452 if (!$w || $w == -999999) {
455 if (!$h || $h == -999999) {
477 $transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $vv[0], -$vv[1], -$vv[2], $vv[3], $vv[4] * $this->kp, -$vv[5] * $this->kp);
481 $t_y = -$vv[1];
486 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $tm[4] * $this->kp, $tm[5] * $this->kp);
497 $tm[0] = cos(deg2rad(-$vv[0]));
498 $tm[1] = sin(deg2rad(-$vv[0]));
499 $tm[2] = -$tm[1];
502 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $vv[1] * $this->kp, -$vv[2] * $this->kp);
506 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', -$vv[1] * $this->kp, $vv[2] * $this->kp);
509 $tm[2] = tan(deg2rad(-$vv[0]));
512 $tm[1] = tan(deg2rad(-$vv[0]));
552 if ($gradient_info['color'][$i]['offset'] < $gradient_info['color'][($i - 1)]['offset']) {
553 $gradient_info['color'][$i]['offset'] = $gradient_info['color'][($i - 1)]['offset'];
563 if (isset($gradient_info['color'][($ns - 1)]['offset']) && $gradient_info['color'][($ns - 1)]['offset'] < 1) {
564 $gradient_info['color'][] = $gradient_info['color'][($ns - 1)];
576 $gradient_info['info']['x1'] = ($gradient_info['info']['x1'] - $x_offset) / $w;
579 $gradient_info['info']['y1'] = ($gradient_info['info']['y1'] - $y_offset) / $h;
582 $gradient_info['info']['x2'] = ($gradient_info['info']['x2'] - $x_offset) / $w;
585 $gradient_info['info']['y2'] = ($gradient_info['info']['y2'] - $y_offset) / $h;
630 $angle = rad2deg(atan2(($gradient_info['info']['y2'] - $gradient_info['info']['y1']), ($gradient_info['info']['x2'] - $gradient_info['info']['x1'])));
634 $angle -= 360;
649 $d = -$useh; // height
650 $e = $usex; // x- offset
651 $f = -$usey; // -y-offset
653 $return .= sprintf('%.3F 0 0 %.3F %.3F %.3F cm ', $a * $this->kp, $d * $this->kp, $e * $this->kp, $f * $this->kp);
677 $gradient_info['color'][(($ns * $gp) + $i)] = $gradient_info['color'][(($ns * ($gp - 1)) + ($ns - $i - 1))];
678 $tmp = $gp + (1 - $offs[($ns - $i - 1)]);
687 $px1 = $x1 + ($x2 - $x1) * $tmp;
688 $py1 = $y1 + ($y2 - $y1) * $tmp;
690 $alpha = atan2($y2 - $y1, $x2 - $x1);
696 $res1 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 0, 0, 1); // $x=0 vert axis
697 $res2 = $this->testIntersect($px1, $py1, $px2, $py2, 1, 0, 1, 1); // $x=1 vert axis
698 $res3 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 0, 1, 0); // $y=0 horiz axis
699 $res4 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 1, 1, 1); // $y=1 horiz axis
714 $newarr[$i] = $gradient_info['color'][($ns - $i - 1)];
716 $tmp = -$gp + (1 - $offs[($ns - $i - 1)]);
719 $tmp = -$gp + $offs[$i];
724 $tmp = -$gp + $offs[$i];
730 $px1 = $x1 + ($x2 - $x1) * $tmp;
731 $py1 = $y1 + ($y2 - $y1) * $tmp;
733 $alpha = atan2($y2 - $y1, $x2 - $x1);
739 $res1 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 0, 0, 1); // $x=0 vert axis
740 $res2 = $this->testIntersect($px1, $py1, $px2, $py2, 1, 0, 1, 1); // $x=1 vert axis
741 $res3 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 0, 1, 0); // $y=0 horiz axis
742 $res4 = $this->testIntersect($px1, $py1, $px2, $py2, 0, 1, 1, 1); // $y=1 horiz axis
747 for ($i = ($ns - 1); $i >= 0; $i--) {
761 $range = $gradient_info['color'][count($gradient_info['color']) - 1]['offset'] - $gradient_info['color'][0]['offset'];
774 $offset = ($gradient_info['color'][$i]['offset'] - $min) / $range;
775 $this->mpdf->gradients[$n]['stops'][] = [
783 $grx1 = $x1 + ($x2 - $x1) * $gradient_info['color'][0]['offset'];
784 $gry1 = $y1 + ($y2 - $y1) * $gradient_info['color'][0]['offset'];
785 $grx2 = $x1 + ($x2 - $x1) * $gradient_info['color'][count($gradient_info['color']) - 1]['offset'];
786 $gry2 = $y1 + ($y2 - $y1) * $gradient_info['color'][count($gradient_info['color']) - 1]['offset'];
788 $this->mpdf->gradients[$n]['coords'] = [$grx1, $gry1, $grx2, $gry2];
790 $this->mpdf->gradients[$n]['colorspace'] = $gradient_info['colorspace'];
792 $this->mpdf->gradients[$n]['type'] = 2;
793 $this->mpdf->gradients[$n]['fo'] = true;
795 $this->mpdf->gradients[$n]['extend'] = ['true', 'true'];
797 $this->mpdf->gradients[$n]['trans'] = true;
810 $gradient_info['info']['x0'] = ($gradient_info['info']['x0'] - $x_offset) / $w;
813 $gradient_info['info']['y0'] = ($gradient_info['info']['y0'] - $y_offset) / $h;
816 $gradient_info['info']['x1'] = ($gradient_info['info']['x1'] - $x_offset) / $w;
819 $gradient_info['info']['y1'] = ($gradient_info['info']['y1'] - $y_offset) / $h;
896 ($gradient_info['info']['y0'] - $ay1),
897 ($gradient_info['info']['x0'] - $ax1)
903 $angle -= 360;
924 $d = -$useh; // height
925 $e = $usex; // x- offset
926 $f = -$usey; // -y-offset
930 $return .= sprintf('%.3F 0 0 %.3F %.3F %.3F cm ', $a * $this->kp, $d * $this->kp, $e * $this->kp, $f * $this->kp);
943 while (pow(($x1 - $x0), 2) + pow(($y1 - $y0), 2) >= pow($r, 2)) {
945 $x1 -= ($x1 - $x0) / 100;
946 $y1 -= ($y1 - $y0) / 100;
961 $gradient_info['color'][(($ns * $gp) + $i)] = $gradient_info['color'][(($ns * ($gp - 1)) + ($ns - $i - 1))];
962 $tmp = $gp + (1 - $offs[($ns - $i - 1)]);
973 $px = $x1 + ($x0 - $x1) * $tmp;
974 $py = $y1 + ($y0 - $y1) * $tmp;
976 $res = $this->testIntersectCircle($px, $py, $pr);
990 $range = $gradient_info['color'][count($gradient_info['color']) - 1]['offset'] - $gradient_info['color'][0]['offset'];
1003 $offset = ($gradient_info['color'][$i]['offset'] - $min) / $range;
1004 $this->mpdf->gradients[$n]['stops'][] = [
1012 $grx1 = $x1 + ($x0 - $x1) * $gradient_info['color'][0]['offset'];
1013 $gry1 = $y1 + ($y0 - $y1) * $gradient_info['color'][0]['offset'];
1014 $grx2 = $x1 + ($x0 - $x1) * $gradient_info['color'][count($gradient_info['color']) - 1]['offset'];
1015 $gry2 = $y1 + ($y0 - $y1) * $gradient_info['color'][count($gradient_info['color']) - 1]['offset'];
1017 $grr = $r * $gradient_info['color'][count($gradient_info['color']) - 1]['offset'];
1019 $this->mpdf->gradients[$n]['coords'] = [$grx1, $gry1, $grx2, $gry2, abs($grr), abs($grir)];
1021 $this->mpdf->gradients[$n]['colorspace'] = $gradient_info['colorspace'];
1023 $this->mpdf->gradients[$n]['type'] = 3;
1024 $this->mpdf->gradients[$n]['fo'] = true;
1026 $this->mpdf->gradients[$n]['extend'] = ['true', 'true'];
1028 $this->mpdf->gradients[$n]['trans'] = true;
1041 $this->svg_attribs = $attribs;
1042 if (isset($this->svg_attribs['viewBox'])) {
1043 $vb = preg_split('/\s+/is', trim($this->svg_attribs['viewBox']));
1045 $this->svg_info['x'] = $vb[0];
1046 $this->svg_info['y'] = $vb[1];
1047 $this->svg_info['w'] = $vb[2];
1048 $this->svg_info['h'] = $vb[3];
1055 $svg_w = $this->sizeConverter->convert($attribs['width']); // mm (interprets numbers as pixels)
1058 $svg_h = $this->sizeConverter->convert($attribs['height']); // mm
1064 if (isset($this->svg_info['w']) && $this->svg_info['w']) { // if 'w' set by viewBox
1065 if ($svg_w) { // if width also set, use these values to determine to set size of "pixel"
1066 $this->kp *= ($svg_w / 0.2645) / $this->svg_info['w'];
1067 $this->kf = ($svg_w / 0.2645) / $this->svg_info['w'];
1069 $this->kp *= ($svg_h / 0.2645) / $this->svg_info['h'];
1070 $this->kf = ($svg_h / 0.2645) / $this->svg_info['h'];
1077 $svg_w = $svg_h = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
1086 $this->svg_info['x'] = 0;
1087 $this->svg_info['y'] = 0;
1088 $this->svg_info['w'] = $svg_w / 0.2645; // mm->pixels
1089 $this->svg_info['h'] = $svg_h / 0.2645; // mm->pixels
1098 if (isset($this->svg_attribs['overflow'])) {
1099 if ($this->svg_attribs['overflow'] == 'hidden') {
1101 $svg_w = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['width']);
1102 $svg_h = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['height']);
1104 // $xmax = floor($this->svg_attribs['width']);
1107 // $ymax = floor(($this->svg_attribs['height'] * -1));
1108 $ymax = floor(($svg_h * -1));
1133 $tmp = count($this->svg_style) - 1;
1134 $current_style = $this->svg_style[$tmp];
1150 $transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $vv[0], -$vv[1], -$vv[2], $vv[3], $vv[4] * $this->kp, -$vv[5] * $this->kp);
1156 if ($vv[0] < 0) { $sx *= -1; } // change sign
1158 if ($vv[3] < 0) { $sy *= -1; } // change sign
1162 $t=atan2(-$vv[2],$vv[0]); // Should be the same value or skew has been applied
1165 $t *= -1;
1170 $mc = -$sx * sin($t);
1173 // $transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $ma, $mb, $mc, $md, $vv[4]*$this->kp, -$vv[5]*$this->kp);
1178 $t_y = -$vv[1];
1183 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $tm[4] * $this->kp, $tm[5] * $this->kp);
1194 $tm[0] = cos(deg2rad(-$vv[0]));
1195 $tm[1] = sin(deg2rad(-$vv[0]));
1196 $tm[2] = -$tm[1];
1199 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $vv[1] * $this->kp, -$vv[2] * $this->kp);
1203 $transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', -$vv[1] * $this->kp, $vv[2] * $this->kp);
1206 $tm[2] = tan(deg2rad(-$vv[0]));
1209 $tm[1] = tan(deg2rad(-$vv[0]));
1221 $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i", "$2", $critere_style['style']);
1228 if ((preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i", $critere_style['style'], $m) ||
1229 preg_match("/^opacity:\s*([a-z0-9.]*|none)/i", $critere_style['style'], $m)) && $m[1] != 'inherit') {
1230 $current_style['fill-opacity'] = $m[1];
1231 $current_style['stroke-opacity'] = $m[1];
1234 $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
1236 $current_style['fill-opacity'] = $tmp;
1239 $tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
1241 $current_style['fill-rule'] = $tmp;
1247 $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
1253 $tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
1255 $current_style['stroke-linecap'] = $tmp;
1258 $tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
1260 $current_style['stroke-linejoin'] = $tmp;
1263 $tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
1265 $current_style['stroke-miterlimit'] = $tmp;
1268 $tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
1270 $current_style['stroke-opacity'] = $tmp;
1273 $tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
1275 $current_style['stroke-width'] = $tmp;
1278 $tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i", "$2", $critere_style['style']);
1280 $current_style['stroke-dasharray'] = $tmp;
1283 $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
1285 $current_style['stroke-dashoffset'] = $tmp;
1291 $current_style['fill-opacity'] = $critere_style['opacity'];
1292 $current_style['stroke-opacity'] = $critere_style['opacity'];
1299 if (isset($critere_style['fill-opacity']) && $critere_style['fill-opacity'] != 'inherit') {
1300 $current_style['fill-opacity'] = $critere_style['fill-opacity'];
1303 if (isset($critere_style['fill-rule']) && $critere_style['fill-rule'] != 'inherit') {
1304 $current_style['fill-rule'] = $critere_style['fill-rule'];
1311 if (isset($critere_style['stroke-linecap']) && $critere_style['stroke-linecap'] != 'inherit') {
1312 $current_style['stroke-linecap'] = $critere_style['stroke-linecap'];
1315 if (isset($critere_style['stroke-linejoin']) && $critere_style['stroke-linejoin'] != 'inherit') {
1316 $current_style['stroke-linejoin'] = $critere_style['stroke-linejoin'];
1319 if (isset($critere_style['stroke-miterlimit']) && $critere_style['stroke-miterlimit'] != 'inherit') {
1320 $current_style['stroke-miterlimit'] = $critere_style['stroke-miterlimit'];
1323 if (isset($critere_style['stroke-opacity']) && $critere_style['stroke-opacity'] != 'inherit') {
1324 $current_style['stroke-opacity'] = $critere_style['stroke-opacity'];
1327 if (isset($critere_style['stroke-width']) && $critere_style['stroke-width'] != 'inherit') {
1328 $current_style['stroke-width'] = $critere_style['stroke-width'];
1331 if (isset($critere_style['stroke-dasharray']) && $critere_style['stroke-dasharray'] != 'inherit') {
1332 $current_style['stroke-dasharray'] = $critere_style['stroke-dasharray'];
1334 if (isset($critere_style['stroke-dashoffset']) && $critere_style['stroke-dashoffset'] != 'inherit') {
1335 $current_style['stroke-dashoffset'] = $critere_style['stroke-dashoffset'];
1359 if (isset($this->svg_gradient[$id_gradient])) {
1360 $fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element);
1370 $col = $this->colorConverter->convert($critere_style['color'], $this->mpdf->PDFAXwarnings);
1373 $critere_style['fill-opacity'] = ord($col[4] / 100);
1376 $critere_style['fill-opacity'] = ord($col[5] / 100);
1378 $path_style .= $this->mpdf->SetFColor($col, true) . ' ';
1382 $col = $this->colorConverter->convert($critere_style['fill'], $this->mpdf->PDFAXwarnings);
1385 $critere_style['fill-opacity'] = ord($col[4] / 100);
1388 $critere_style['fill-opacity'] = ord($col[5] / 100);
1390 $path_style .= $this->mpdf->SetFColor($col, true) . ' ';
1399 if (isset($this->svg_gradient[$id_gradient])) {
1400 $fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element);
1411 $col = $this->colorConverter->convert($critere_style['color'], $this->mpdf->PDFAXwarnings);
1414 $critere_style['stroke-opacity'] = ord($col[4] / 100);
1417 $critere_style['stroke-opacity'] = ord($col[5] / 100);
1419 $path_style .= $this->mpdf->SetDColor($col, true) . ' ';
1421 $lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
1422 $path_style .= sprintf('%.3F w ', $lw * $this->kp);
1425 $col = $this->colorConverter->convert($critere_style['stroke'], $this->mpdf->PDFAXwarnings);
1430 $critere_style['stroke-opacity'] = ord($col[4] / 100);
1433 $critere_style['stroke-opacity'] = ord($col[5] / 100);
1435 $path_style .= $this->mpdf->SetDColor($col, true) . ' ';
1437 $lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
1438 $path_style .= sprintf('%.3F w ', $lw * $this->kp);
1444 if ($critere_style['stroke-linejoin'] == 'miter') {
1446 } elseif ($critere_style['stroke-linejoin'] == 'round') {
1448 } elseif ($critere_style['stroke-linejoin'] == 'bevel') {
1452 if ($critere_style['stroke-linecap'] == 'butt') {
1454 } elseif ($critere_style['stroke-linecap'] == 'round') {
1456 } elseif ($critere_style['stroke-linecap'] == 'square') {
1460 if (isset($critere_style['stroke-miterlimit'])) {
1461 if ($critere_style['stroke-miterlimit'] == 'none') {
1462 } elseif (preg_match('/^[\d.]+$/', $critere_style['stroke-miterlimit'])) {
1463 $path_style .= sprintf('%.2F M ', $critere_style['stroke-miterlimit']);
1467 if (isset($critere_style['stroke-dasharray'])) {
1470 $d = preg_split('/(,\s?|\s)/', $critere_style['stroke-dasharray']);
1488 $arr .= sprintf('%.3F %.3F ', $d[$i] * $this->kp, $d[$i + 1] * $this->kp);
1491 if (isset($critere_style['stroke-dashoffset'])) {
1492 $off = $critere_style['stroke-dashoffset'] + 0;
1495 $path_style .= sprintf('[%s] %.3F d ', $arr, $off * $this->kp);
1500 if ($critere_style['fill-rule'] == 'evenodd') {
1506 if (isset($critere_style['fill-opacity'])) {
1508 if ($critere_style['fill-opacity'] == 0) {
1510 } elseif ($critere_style['fill-opacity'] > 1) {
1512 } elseif ($critere_style['fill-opacity'] > 0) {
1513 $opacity = $critere_style['fill-opacity'];
1514 } elseif ($critere_style['fill-opacity'] < 0) {
1517 $gs = $this->mpdf->AddExtGState(['ca' => $opacity, 'BM' => '/Normal']);
1518 $this->mpdf->extgstates[$gs]['fo'] = true;
1522 if (isset($critere_style['stroke-opacity'])) {
1524 if ($critere_style['stroke-opacity'] == 0) {
1526 } elseif ($critere_style['stroke-opacity'] > 1) {
1528 } elseif ($critere_style['stroke-opacity'] > 0) {
1529 $opacity = $critere_style['stroke-opacity'];
1530 } elseif ($critere_style['stroke-opacity'] < 0) {
1533 $gs = $this->mpdf->AddExtGState(['CA' => $opacity, 'BM' => '/Normal']);
1534 $this->mpdf->extgstates[$gs]['fo'] = true;
1566 $minl = $this->pathBBox[0];
1567 $mint = $this->pathBBox[1];
1568 $maxr = $this->pathBBox[2] + $this->pathBBox[0];
1569 $maxb = $this->pathBBox[3] + $this->pathBBox[1];
1571 $start = [$this->xbase, -$this->ybase];
1573 // taken from https://github.com/PhenX/php-svg-lib/blob/master/src/Svg/Tag/Path.php#L47
1574 // Handle args like: a5.38022,5.38022,0,0,1-2.4207.72246,4.50524,4.50524,0,0,1-3.12681-1.33942,9.67442,9.67442,0,0,1-2.38273-3.016,1.87506,1.87506,0,0,1,.34979-2.43562
1575 preg_match_all('/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/i', $arguments, $a, PREG_PATTERN_ORDER);
1601 $pdfx = ($this->xbase + $x);
1602 $pdfy = ($this->ybase - $y);
1603 $this->xbase += $x;
1604 $this->ybase += -$y;
1609 $pdfy = -$y;
1610 $this->xbase = $x;
1611 $this->ybase = -$y;
1614 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1618 $mint = min($mint, -$pdf_pt['y']);
1619 $maxb = max($maxb, -$pdf_pt['y']);
1622 $path_cmd .= sprintf('%.3F %.3F m ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1624 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1628 if ($this->subPathInit) {
1629 $this->spxstart = $this->xbase;
1630 $this->spystart = $this->ybase;
1631 $this->subPathInit = false;
1646 $pdfx = ($this->xbase + $x);
1647 $pdfy = ($this->ybase - $y);
1648 $this->xbase += $x;
1649 $this->ybase += -$y;
1654 $pdfy = -$y;
1655 $this->xbase = $x;
1656 $this->ybase = -$y;
1660 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1664 $mint = min($mint, -$pdf_pt['y']);
1665 $maxb = max($maxb, -$pdf_pt['y']);
1667 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1681 $pdfx = ($this->xbase + $x);
1682 $pdfy = ($this->ybase - $y);
1683 $this->xbase += $x;
1684 $this->ybase += -$y;
1688 $y = -$this->ybase;
1690 $pdfy = -$y;
1691 $this->xbase = $x;
1692 $this->ybase = -$y;
1696 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1699 $mint = min($mint, -$pdf_pt['y']);
1700 $maxb = max($maxb, -$pdf_pt['y']);
1701 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1715 $pdfx = ($this->xbase + $x);
1716 $pdfy = ($this->ybase - $y);
1717 $this->xbase += $x;
1718 $this->ybase += -$y;
1722 $x = $this->xbase;
1724 $pdfy = -$y;
1725 $this->xbase = $x;
1726 $this->ybase = -$y;
1730 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1733 $mint = min($mint, -$pdf_pt['y']);
1734 $maxb = max($maxb, -$pdf_pt['y']);
1735 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1745 if (!($this->lastcommand == 'C' || $this->lastcommand == 'c' || $this->lastcommand == 'S' || $this->lastcommand == 's')) {
1746 $this->lastcontrolpoints = [0, 0];
1751 $x1 = $this->lastcontrolpoints[0];
1752 $y1 = $this->lastcontrolpoints[1];
1762 $pdfx1 = ($this->xbase + $x1);
1763 $pdfy1 = ($this->ybase - $y1);
1764 $pdfx2 = ($this->xbase + $x2);
1765 $pdfy2 = ($this->ybase - $y2);
1766 $pdfx = ($this->xbase + $x);
1767 $pdfy = ($this->ybase - $y);
1768 $this->xbase += $x;
1769 $this->ybase += -$y;
1773 $pdfx1 = $this->xbase + $x1;
1774 $pdfy1 = $this->ybase - $y1;
1776 $pdfy2 = -$y2;
1778 $pdfy = -$y;
1779 $this->xbase = $x;
1780 $this->ybase = -$y;
1784 $this->lastcontrolpoints = [($pdfx - $pdfx2), -($pdfy - $pdfy2)]; // mPDF 4.4.003 always relative
1786 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1788 $curves = [$pdfx1, -$pdfy1, $pdfx2, -$pdfy2, $pdfx, -$pdfy];
1789 $bx = $this->computeBezierBoundingBox($start, $curves);
1796 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1798 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $pdfx1 * $this->kp, $pdfy1 * $this->kp, $pdfx2 * $this->kp, $pdfy2 * $this->kp, $pdfx * $this->kp, $pdfy * $this->kp);
1817 $pdfx1 = ($this->xbase + $x1);
1818 $pdfy1 = ($this->ybase - $y1);
1819 $pdfx2 = ($this->xbase + $x2);
1820 $pdfy2 = ($this->ybase - $y2);
1821 $pdfx = ($this->xbase + $x);
1822 $pdfy = ($this->ybase - $y);
1823 $this->xbase += $x;
1824 $this->ybase += -$y;
1829 $pdfy1 = -$y1;
1831 $pdfy2 = -$y2;
1833 $pdfy = -$y;
1834 $this->xbase = $x;
1835 $this->ybase = -$y;
1839 $this->lastcontrolpoints = [($pdfx - $pdfx2), -($pdfy - $pdfy2)]; // mPDF 4.4.003 always relative
1840 // $pdf_pt2 = $this->svg_overflow($pdfx2,$pdfy2);
1841 // $pdf_pt1 = $this->svg_overflow($pdfx1,$pdfy1);
1842 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1844 $curves = [$pdfx1, -$pdfy1, $pdfx2, -$pdfy2, $pdfx, -$pdfy];
1845 $bx = $this->computeBezierBoundingBox($start, $curves);
1852 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1854 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $pdfx1 * $this->kp, $pdfy1 * $this->kp, $pdfx2 * $this->kp, $pdfy2 * $this->kp, $pdfx * $this->kp, $pdfy * $this->kp);
1871 $pdfx = ($this->xbase + $x);
1872 $pdfy = ($this->ybase - $y);
1874 $pdfx1 = ($this->xbase + ($x1 * 2 / 3));
1875 $pdfy1 = ($this->ybase - ($y1 * 2 / 3));
1878 $pdfy2 = $pdfy1 + 1 / 3 * (-$y);
1880 $this->xbase += $x;
1881 $this->ybase += -$y;
1886 $pdfy = -$y;
1888 $pdfx1 = ($this->xbase + (($x1 - $this->xbase) * 2 / 3));
1889 $pdfy1 = ($this->ybase - (($y1 + $this->ybase) * 2 / 3));
1891 $pdfx2 = ($x + (($x1 - $x) * 2 / 3));
1892 $pdfy2 = (-$y - (($y1 - $y) * 2 / 3));
1895 $pdfx2 = $pdfx1 + 1 / 3 * ($x - $this->xbase);
1896 $pdfy2 = $pdfy1 + 1 / 3 * (-$y - $this->ybase);
1898 $this->xbase = $x;
1899 $this->ybase = -$y;
1903 $this->lastcontrolpoints = [($pdfx - $pdfx2), -($pdfy - $pdfy2)]; // mPDF 4.4.003 always relative
1905 $pdf_pt = $this->svg_overflow($pdfx, $pdfy);
1907 $curves = [$pdfx1, -$pdfy1, $pdfx2, -$pdfy2, $pdfx, -$pdfy];
1908 $bx = $this->computeBezierBoundingBox($start, $curves);
1915 $path_cmd .= sprintf('%.3F %.3F l ', $pdf_pt['x'] * $this->kp, $pdf_pt['y'] * $this->kp);
1917 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $pdfx1 * $this->kp, $pdfy1 * $this->kp, $pdfx2 * $this->kp, $pdfy2 * $this->kp, $pdfx * $this->kp, $pdfy * $this->kp);
1925 if (!($this->lastcommand == 'Q' || $this->lastcommand == 'q' || $this->lastcommand == 'T' || $this->lastcommand == 't')) {
1926 $this->lastcontrolpoints = [0, 0];
1934 $x1 = $this->lastcontrolpoints[0];
1935 $y1 = $this->lastcontrolpoints[1];
1938 $pdfx = ($this->xbase + $x);
1939 $pdfy = ($this->ybase - $y);
1941 $pdfx1 = ($this->xbase + ($x1));
1942 $pdfy1 = ($this->ybase - ($y1));
1945 $pdfy2 = $pdfy1 + 1 / 3 * (-$y);
1947 $this->xbase += $x;
1948 $this->ybase += -$y;
1953 $pdfy = -$y;
1955 $pdfx1 = ($this->xbase + ($x1));
1956 $pdfy1 = ($this->ybase - ($y1));
1959 $pdfx2 = $pdfx1 + 1 / 3 * ($x - $this->xbase);
1960 $pdfy2 = $pdfy1 + 1 / 3 * (-$y - $this->ybase);
1962 $this->xbase = $x;
1963 $this->ybase = -$y;
1966 $this->lastcontrolpoints = [($pdfx - $pdfx2), -($pdfy - $pdfy2)]; // mPDF 4.4.003 always relative
1968 $curves = [$pdfx1, -$pdfy1, $pdfx2, -$pdfy2, $pdfx, -$pdfy];
1969 $bx = $this->computeBezierBoundingBox($start, $curves);
1975 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $pdfx1 * $this->kp, $pdfy1 * $this->kp, $pdfx2 * $this->kp, $pdfy2 * $this->kp, $pdfx * $this->kp, $pdfy * $this->kp);
1987 // x-axis-rotation
1996 $x1 = $this->xbase;
1997 $y1 = -$this->ybase;
2000 $x2 = $this->xbase + $x2;
2001 $y2 = -$this->ybase + $y2;
2002 $this->xbase += isset($a[$i + 5]) ? $a[$i + 5] : 0;
2003 $this->ybase += isset($a[$i + 6]) ? -$a[$i + 6] : 0;
2005 $this->xbase = $x2;
2006 $this->ybase = -$y2;
2009 list($pcmd, $bounds) = $this->Arcto($x1, $y1, $x2, $y2, $rx, $ry, $angle, $largeArcFlag, $sweepFlag);
2026 $this->subPathInit = true;
2028 $this->xbase = $this->spxstart;
2029 $this->ybase = $this->spystart;
2035 $this->subPathInit = false;
2038 $this->lastcommand = $command;
2041 $this->pathBBox[0] = $minl;
2042 $this->pathBBox[1] = $mint;
2043 $this->pathBBox[2] = $maxr - $this->pathBBox[0];
2044 $this->pathBBox[3] = $maxb - $this->pathBBox[1];
2054 // 1. Treat out-of-range parameters as described in
2071 $rx = -$rx;
2075 $ry = -$ry;
2083 $x1dash = $cosPhi * ($x1 - $x2) / 2.0 + $sinPhi * ($y1 - $y2) / 2.0;
2084 $y1dash = -$sinPhi * ($x1 - $x2) / 2.0 + $cosPhi * ($y1 - $y2) / 2.0;
2086 $numerator = $rx * $rx * $ry * $ry - $rx * $rx * $y1dash * $y1dash - $ry * $ry * $x1dash * $x1dash;
2094 // -> find factor s, such that numerator' with rx'=s*rx and
2096 $s = sqrt(1.0 - $numerator / ($rx * $rx * $ry * $ry));
2103 $root = ($largeArcFlag == $sweepFlag ? -1.0 : 1.0) * sqrt($numerator / ($rx * $rx * $y1dash * $y1dash + $ry * $ry * $x1dash * $x1dash));
2107 $cydash = -$root * $ry * $x1dash / $rx;
2109 $cx = $cosPhi * $cxdash - $sinPhi * $cydash + ($x1 + $x2) / 2.0;
2113 $theta1 = $this->CalcVectorAngle(1.0, 0.0, ($x1dash - $cxdash) / $rx, ($y1dash - $cydash) / $ry);
2114 $dtheta = $this->CalcVectorAngle(($x1dash - $cxdash) / $rx, ($y1dash - $cydash) / $ry, (-$x1dash - $cxdash) / $rx, (-$y1dash - $cydash) / $ry);
2117 $dtheta -= 2.0 * M_PI;
2139 $xe = $cosPhi * $rx * $cosTheta2 - $sinPhi * $ry * $sinTheta2 + $cx;
2143 $dx1 = $t * ( - $cosPhi * $rx * $sinTheta1 - $sinPhi * $ry * $cosTheta1);
2144 $dy1 = $t * ( - $sinPhi * $rx * $sinTheta1 + $cosPhi * $ry * $cosTheta1);
2147 $dye = $t * ( $sinPhi * $rx * $sinTheta2 - $cosPhi * $ry * $cosTheta2);
2168 $path .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $cpx1 * $this->kp, -$cpy1 * $this->kp, $cpx2 * $this->kp, -$cpy2 * $this->kp, $x2 * $this->kp, -$y2 * $this->kp) . "\n";
2184 return ($tb - $ta);
2187 return (6.28318530718 - ($ta - $tb));
2190 function ConvertSVGSizePixels($size = 5, $maxsize = 'x')
2193 // e.g. $w = $this->ConvertSVGSizePixels($arguments['w'],$this->svg_info['w']*(25.4/$this->mpdf->dpi));
2194 // usefontsize - setfalse for e.g. margins - will ignore fontsize for % values
2200 $maxsize = $this->svg_info['h'];
2202 $maxsize = $this->svg_info['w'];
2205 $maxsize *= (25.4 / $this->mpdf->dpi); // convert pixels to mm
2206 $fontsize = $this->mpdf->FontSize / $this->kf;
2209 $size = $this->sizeConverter->convert($size, $maxsize, $fontsize, false) * 1 / (25.4 / $this->mpdf->dpi);
2211 return $size;
2214 function ConvertSVGSizePts($size = 5)
2216 // usefontsize - setfalse for e.g. margins - will ignore fontsize for % values
2220 $maxsize = $this->mpdf->FontSize;
2223 $size = $this->sizeConverter->convert($size, $maxsize, false, true) * 72 / 25.4;
2225 return $size;
2234 $x = $this->ConvertSVGSizePixels($arguments['x'], 'x'); // mPDF 4.4.003
2235 $y = $this->ConvertSVGSizePixels($arguments['y'], 'y'); // mPDF 4.4.003
2236 $h = $this->ConvertSVGSizePixels($arguments['h'], 'y'); // mPDF 4.4.003
2237 $w = $this->ConvertSVGSizePixels($arguments['w'], 'x'); // mPDF 4.4.003
2238 $rx = $this->ConvertSVGSizePixels($arguments['rx'], 'x'); // mPDF 4.4.003
2239 $ry = $this->ConvertSVGSizePixels($arguments['ry'], 'y'); // mPDF 4.4.003
2261 $path_cmd = sprintf('%.3F %.3F m ', ($x * $this->kp), -($y * $this->kp));
2262 $path_cmd .= sprintf('%.3F %.3F l ', (($x + $w) * $this->kp), -($y * $this->kp));
2263 $path_cmd .= sprintf('%.3F %.3F l ', (($x + $w) * $this->kp), -(($y + $h) * $this->kp));
2264 $path_cmd .= sprintf('%.3F %.3F l ', ($x) * $this->kp, -(($y + $h) * $this->kp));
2265 $path_cmd .= sprintf('%.3F %.3F l h ', ($x * $this->kp), -($y * $this->kp));
2269 $kappa = 4 * (sqrt(2) - 1) / 3;
2274 $path_cmd = sprintf('%.3F %.3F m ', ($x + $rx) * $this->kp, -$y * $this->kp);
2275 $path_cmd .= sprintf('%.3F %.3F l ', ($x + ($w - $rx)) * $this->kp, -$y * $this->kp);
2276 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', ($x + ($w - $rx + $kx)) * $this->kp, -$y * $this->kp, ($x + $w) * $this->kp, (-$y + (-$ry + $ky)) * $this->kp, ($x + $w) * $this->kp, (-$y + (-$ry)) * $this->kp);
2277 $path_cmd .= sprintf('%.3F %.3F l ', ($x + $w) * $this->kp, (-$y + (-$h + $ry)) * $this->kp);
2278 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', ($x + $w) * $this->kp, (-$y + (-$h - $ky + $ry)) * $this->kp, ($x + ($w - $rx + $kx)) * $this->kp, (-$y + (-$h)) * $this->kp, ($x + ($w - $rx)) * $this->kp, (-$y + (-$h)) * $this->kp);
2280 $path_cmd .= sprintf('%.3F %.3F l ', ($x + $rx) * $this->kp, (-$y + (-$h)) * $this->kp);
2281 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', ($x + ($rx - $kx)) * $this->kp, (-$y + (-$h)) * $this->kp, $x * $this->kp, (-$y + (-$h - $ky + $ry)) * $this->kp, $x * $this->kp, (-$y + (-$h + $ry)) * $this->kp);
2282 $path_cmd .= sprintf('%.3F %.3F l ', $x * $this->kp, (-$y + (-$ry)) * $this->kp);
2283 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c h ', $x * $this->kp, (-$y + (-$ry + $ky)) * $this->kp, ($x + ($rx - $kx)) * $this->kp, -$y * $this->kp, ($x + $rx) * $this->kp, -$y * $this->kp);
2299 $kappa = 4 * (sqrt(2) - 1) / 3;
2301 $cx = $this->ConvertSVGSizePixels($arguments['cx'], 'x');
2302 $cy = $this->ConvertSVGSizePixels($arguments['cy'], 'y');
2303 $rx = $this->ConvertSVGSizePixels($arguments['rx'], 'x');
2304 $ry = $this->ConvertSVGSizePixels($arguments['ry'], 'y');
2307 $y1 = -$cy + $ry;
2310 $y2 = -$cy;
2313 $y3 = -$cy - $ry;
2315 $x4 = $cx - $rx;
2316 $y4 = -$cy;
2318 $path_cmd = sprintf('%.3F %.3F m ', $x1 * $this->kp, $y1 * $this->kp);
2319 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', ($x1 + ($rx * $kappa)) * $this->kp, $y1 * $this->kp, $x2 * $this->kp, ($y2 + ($ry * $kappa)) * $this->kp, $x2 * $this->kp, $y2 * $this->kp);
2320 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $x2 * $this->kp, ($y2 - ($ry * $kappa)) * $this->kp, ($x3 + ($rx * $kappa)) * $this->kp, $y3 * $this->kp, $x3 * $this->kp, $y3 * $this->kp);
2321 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', ($x3 - ($rx * $kappa)) * $this->kp, $y3 * $this->kp, $x4 * $this->kp, ($y4 - ($ry * $kappa)) * $this->kp, $x4 * $this->kp, $y4 * $this->kp);
2322 $path_cmd .= sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c ', $x4 * $this->kp, ($y4 + ($ry * $kappa)) * $this->kp, ($x1 - ($rx * $kappa)) * $this->kp, $y1 * $this->kp, $x1 * $this->kp, $y1 * $this->kp);
2332 $ybase = - $arguments[1];
2337 $xbase = $this->ConvertSVGSizePixels($arguments[0], 'x');
2338 $ybase = - $this->ConvertSVGSizePixels($arguments[1], 'y');
2341 $path_cmd = sprintf('%.3F %.3F m ', $xbase * $this->kp, $ybase * $this->kp);
2346 $tmp_y = - $arguments[($i + 1)];
2348 $tmp_x = $this->ConvertSVGSizePixels($arguments[$i], 'x');
2349 $tmp_y = - $this->ConvertSVGSizePixels($arguments[($i + 1)], 'y');
2351 $path_cmd .= sprintf('%.3F %.3F l ', $tmp_x * $this->kp, $tmp_y * $this->kp);
2354 // $path_cmd .= 'h '; // ?? In error - don't close subpath here
2361 $ybase = - $arguments[1];
2362 $path_cmd = sprintf('%.3F %.3F m ', $xbase * $this->kp, $ybase * $this->kp);
2366 $tmp_y = - $arguments[($i + 1)];
2368 $path_cmd .= sprintf('%.3F %.3F l ', $tmp_x * $this->kp, $tmp_y * $this->kp);
2371 $path_cmd .= sprintf('%.3F %.3F l ', $xbase * $this->kp, $ybase * $this->kp);
2379 $current_style = $this->txt_style[count($this->txt_style) - 1]; // mPDF 5.7.4
2382 $render = -1;
2384 if (isset($this->txt_data[2])) {
2387 // If using SVG Font
2388 if (isset($this->svg_font[$current_style['font-family']])) {
2390 // select font
2392 $style .= (isset($current_style['font-weight']) && $current_style['font-weight'] == 'bold') ? 'B' : '';
2393 $style .= (isset($current_style['font-style']) && $current_style['font-style'] == 'italic') ? 'I' : '';
2394 $style .= (isset($current_style['font-variant']) && $current_style['font-variant'] == 'small-caps') ? 'S' : '';
2396 $fontsize = $current_style['font-size'] * $this->mpdf->dpi / 72;
2398 if (isset($this->svg_font[$current_style['font-family']][$style])) {
2399 $svg_font = $this->svg_font[$current_style['font-family']][$style];
2400 } elseif (isset($this->svg_font[$current_style['font-family']]['R'])) {
2401 $svg_font = $this->svg_font[$current_style['font-family']]['R'];
2404 if (!isset($svg_font['units-per-em']) || $svg_font['units-per-em'] < 1) {
2405 $svg_font['units-per-em'] = 1000;
2408 $units_per_em = $svg_font['units-per-em'];
2410 $stroke_width = $current_style['stroke-width'];
2416 if (isset($current_style['fill-opacity'])) {
2417 if ($current_style['fill-opacity'] == 0) {
2419 } elseif ($current_style['fill-opacity'] > 1) {
2421 } elseif ($current_style['fill-opacity'] > 0) {
2422 $fopacity = $current_style['fill-opacity'];
2423 } elseif ($current_style['fill-opacity'] < 0) {
2429 if (isset($current_style['stroke-opacity'])) {
2430 if ($current_style['stroke-opacity'] == 0) {
2432 } elseif ($current_style['stroke-opacity'] > 1) {
2434 } elseif ($current_style['stroke-opacity'] > 0) {
2435 $sopacity = $current_style['stroke-opacity'];
2436 } elseif ($current_style['stroke-opacity'] < 0) {
2441 $gs = $this->mpdf->AddExtGState(['ca' => $fopacity, 'CA' => $sopacity, 'BM' => '/Normal']);
2442 $this->mpdf->extgstates[$gs]['fo'] = true;
2447 $col = $this->colorConverter->convert($current_style['fill'], $this->mpdf->PDFAXwarnings);
2448 $fillstr = $this->mpdf->SetFColor($col, true);
2455 $scol = $this->colorConverter->convert($current_style['stroke'], $this->mpdf->PDFAXwarnings);
2457 $strokestr .= $this->mpdf->SetDColor($scol, true) . ' ';
2459 $linewidth = $this->ConvertSVGSizePixels($stroke_width);
2461 $strokestr .= sprintf('%.3F w 0 J 0 j ', $linewidth * $this->kp);
2462 if ($render == -1) {
2472 if ($render == -1) {
2480 $x = $this->txt_data[0]; // mPDF 5.7.4
2481 $y = $this->txt_data[1]; // mPDF 5.7.4
2482 $txt = $this->txt_data[2];
2490 if ($this->textjuststarted) {
2494 $this->textjuststarted = false; // mPDF 5.7.4
2496 $txt = $this->mpdf->purify_utf8_text($txt);
2498 if ($this->mpdf->text_input_as_HTML) {
2499 $txt = $this->mpdf->all_entities_to_utf8($txt);
2502 $nb = mb_strlen($txt, 'UTF-8');
2510 $char = mb_substr($txt, $i, 1, 'UTF-8');
2515 if (isset($svg_font['glyphs'][$char]['horiz-adv-x'])) {
2516 $horiz_adv_x = $svg_font['glyphs'][$char]['horiz-adv-x'];
2518 $horiz_adv_x = $svg_font['horiz-adv-x'];
2522 $horiz_adv_x = $svg_font['horiz-adv-x']; // missing glyph width
2525 preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $d, $commands, PREG_SET_ORDER);
2526 $subpath_cmd .= sprintf('q %.4F 0 0 %.4F mPDF-AXS(%.4F) %.4F cm ', $scale, -$scale, ($x + $sw * $scale) * $this->kp, -$y * $this->kp);
2528 $this->subPathInit = true;
2529 $this->pathBBox = [999999, 999999, -999999, -999999];
2540 $subpath_cmd .= $this->svgPath($command, $arguments);
2545 if ($this->pathBBox[2] == -1999998) {
2546 $this->pathBBox[2] = 100;
2549 if ($this->pathBBox[3] == -1999998) {
2550 $this->pathBBox[3] = 100;
2553 if ($this->pathBBox[0] == 999999) {
2554 $this->pathBBox[0] = 0;
2557 if ($this->pathBBox[1] == 999999) {
2558 $this->pathBBox[1] = 0;
2568 $this->textlength = $sw;
2569 $this->texttotallength += $this->textlength;
2575 unset($this->txt_data[0], $this->txt_data[1], $this->txt_data[2]);
2579 // select font
2580 $style .= ($current_style['font-weight'] == 'bold') ? 'B' : '';
2581 $style .= ($current_style['font-style'] == 'italic') ? 'I' : '';
2582 $size = $current_style['font-size'] * $this->kf;
2584 $current_style['font-family'] = $this->mpdf->SetFont($current_style['font-family'], $style, $size, false);
2585 $this->mpdf->CurrentFont['fo'] = true;
2591 if (isset($current_style['fill-opacity'])) {
2592 if ($current_style['fill-opacity'] == 0) {
2594 } elseif ($current_style['fill-opacity'] > 1) {
2596 } elseif ($current_style['fill-opacity'] > 0) {
2597 $fopacity = $current_style['fill-opacity'];
2598 } elseif ($current_style['fill-opacity'] < 0) {
2605 if (isset($current_style['stroke-opacity'])) {
2606 if ($current_style['stroke-opacity'] == 0) {
2608 } elseif ($current_style['stroke-opacity'] > 1) {
2610 } elseif ($current_style['stroke-opacity'] > 0) {
2611 $sopacity = $current_style['stroke-opacity'];
2612 } elseif ($current_style['stroke-opacity'] < 0) {
2617 $gs = $this->mpdf->AddExtGState(['ca' => $fopacity, 'CA' => $sopacity, 'BM' => '/Normal']);
2618 $this->mpdf->extgstates[$gs]['fo'] = true;
2624 $col = $this->colorConverter->convert($current_style['fill'], $this->mpdf->PDFAXwarnings);
2625 $fillstr = $this->mpdf->SetFColor($col, true);
2631 if (isset($current_style['stroke-width']) && $current_style['stroke-width'] > 0 && $current_style['stroke'] != 'none') {
2632 $scol = $this->colorConverter->convert($current_style['stroke'], $this->mpdf->PDFAXwarnings);
2635 $strokestr .= $this->mpdf->SetDColor($scol, true) . ' ';
2638 $linewidth = $this->ConvertSVGSizePixels($current_style['stroke-width']);
2641 $strokestr .= sprintf('%.3F w 1 J 1 j ', $linewidth * $this->kp);
2642 if ($render == -1) {
2651 if ($render == -1) {
2655 $x = $this->txt_data[0]; // mPDF 5.7.4
2656 $y = $this->txt_data[1]; // mPDF 5.7.4
2657 $txt = $this->txt_data[2];
2665 if ($this->textjuststarted) {
2669 $this->textjuststarted = false; // mPDF 5.7.4
2671 $txt = $this->mpdf->purify_utf8_text($txt);
2673 if ($this->mpdf->text_input_as_HTML) {
2674 $txt = $this->mpdf->all_entities_to_utf8($txt);
2677 if ($this->mpdf->usingCoreFont) {
2678 $txt = mb_convert_encoding($txt, $this->mpdf->mb_enc, 'UTF-8');
2681 if (preg_match("/([" . $this->mpdf->pregRTLchars . "])/u", $txt)) {
2682 $this->mpdf->biDirectional = true;
2686 $save_OTLtags = $this->mpdf->OTLtags;
2687 $this->mpdf->OTLtags = [];
2689 if ($this->mpdf->useKerning) {
2691 if ($this->mpdf->CurrentFont['haskernGPOS']) {
2693 if (isset($this->mpdf->OTLtags['Plus'])) {
2694 $this->mpdf->OTLtags['Plus'] .= ' kern';
2696 $this->mpdf->OTLtags['Plus'] = ' kern';
2704 // Use OTL OpenType Table Layout - GSUB & GPOS
2705 if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
2706 $txt = $this->otl->applyOTL($txt, $this->mpdf->CurrentFont['useOTL']);
2707 $OTLdata = $this->otl->OTLdata;
2710 $this->mpdf->OTLtags = $save_OTLtags;
2712 $this->mpdf->magic_reverse_dir($txt, $this->mpdf->directionality, $OTLdata);
2714 $this->mpdf->CurrentFont['used'] = true;
2716 $sw = $this->mpdf->GetStringWidth($txt, true, $OTLdata, $textvar); // also adds characters to subset
2719 $this->textlength = $sw * 1 / (25.4 / $this->mpdf->dpi);
2720 $this->texttotallength += $this->textlength;
2722 $pdfx = $x * $this->kp;
2723 $pdfy = -$y * $this->kp;
2725 $aixextra = sprintf(' /F%d %.3F Tf %s %s Tr %s %s ', $this->mpdf->CurrentFont['i'], $this->mpdf->FontSizePt, $opacitystr, $render, $fillstr, $strokestr);
2727 $path_cmd = 'q 1 0 0 1 mPDF-AXS(0.00) 0 cm '; // Align X-shift
2728 $path_cmd .= $this->mpdf->Text($pdfx, $pdfy, $txt, $OTLdata, $textvar, $aixextra, 'SVG', true);
2731 unset($this->txt_data[0], $this->txt_data[1], $this->txt_data[2]);
2733 if (isset($current_style['font-size-parent'])) {
2734 $this->mpdf->SetFontSize($current_style['font-size-parent']);
2741 // Reset font // mPDF 5.7.4
2742 $prev_style = $this->txt_style[count($this->txt_style) - 1];
2744 $style .= ($prev_style['font-weight'] == 'bold') ? 'B' : '';
2745 $style .= ($prev_style['font-style'] == 'italic') ? 'I' : '';
2746 $size = $prev_style['font-size'] * $this->kf;
2747 $this->mpdf->SetFont($prev_style['font-family'], $style, $size, false);
2755 $tmp = count($this->txt_style) - 1;
2756 $current_style = $this->txt_style[$tmp];
2763 $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i", "$2", $critere_style['style']);
2770 if (preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i", $critere_style['style'], $m) ||
2771 preg_match("/^opacity:\s*([a-z0-9.]*|none)/i", $critere_style['style'], $m)) {
2772 $current_style['fill-opacity'] = $m[1];
2773 $current_style['stroke-opacity'] = $m[1];
2776 $tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
2778 $current_style['fill-opacity'] = $tmp;
2781 $tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
2783 $current_style['fill-rule'] = $tmp;
2789 $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
2795 $tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
2797 $current_style['stroke-linecap'] = $tmp;
2800 $tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
2802 $current_style['stroke-linejoin'] = $tmp;
2805 $tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i", "$2", $critere_style['style']);
2807 $current_style['stroke-miterlimit'] = $tmp;
2810 $tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
2812 $current_style['stroke-opacity'] = $tmp;
2815 $tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
2817 $current_style['stroke-width'] = $tmp;
2820 $tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i", "$2", $critere_style['style']);
2822 $current_style['stroke-dasharray'] = $tmp;
2825 $tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
2827 $current_style['stroke-dashoffset'] = $tmp;
2830 $tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.\"' ,\-]*|none)(.*)/i", "$2", $critere_style['style']);
2832 $critere_style['font-family'] = $tmp;
2835 $tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i", "$2", $critere_style['style']);
2837 $critere_style['font-size'] = $tmp;
2840 $tmp = preg_replace("/(.*)font-weight:\s*([a-z0-9.]*|normal)(.*)/i", "$2", $critere_style['style']);
2842 $critere_style['font-weight'] = $tmp;
2845 $tmp = preg_replace("/(.*)font-style:\s*([a-z0-9.]*|normal)(.*)/i", "$2", $critere_style['style']);
2847 $critere_style['font-style'] = $tmp;
2850 $tmp = preg_replace("/(.*)font-variant:\s*([a-z0-9.]*|normal)(.*)/i", "$2", $critere_style['style']);
2852 $critere_style['font-variant'] = $tmp;
2855 $tmp = preg_replace("/(.*)text-anchor:\s*(start|middle|end)(.*)/i", "$2", $critere_style['style']);
2857 $critere_style['text-anchor'] = $tmp;
2861 if (isset($critere_style['font'])) {
2862 // [ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]?<'font-size'> [ / <'line-height'> ]? <'font-family'> ]
2864 $tmp = preg_replace("/(.*)(italic|oblique)(.*)/i", "$2", $critere_style['font']);
2865 if ($tmp != $critere_style['font']) {
2869 $current_style['font-style'] = $tmp;
2872 $tmp = preg_replace("/(.*)(bold|bolder)(.*)/i", "$2", $critere_style['font']);
2873 if ($tmp != $critere_style['font']) {
2877 $current_style['font-weight'] = $tmp;
2880 $tmp = preg_replace("/(.*)(small\-caps)(.*)/i", "$2", $critere_style['font']);
2881 if ($tmp != $critere_style['font']) {
2882 $current_style['font-variant'] = $tmp;
2886 $tmp = preg_replace("/(.*)\b(\d+)[\b|\/](.*)/i", "$2", $critere_style['font']);
2887 if ($tmp != $critere_style['font']) {
2888 $current_style['font-size'] = $this->ConvertSVGSizePts($tmp);
2889 $this->mpdf->SetFont('', '', $current_style['font-size'], false);
2895 $current_style['fill-opacity'] = $critere_style['opacity'];
2896 $current_style['stroke-opacity'] = $critere_style['opacity'];
2900 if (isset($critere_style['stroke-opacity']) && $critere_style['stroke-opacity'] != 'inherit') {
2901 $current_style['stroke-opacity'] = $critere_style['stroke-opacity'];
2905 if (isset($critere_style['fill-opacity']) && $critere_style['fill-opacity'] != 'inherit') {
2906 $current_style['fill-opacity'] = $critere_style['fill-opacity'];
2917 if (isset($critere_style['stroke-width']) && $critere_style['stroke-width'] != 'inherit') {
2918 $current_style['stroke-width'] = $critere_style['stroke-width'];
2921 if (isset($critere_style['font-style']) && $critere_style['font-style'] != 'inherit') {
2922 if (strtolower($critere_style['font-style']) == 'oblique') {
2923 $critere_style['font-style'] = 'italic';
2925 $current_style['font-style'] = $critere_style['font-style'];
2928 if (isset($critere_style['font-weight']) && $critere_style['font-weight'] != 'inherit') {
2929 if (strtolower($critere_style['font-weight']) == 'bolder') {
2930 $critere_style['font-weight'] = 'bold';
2932 $current_style['font-weight'] = $critere_style['font-weight'];
2935 if (isset($critere_style['font-variant']) && $critere_style['font-variant'] != 'inherit') {
2936 $current_style['font-variant'] = $critere_style['font-variant'];
2939 if (isset($critere_style['font-size']) && $critere_style['font-size'] != 'inherit') {
2940 if (strpos($critere_style['font-size'], '%') !== false) {
2941 $current_style['font-size-parent'] = $current_style['font-size'];
2943 $current_style['font-size'] = $this->ConvertSVGSizePts($critere_style['font-size']);
2944 $this->mpdf->SetFont('', '', $current_style['font-size'], false);
2947 if (isset($critere_style['font-family']) && $critere_style['font-family'] != 'inherit') {
2948 $v = $critere_style['font-family'];
2953 $svgfontstyle .= (isset($current_style['font-weight']) && $current_style['font-weight'] == 'bold') ? 'B' : '';
2954 $svgfontstyle .= (isset($current_style['font-style']) && $current_style['font-style'] == 'italic') ? 'I' : '';
2955 $svgfontstyle .= (isset($current_style['font-variant']) && $current_style['font-variant'] == 'small-caps') ? 'S' : '';
2962 if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) {
2963 $v = $this->mpdf->fonttrans[$v];
2965 if ((!$this->mpdf->usingCoreFont && in_array($v, $this->mpdf->available_unifonts)) ||
2966 ($this->mpdf->usingCoreFont && in_array($v, ['courier', 'times', 'helvetica', 'arial'])) ||
2967 in_array($v, ['sjis', 'uhc', 'big5', 'gb']) || isset($this->svg_font[$v][$svgfontstyle])) { // mPDF 6
2968 $current_style['font-family'] = $v;
2980 if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) {
2981 $v = $this->mpdf->fonttrans[$v];
2983 if (in_array($v, $this->mpdf->sans_fonts) || in_array($v, $this->mpdf->serif_fonts) || in_array($v, $this->mpdf->mono_fonts) || isset($this->svg_font[$v][$svgfontstyle])) { // mPDF 6
2984 $current_style['font-family'] = $v;
2991 if (isset($critere_style['text-anchor']) && $critere_style['text-anchor'] != 'inherit') {
2992 $current_style['text-anchor'] = $critere_style['text-anchor'];
2996 array_push($this->txt_style, $current_style);
3002 $this->svg_gradient[$id] = $array_gradient;
3007 $this->svg_string .= $content;
3019 * @author Antonio Norman - softcodex.ch
3024 if (!$xml->loadXML($data, LIBXML_NOERROR)) {
3029 $svgNode = $xml->getElementsByTagName('svg');
3030 if ($svgNode->length === 0) {
3037 foreach ($svgNode->item(0)->getElementsByTagName('style') as $styleNode) {
3039 preg_match_all('/(\.[^{]+)\s*\{\s*([^}]+)\s*}/m', $styleNode->nodeValue, $matches, PREG_SET_ORDER);
3057 foreach ($xml->childNodes as $node) {
3059 if ($node->hasChildNodes()) {
3068 if (!$node->hasAttribute('class')) {
3073 $classes = explode(' ', $node->getAttribute('class'));
3080 $style = $node->hasAttribute('style') ?
3081 $styles[$class] . ' ' . $node->getAttribute('style') :
3084 $node->setAttribute('style', $style);
3092 return $xml->saveXML();
3101 $data = preg_replace('/<!--.*?-->/is', '', $data); // mPDF 5.7.4
3104 $data = preg_replace('/<([^!?\/a-zA-Z_:])/i', '&lt;\\1', $data); // mPDF 5.7.4
3106 $data = $this->mergeStyles($data);
3108 if ($this->mpdf->svgAutoFont) {
3109 $data = $this->markScriptToLang($data);
3112 $this->svg_info = [];
3119 // Get User-defined entities
3120 preg_match_all('/<!ENTITY\s+([a-z]+)\s+\"(.*?)\">/si', $data, $ent);
3136 // Delete links from data - keeping in $links
3178 if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*\/>/si', $data, $m)) {
3181 if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\']/si', $data, $m)) {
3208 if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
3234 if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\'][^>]*\/>/si', $data, $m)) {
3238 if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']' . $links[2][$i] . '["\']/si', $data, $m)) {
3263 if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
3290 $this->svg_info['data'] = $data;
3291 $this->svg_string = '';
3296 $this->inDefs = false;
3298 $svg2pdf_xml_parser = xml_parser_create("utf-8");
3315 if ($this->svg_error) {
3319 'x' => $this->svg_info['x'] * $this->kp,
3320 'y' => -$this->svg_info['y'] * $this->kp,
3321 'w' => $this->svg_info['w'] * $this->kp,
3322 'h' => -$this->svg_info['h'] * $this->kp,
3323 'data' => $this->svg_string,
3332 if ($this->mpdf->onlyCoreFonts) {
3337 $a = preg_split('/<(.*?)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
3341 $e = $this->mpdf->lesser_entity_decode($e);
3343 $earr = $this->mpdf->UTF8StringToArray($e, false);
3360 // NEW (non-common) Script encountered in this chunk.
3374 // If scriptblock[x] = common & non-baseScript
3378 if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf->baseScript && $scriptblocks[$sch + 1] == $this->mpdf->baseScript) {
3379 $end = count($chardata[$sch]) - 1;
3383 $end--;
3395 // ZZZ99 Undo lesser_entity_decode as above - but only for <>&
3400 if (substr($a[$i - 1], 0, 5) != '<text' && substr($a[$i - 1], 0, 5) != '<tspa') {
3405 // Check Vietnamese if Latin script - even if Basescript
3406 if ($scriptblocks[$sch] == Ucdn::SCRIPT_LATIN && $this->mpdf->autoVietnamese && preg_match("/([" . $this->scriptToLanguage->getLanguageDelimiters('viet') . "])/u", $s)) {
3408 } // Check Arabic for different languages if Arabic script - even if Basescript
3409 elseif ($scriptblocks[$sch] == Ucdn::SCRIPT_ARABIC && $this->mpdf->autoArabic) {
3410 if (preg_match("/[" . $this->scriptToLanguage->getLanguageDelimiters('sindhi') . "]/u", $s)) {
3412 } elseif (preg_match("/[" . $this->scriptToLanguage->getLanguageDelimiters('urdu') . "]/u", $s)) {
3414 } elseif (preg_match("/[" . $this->scriptToLanguage->getLanguageDelimiters('pashto') . "]/u", $s)) {
3416 } elseif (preg_match("/[" . $this->scriptToLanguage->getLanguageDelimiters('persian') . "]/u", $s)) {
3418 } elseif ($this->mpdf->baseScript != Ucdn::SCRIPT_ARABIC && $this->scriptToLanguage->getLanguageByScript($scriptblocks[$sch])) {
3419 $lang = "'." . $this->scriptToLanguage->getLanguageByScript($scriptblocks[$sch]) . "'";
3422 elseif ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf->baseScript && $this->scriptToLanguage->getLanguageByScript($scriptblocks[$sch])) {
3423 $lang = $this->scriptToLanguage->getLanguageByScript($scriptblocks[$sch]);
3447 if (strtolower($name) == 'font') {
3450 if (isset($attribs['horiz-adv-x']) && $attribs['horiz-adv-x']) {
3451 $last_svg_fontdefw = $attribs['horiz-adv-x'];
3455 } elseif (strtolower($name) == 'font-face') { // mPDF 6
3457 $last_svg_fontstyle .= (isset($attribs['font-weight']) && $attribs['font-weight'] == 'bold') ? 'B' : '';
3458 $last_svg_fontstyle .= (isset($attribs['font-style']) && $attribs['font-style'] == 'italic') ? 'I' : '';
3459 $last_svg_fontstyle .= (isset($attribs['font-variant']) && $attribs['font-variant'] == 'small-caps') ? 'S' : '';
3461 if (isset($attribs['font-family']) && $attribs['font-family']) {
3464 'units-per-em' => (isset($attribs['units-per-em']) ? $attribs['units-per-em'] : ''),
3469 $last_svg_fontid = strtolower($attribs['font-family']);
3472 $tmp_svg_font['horiz-adv-x'] = $last_svg_fontdefw;
3474 $tmp_svg_font['horiz-adv-x'] = 500;
3477 $this->svg_font[$last_svg_fontid][$last_svg_fontstyle] = $tmp_svg_font;
3481 } elseif (strtolower($name) == 'missing-glyph') { // mPDF 6
3483 if ($last_svg_fontid && isset($attribs['horiz-adv-x'])) {
3484 $this->svg_font[$last_svg_fontid][$last_svg_fontstyle]['horiz-adv-x'] = (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : '');
3485 $this->svg_font[$last_svg_fontid][$last_svg_fontstyle]['d'] = (isset($attribs['d']) ? $attribs['d'] : '');
3493 $this->svg_font[$last_svg_fontid][$last_svg_fontstyle]['glyphs'][$attribs['unicode']] = [
3494 'horiz-adv-x' => (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : $last_svg_fontdefw),
3527 $this->svgAddGradient($attribs['id'], $tmp_gradient);
3562 $this->svgAddGradient($attribs['id'], $tmp_gradient);
3573 if (isset($attribs['style']) and preg_match('/stop-color:\s*([^;]*)/i', $attribs['style'], $m)) {
3575 } elseif (isset($attribs['stop-color']) && $attribs['stop-color']) {
3576 $color = $attribs['stop-color'];
3579 $col = $this->colorConverter->convert($color, $this->mpdf->PDFAXwarnings);
3581 $col = $this->colorConverter->convert('#000000', $this->mpdf->PDFAXwarnings);
3586 $this->svg_gradient[$last_gradid]['colorspace'] = 'RGB';
3589 $this->svg_gradient[$last_gradid]['colorspace'] = 'CMYK';
3592 $this->svg_gradient[$last_gradid]['colorspace'] = 'Gray';
3597 if (isset($attribs['style']) and preg_match('/stop-opacity:\s*([0-9.]*)/i', $attribs['style'], $m)) {
3599 } elseif (isset($attribs['stop-opacity'])) {
3600 $stop_opacity = $attribs['stop-opacity'];
3612 array_push($this->svg_gradient[$last_gradid]['color'], $tmp_color);
3617 if ($this->inDefs) {
3621 $this->xbase = 0;
3622 $this->ybase = 0;
3628 $this->inDefs = true;
3632 $this->svgOffset($attribs);
3638 preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $path, $commands, PREG_SET_ORDER);
3640 $this->subPathInit = true;
3641 $this->pathBBox = [999999, 999999, -999999, -999999];
3651 $path_cmd .= $this->svgPath($command, $arguments);
3654 if ($this->pathBBox[2] == -1999998) {
3655 $this->pathBBox[2] = 100;
3658 if ($this->pathBBox[3] == -1999998) {
3659 $this->pathBBox[3] = 100;
3662 if ($this->pathBBox[0] == 999999) {
3663 $this->pathBBox[0] = 0;
3666 if ($this->pathBBox[1] == 999999) {
3667 $this->pathBBox[1] = 0;
3672 $path_style = $this->svgDefineStyle($critere_style);
3719 $path_cmd = $this->svgRect($arguments);
3722 $path_style = $this->svgDefineStyle($critere_style);
3754 $path_cmd = $this->svgEllipse($arguments);
3757 $path_style = $this->svgDefineStyle($critere_style);
3789 $path_cmd = $this->svgEllipse($arguments);
3792 $path_style = $this->svgDefineStyle($critere_style);
3803 $path_cmd = $this->svgPolyline($arguments, false);
3806 $path_style = $this->svgDefineStyle($critere_style);
3813 preg_match_all('/[0-9\-\.]*/', $path, $tmp, PREG_SET_ORDER);
3822 $path_cmd = $this->svgPolyline($arguments);
3825 $path_style = $this->svgDefineStyle($critere_style);
3832 preg_match_all('/([\-]*[0-9\.]+)/', $path, $tmp);
3841 $path_cmd = $this->svgPolygon($arguments);
3845 $path_style = $this->svgDefineStyle($critere_style);
3853 $this->svgImage($attribs);
3865 // fallthtough - then continue like a <g>
3869 $array_style = $this->svgDefineStyle($attribs);
3873 if ($this->intext) {
3874 $this->textoutput .= ' q ' . $array_style['transformations'];
3876 $this->svgWriteString(' q ' . $array_style['transformations']);
3880 array_push($this->svg_style, $array_style);
3882 $this->svgDefineTxtStyle($attribs);
3888 $this->textlength = 0; // mPDF 5.7.4
3889 $this->texttotallength = 0; // mPDF 5.7.4
3890 $this->textoutput = ''; // mPDF 5.7.4
3891 $this->textanchor = 'start'; // mPDF 5.7.4
3892 $this->textXorigin = 0; // mPDF 5.7.4
3893 $this->textYorigin = 0; // mPDF 5.7.4
3895 $this->intext = true; // mPDF 5.7.4
3899 if ($this->mpdf->svgClasses && isset($attribs['class']) && $attribs['class']) {
3902 if (isset($this->cssManager->CSS['CLASS>>' . strtoupper($class)])) {
3903 $c = $this->cssManager->CSS['CLASS>>' . strtoupper($class)];
3911 if ($this->mpdf->svgAutoFont && isset($attribs['lang']) && $attribs['lang']) {
3912 if (!$this->mpdf->usingCoreFont) {
3913 if ($attribs['lang'] != $this->mpdf->default_lang) {
3914 list ($coreSuitable, $mpdf_unifont) = $this->languageToFont->getLanguageOptions($attribs['lang'], $this->mpdf->useAdobeCJK);
3916 $styl .= 'font-family:' . $mpdf_unifont . ';';
3930 $array_style = $this->svgDefineStyle($attribs);
3932 $this->textoutput .= ' q ' . $array_style['transformations']; // mPDF 5.7.4
3934 array_push($this->svg_style, $array_style);
3936 $this->txt_data = [];
3937 $x = isset($attribs['x']) ? $this->ConvertSVGSizePixels($attribs['x'], 'x') : 0; // mPDF 5.7.4
3938 $y = isset($attribs['y']) ? $this->ConvertSVGSizePixels($attribs['y'], 'y') : 0; // mPDF 5.7.4
3939 $x += isset($attribs['dx']) ? $this->ConvertSVGSizePixels($attribs['dx'], 'x') : 0; // mPDF 5.7.4
3940 $y += isset($attribs['dy']) ? $this->ConvertSVGSizePixels($attribs['dy'], 'y') : 0; // mPDF 5.7.4
3942 $this->txt_data[0] = $x; // mPDF 5.7.4
3943 $this->txt_data[1] = $y; // mPDF 5.7.4
3946 $this->svgDefineTxtStyle($critere_style);
3948 $this->textanchor = $this->txt_style[count($this->txt_style) - 1]['text-anchor']; // mPDF 5.7.4
3949 $this->textXorigin = $this->txt_data[0]; // mPDF 5.7.4
3950 $this->textYorigin = $this->txt_data[1]; // mPDF 5.7.4
3951 $this->textjuststarted = true; // mPDF 5.7.4
3958 // OUTPUT CHUNK(s) UP To NOW (svgText updates $this->textlength)
3959 $p_cmd = $this->svgText();
3960 $this->textoutput .= $p_cmd;
3961 $tmp = count($this->svg_style) - 1;
3962 $current_style = $this->svg_style[$tmp];
3965 if ($this->mpdf->svgClasses && isset($attribs['class']) && $attribs['class']) {
3968 if (isset($this->cssManager->CSS['CLASS>>' . strtoupper($class)])) {
3969 $c = $this->cssManager->CSS['CLASS>>' . strtoupper($class)];
3977 if ($this->mpdf->svgAutoFont && isset($attribs['lang']) && $attribs['lang']) {
3978 if (!$this->mpdf->usingCoreFont) {
3979 if ($attribs['lang'] != $this->mpdf->default_lang) {
3980 list ($coreSuitable, $mpdf_unifont) = $this->languageToFont->getLanguageOptions($attribs['lang'], $this->mpdf->useAdobeCJK);
3982 $styl .= 'font-family:' . $mpdf_unifont . ';';
3996 $array_style = $this->svgDefineStyle($attribs);
3998 $this->txt_data = [];
4001 // If absolute position adjustment (x or y), creates new block of text for text-alignment
4003 // If text-anchor middle|end, adjust
4004 if ($this->textanchor == 'end') {
4005 $tx = -$this->texttotallength;
4006 } elseif ($this->textanchor == 'middle') {
4007 $tx = -$this->texttotallength / 2;
4011 while (preg_match('/mPDF-AXS\((.*?)\)/', $this->textoutput, $m)) {
4013 $txk = $m[1] + ($tx * $this->kp);
4014 $this->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk), $this->textoutput, 1);
4016 $this->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', '\\1', $this->textoutput, 1);
4020 $this->svgWriteString($this->textoutput);
4022 $this->textXorigin += $this->textlength;
4023 $currentX = $this->textXorigin;
4024 $currentY = $this->textYorigin;
4025 $this->textlength = 0;
4026 $this->texttotallength = 0;
4027 $this->textoutput = '';
4029 $x = isset($attribs['x']) ? $this->ConvertSVGSizePixels($attribs['x'], 'x') : $currentX;
4030 $y = isset($attribs['y']) ? $this->ConvertSVGSizePixels($attribs['y'], 'y') : $currentY;
4032 $this->txt_data[0] = $x;
4033 $this->txt_data[1] = $y;
4036 $this->svgDefineTxtStyle($critere_style);
4038 $this->textanchor = $this->txt_style[count($this->txt_style) - 1]['text-anchor'];
4039 $this->textXorigin = $x;
4040 $this->textYorigin = $y;
4042 $this->textXorigin += $this->textlength;
4043 $currentX = $this->textXorigin;
4044 $currentY = $this->textYorigin;
4046 $currentX += isset($attribs['dx']) ? $this->ConvertSVGSizePixels($attribs['dx'], 'x') : 0;
4047 $currentY += isset($attribs['dy']) ? $this->ConvertSVGSizePixels($attribs['dy'], 'y') : 0;
4049 $this->txt_data[0] = $currentX;
4050 $this->txt_data[1] = $currentY;
4053 $this->svgDefineTxtStyle($critere_style);
4054 $this->textXorigin = $currentX;
4055 $this->textYorigin = $currentY;
4059 $this->textoutput .= ' q ' . $array_style['transformations'];
4061 array_push($this->svg_style, $array_style);
4069 list($prestyle, $poststyle) = $this->svgStyle($path_style, $attribs, strtolower($name));
4071 $this->svgWriteString(" q " . $path_style['transformations'] . $prestyle . $path_cmd . $poststyle . " Q\n");
4073 $this->svgWriteString(" q " . $prestyle . $path_cmd . $poststyle . " Q\n"); // mPDF 5.7.4
4080 if ($this->inDefs) {
4084 if (isset($this->txt_data[2])) {
4085 $this->txt_data[2] .= $data;
4087 $this->txt_data[2] = $data;
4088 $this->txt_data[0] = $this->textXorigin;
4089 $this->txt_data[1] = $this->textYorigin;
4098 $this->inDefs = false;
4102 if ($this->inDefs) {
4109 if ($this->intext) {
4110 $p_cmd = $this->svgText();
4111 $this->textoutput .= $p_cmd;
4114 $tmp = count($this->svg_style) - 1;
4115 $current_style = $this->svg_style[$tmp];
4118 if ($this->intext) {
4119 $this->textoutput .= " Q\n";
4122 $this->svgWriteString(" Q\n");
4126 array_pop($this->svg_style);
4127 array_pop($this->txt_style);
4129 if ($this->intext) {
4130 $this->textXorigin += $this->textlength;
4131 $this->textlength = 0;
4136 case 'font':
4140 case 'font-face':
4151 if (!empty($this->txt_data[2])) {
4152 $this->txt_data[2] = rtrim($this->txt_data[2]); // mPDF 5.7.4
4155 $path_cmd = $this->svgText();
4156 $this->textoutput .= $path_cmd; // mPDF 5.7.4
4157 $tmp = count($this->svg_style) - 1;
4158 $current_style = $this->svg_style[$tmp];
4161 $this->textoutput .= " Q\n"; // mPDF 5.7.4
4163 array_pop($this->svg_style);
4164 array_pop($this->txt_style); // mPDF 5.7.4
4167 // If text-anchor middle|end, adjust
4168 if ($this->textanchor == 'end') {
4169 $tx = -$this->texttotallength;
4170 } elseif ($this->textanchor == 'middle') {
4171 $tx = -$this->texttotallength / 2;
4175 while (preg_match('/mPDF-AXS\((.*?)\)/', $this->textoutput, $m)) {
4177 $txk = $m[1] + ($tx * $this->kp);
4178 $this->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk), $this->textoutput, 1);
4180 $this->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', '\\1', $this->textoutput, 1);
4184 $this->svgWriteString($this->textoutput);
4185 $this->textlength = 0;
4186 $this->texttotallength = 0;
4187 $this->textoutput = '';
4188 $this->intext = false; // mPDF 5.7.4
4193 $p_cmd = $this->svgText();
4194 $this->textoutput .= $p_cmd;
4195 $tmp = count($this->svg_style) - 1;
4196 $current_style = $this->svg_style[$tmp];
4198 $this->textoutput .= " Q\n";
4200 array_pop($this->svg_style);
4201 array_pop($this->txt_style);
4203 $this->textXorigin += $this->textlength;
4204 $this->textlength = 0;
4223 $b = 6 * $P0[$i] - 12 * $P1[$i] + 6 * $P2[$i];
4224 $a = -3 * $P0[$i] + 9 * $P1[$i] - 9 * $P2[$i] + 3 * $P3[$i];
4225 $c = 3 * $P1[$i] - 3 * $P0[$i];
4233 $t = -$c / $b;
4236 $bounds[$i][] = (pow((1 - $t), 3) * $P0[$i] + 3 * pow((1 - $t), 2) * $t * $P1[$i] + 3 * (1 - $t) * pow($t, 2) * $P2[$i] + pow($t, 3) * $P3[$i]);
4242 $b2ac = pow($b, 2) - 4 * $c * $a;
4248 $t1 = (-$b + sqrt($b2ac)) / (2 * $a);
4251 $bounds[$i][] = (pow((1 - $t1), 3) * $P0[$i] + 3 * pow((1 - $t1), 2) * $t1 * $P1[$i] + 3 * (1 - $t1) * pow($t1, 2) * $P2[$i] + pow($t1, 3) * $P3[$i]);
4254 $t2 = (-$b - sqrt($b2ac)) / (2 * $a);
4257 $bounds[$i][] = (pow((1 - $t2), 3) * $P0[$i] + 3 * pow((1 - $t2), 2) * $t2 * $P1[$i] + 3 * (1 - $t2) * pow($t2, 2) * $P2[$i] + pow($t2, 3) * $P3[$i]);
4277 $d1 = sqrt(pow(($cy - 0), 2) + pow(($cx - 0), 2));
4278 $d2 = sqrt(pow(($cy - 1), 2) + pow(($cx - 0), 2));
4279 $d3 = sqrt(pow(($cy - 0), 2) + pow(($cx - 1), 2));
4280 $d4 = sqrt(pow(($cy - 1), 2) + pow(($cx - 1), 2));
4291 $a1 = $y2 - $y1;
4292 $b1 = $x1 - $x2;
4294 $a2 = $y4 - $y3;
4295 $b2 = $x3 - $x4;
4297 $det = $a1 * $b2 - $a2 * $b1;
4302 $x = ($b2 * $c1 - $b1 * $c2) / $det;
4303 $y = ($a1 * $c2 - $a2 * $c1) / $det;