From: Alan Date: Mon, 26 Feb 2024 03:55:50 +0000 (+0800) Subject: fpdf fixes X-Git-Url: http://git.roojs.org/?p=pear;a=commitdiff_plain;h=c90a16a83b80cf1fa4d586ee1d2e0f0b0521037a fpdf fixes --- diff --git a/Fpdf/font/unifont/ttfonts.php b/Fpdf/font/unifont/ttfonts.php index 2c6fe738..ce695c7c 100644 --- a/Fpdf/font/unifont/ttfonts.php +++ b/Fpdf/font/unifont/ttfonts.php @@ -27,37 +27,39 @@ define("GF_TWOBYTWO",(1 << 7)); class TTFontFile { - -var $_pos; -var $numTables; -var $searchRange; -var $entrySelector; -var $rangeShift; -var $tables; -var $otables; -var $filename; -var $fh; -var $hmetrics; -var $glyphPos; -var $charToGlyph; -var $ascent; -var $descent; -var $name; -var $familyName; -var $styleName; -var $fullName; -var $uniqueFontID; -var $unitsPerEm; -var $bbox; -var $capHeight; -var $stemV; -var $italicAngle; -var $flags; -var $underlinePosition; -var $underlineThickness; -var $charWidths; -var $defaultWidth; -var $maxStrLenRead; + + var $_pos; + var $numTables; + var $searchRange; + var $entrySelector; + var $rangeShift; + var $tables; + var $otables; + var $filename; + var $fh; + var $hmetrics; + var $glyphPos; + var $charToGlyph; + var $ascent; + var $descent; + var $name; + var $familyName; + var $styleName; + var $fullName; + var $uniqueFontID; + var $unitsPerEm; + var $bbox; + var $capHeight; + var $stemV; + var $italicAngle; + var $flags; + var $underlinePosition; + var $underlineThickness; + var $charWidths; + var $defaultWidth; + var $maxStrLenRead; + var $version; + var $fontRevision; function TTFontFile() { $this->maxStrLenRead = 200000; // Maximum size of glyf table to read in as string (otherwise reads each glyph from file) @@ -327,7 +329,7 @@ var $maxStrLenRead; if (!$psName) die("Could not find PostScript font name"); for ($i=0;$i126 || strpos(' [](){}<>/%',$c)!==false) die("psName=".$psName." contains invalid character ".$c." ie U+".ord(c)); diff --git a/Fpdf/tFPDF.php b/Fpdf/tFPDF.php index 6a33b4c8..aaf9d077 100644 --- a/Fpdf/tFPDF.php +++ b/Fpdf/tFPDF.php @@ -77,7 +77,7 @@ var $PDFVersion; //PDF version number * Public methods * * * *******************************************************************************/ -function tFPDF($orientation='P', $unit='mm', $format='A4') +function __construct($orientation='P', $unit='mm', $format='a4') { //Some checks $this->_dochecks(); @@ -540,7 +540,7 @@ function AddFont($family, $style='', $file='', $uni=false) if(!isset($name)) { $this->Error('Problem with the font definition file'); } - $i = count($this->fonts)+$this->extraFontSubsets+1; + $i = count(is_array($this->fonts) ? $this->fonts : array())+$this->extraFontSubsets+1; $sbarr = range(0,127); $this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$ttfilename, 'subsets'=>array(0=>$sbarr), 'subsetfontids'=>array($i), 'used'=>false); unset($cw); @@ -1271,18 +1271,19 @@ function _beginpage($orientation, $format) $this->y=$this->tMargin; $this->FontFamily=''; //Check page size - if($orientation=='') + if($orientation=='') { $orientation=$this->DefOrientation; - else + } else { $orientation=strtoupper($orientation[0]); - if($format=='') + } + if($format=='') { $format=$this->DefPageFormat; - else - { - if(is_string($format)) + } else { + if(is_string($format)) { $format=$this->_getpageformat($format); + } } - if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) + if($orientation!=$this->CurOrientation || empty($format) || $format[0] !=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) { //New size if($orientation=='P') @@ -1292,8 +1293,8 @@ function _beginpage($orientation, $format) } else { - $this->w=$format[1]; - $this->h=$format[0]; + $this->w= $format[1]; + $this->h= $format[0]; } $this->wPt=$this->w*$this->k; $this->hPt=$this->h*$this->k; @@ -1842,8 +1843,10 @@ function _putimages() { $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; reset($this->images); - while(list($file,$info)=each($this->images)) - { + foreach($this->images as $file_info) { + + list($file,$info)=$file_info; + $this->_newobj(); $this->images[$file]['n']=$this->n; $this->_out('<childrenWritePDF($pdf,$data); } diff --git a/XML/SvgToPdf/G.php b/XML/SvgToPdf/G.php index b854f418..6886c1d4 100644 --- a/XML/SvgToPdf/G.php +++ b/XML/SvgToPdf/G.php @@ -118,7 +118,7 @@ class XML_SvgToPDF_G extends XML_SvgToPDF_Base - function writePDF($pdf,&$data) { + function writePDF($pdf,$data) { // g group = does it have a // look for if (empty($this->children)) { diff --git a/XML/SvgToPdf/Path.php b/XML/SvgToPdf/Path.php index 91bfd1c6..af5c77a4 100644 --- a/XML/SvgToPdf/Path.php +++ b/XML/SvgToPdf/Path.php @@ -6,6 +6,7 @@ class XML_SvgToPDF_Path extends XML_SvgToPDF_Base { var $d; // stores the details of the path.. + var $id; function fromXmlNode($node) { @@ -140,8 +141,7 @@ class XML_SvgToPDF_Path extends XML_SvgToPDF_Base { if (!$color || ($color == 'none')) { return false; } - var_dump($color); - return array( + return array( hexdec(substr($color,1,2)), hexdec(substr($color,3,2)), hexdec(substr($color,5,2))); diff --git a/XML/SvgToPdf/Text.php b/XML/SvgToPdf/Text.php index dbbb4c04..0131c240 100644 --- a/XML/SvgToPdf/Text.php +++ b/XML/SvgToPdf/Text.php @@ -3,6 +3,9 @@ class XML_SvgToPDF_Text extends XML_SvgToPDF_Base { + var $linespacing; + + function fromXmlNode($node) { parent::fromXmlNode($node); diff --git a/XML/SvgToPdf/Tspan.php b/XML/SvgToPdf/Tspan.php index 2ac9b7b0..2f081aaa 100644 --- a/XML/SvgToPdf/Tspan.php +++ b/XML/SvgToPdf/Tspan.php @@ -11,6 +11,8 @@ class XML_SvgToPDF_Tspan extends XML_SvgToPDF_Base { var $x = false; var $y = false; var $args = array(); // arguments.. + var $role; + function fromXmlNode($node) { parent::fromXmlNode($node); $this->x = false; @@ -64,7 +66,7 @@ class XML_SvgToPDF_Tspan extends XML_SvgToPDF_Base { } - function shift() // disable shifting on text + function shift($x,$y) // disable shifting on text { return; }