Update TCPDF.
This commit is contained in:
@@ -710,13 +710,13 @@ class Datamatrix {
|
||||
$pos = 0; // current position
|
||||
$cw = array(); // array of codewords to be returned
|
||||
$cw_num = 0; // number of data codewords
|
||||
$data_lenght = strlen($data); // number of chars
|
||||
while ($pos < $data_lenght) {
|
||||
$data_length = strlen($data); // number of chars
|
||||
while ($pos < $data_length) {
|
||||
// set last used encoding
|
||||
$this->last_enc = $enc;
|
||||
switch ($enc) {
|
||||
case ENC_ASCII: { // STEP B. While in ASCII encodation
|
||||
if (($data_lenght > 1) AND ($pos < ($data_lenght - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) {
|
||||
if (($data_length > 1) AND ($pos < ($data_length - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) {
|
||||
// 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode.
|
||||
$cw[] = (intval(substr($data, $pos, 2)) + 130);
|
||||
++$cw_num;
|
||||
@@ -820,7 +820,7 @@ class Datamatrix {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (($p > 0) AND ($epos < $data_lenght));
|
||||
} while (($p > 0) AND ($epos < $data_length));
|
||||
// process last data (if any)
|
||||
if ($p > 0) {
|
||||
// get remaining number of data symbols
|
||||
@@ -870,10 +870,10 @@ class Datamatrix {
|
||||
break;
|
||||
}
|
||||
case ENC_EDF: { // F. While in EDIFACT (EDF) encodation
|
||||
// initialize temporary array with 0 lenght
|
||||
// initialize temporary array with 0 length
|
||||
$temp_cw = array();
|
||||
$epos = $pos;
|
||||
$field_lenght = 0;
|
||||
$field_length = 0;
|
||||
$newenc = $enc;
|
||||
do {
|
||||
// 2. process the next character in EDIFACT encodation.
|
||||
@@ -881,21 +881,21 @@ class Datamatrix {
|
||||
if ($this->isCharMode($chr, ENC_EDF)) {
|
||||
++$epos;
|
||||
$temp_cw[] = $chr;
|
||||
++$field_lenght;
|
||||
++$field_length;
|
||||
}
|
||||
if (($field_lenght == 4) OR ($epos == $data_lenght) OR !$this->isCharMode($chr, ENC_EDF)) {
|
||||
if (($epos == $data_lenght) AND ($field_lenght < 3)) {
|
||||
if (($field_length == 4) OR ($epos == $data_length) OR !$this->isCharMode($chr, ENC_EDF)) {
|
||||
if (($epos == $data_length) AND ($field_length < 3)) {
|
||||
$enc = ENC_ASCII;
|
||||
$cw[] = $this->getSwitchEncodingCodeword($enc);
|
||||
++$cw_num;
|
||||
break;
|
||||
}
|
||||
if ($field_lenght < 4) {
|
||||
if ($field_length < 4) {
|
||||
// set unlatch character
|
||||
$temp_cw[] = 0x1f;
|
||||
++$field_lenght;
|
||||
++$field_length;
|
||||
// fill empty characters
|
||||
for ($i = $field_lenght; $i < 4; ++$i) {
|
||||
for ($i = $field_length; $i < 4; ++$i) {
|
||||
$temp_cw[] = 0;
|
||||
}
|
||||
$enc = ENC_ASCII;
|
||||
@@ -919,19 +919,19 @@ class Datamatrix {
|
||||
}
|
||||
$temp_cw = array();
|
||||
$pos = $epos;
|
||||
$field_lenght = 0;
|
||||
$field_length = 0;
|
||||
if ($enc == ENC_ASCII) {
|
||||
break; // exit from EDIFACT mode
|
||||
}
|
||||
}
|
||||
} while ($epos < $data_lenght);
|
||||
} while ($epos < $data_length);
|
||||
break;
|
||||
}
|
||||
case ENC_BASE256: { // G. While in Base 256 (B256) encodation
|
||||
// initialize temporary array with 0 lenght
|
||||
// initialize temporary array with 0 length
|
||||
$temp_cw = array();
|
||||
$field_lenght = 0;
|
||||
while (($pos < $data_lenght) AND ($field_lenght <= 1555)) {
|
||||
$field_length = 0;
|
||||
while (($pos < $data_length) AND ($field_length <= 1555)) {
|
||||
$newenc = $this->lookAheadTest($data, $pos, $enc);
|
||||
if ($newenc != $enc) {
|
||||
// 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode.
|
||||
@@ -942,16 +942,16 @@ class Datamatrix {
|
||||
$chr = ord($data[$pos]);
|
||||
++$pos;
|
||||
$temp_cw[] = $chr;
|
||||
++$field_lenght;
|
||||
++$field_length;
|
||||
}
|
||||
}
|
||||
// set field lenght
|
||||
if ($field_lenght <= 249) {
|
||||
$cw[] = $this->get255StateCodeword($field_lenght, ($cw_num + 1));
|
||||
// set field length
|
||||
if ($field_length <= 249) {
|
||||
$cw[] = $this->get255StateCodeword($field_length, ($cw_num + 1));
|
||||
++$cw_num;
|
||||
} else {
|
||||
$cw[] = $this->get255StateCodeword((floor($field_lenght / 250) + 249), ($cw_num + 1));
|
||||
$cw[] = $this->get255StateCodeword(($field_lenght % 250), ($cw_num + 2));
|
||||
$cw[] = $this->get255StateCodeword((floor($field_length / 250) + 249), ($cw_num + 1));
|
||||
$cw[] = $this->get255StateCodeword(($field_length % 250), ($cw_num + 2));
|
||||
$cw_num += 2;
|
||||
}
|
||||
if (!empty($temp_cw)) {
|
||||
|
||||
@@ -636,7 +636,7 @@ class PDF417 {
|
||||
// add macro section
|
||||
$codewords = array_merge($codewords, $macrocw);
|
||||
}
|
||||
// Symbol Lenght Descriptor (number of data codewords including Symbol Lenght Descriptor and pad codewords)
|
||||
// Symbol Length Descriptor (number of data codewords including Symbol Length Descriptor and pad codewords)
|
||||
$sld = $size - $errsize;
|
||||
// add symbol length description
|
||||
array_unshift($codewords, $sld);
|
||||
@@ -740,16 +740,6 @@ class PDF417 {
|
||||
* @protected
|
||||
*/
|
||||
protected function getErrorCorrectionLevel($ecl, $numcw) {
|
||||
// get maximum correction level
|
||||
$maxecl = 8; // starting error level
|
||||
$maxerrsize = (928 - $numcw); // available codewords for error
|
||||
while ($maxecl > 0) {
|
||||
$errsize = (2 << $ecl);
|
||||
if ($maxerrsize >= $errsize) {
|
||||
break;
|
||||
}
|
||||
--$maxecl;
|
||||
}
|
||||
// check for automatic levels
|
||||
if (($ecl < 0) OR ($ecl > 8)) {
|
||||
if ($numcw < 41) {
|
||||
@@ -764,6 +754,16 @@ class PDF417 {
|
||||
$ecl = $maxecl;
|
||||
}
|
||||
}
|
||||
// get maximum correction level
|
||||
$maxecl = 8; // starting error level
|
||||
$maxerrsize = (928 - $numcw); // available codewords for error
|
||||
while ($maxecl > 0) {
|
||||
$errsize = (2 << $ecl);
|
||||
if ($maxerrsize >= $errsize) {
|
||||
break;
|
||||
}
|
||||
--$maxecl;
|
||||
}
|
||||
if ($ecl > $maxecl) {
|
||||
$ecl = $maxecl;
|
||||
}
|
||||
@@ -772,7 +772,7 @@ class PDF417 {
|
||||
|
||||
/**
|
||||
* Returns the error correction codewords
|
||||
* @param $cw (array) array of codewords including Symbol Lenght Descriptor and pad
|
||||
* @param $cw (array) array of codewords including Symbol Length Descriptor and pad
|
||||
* @param $ecl (int) error correction level 0-8
|
||||
* @return array of error correction codewords
|
||||
* @protected
|
||||
|
||||
@@ -720,6 +720,7 @@ class QRcode {
|
||||
protected function encodeMask($mask) {
|
||||
$spec = array(0, 0, 0, 0, 0);
|
||||
$this->datacode = $this->getByteStream($this->items);
|
||||
|
||||
if (is_null($this->datacode)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -358,7 +358,7 @@ class TCPDF_COLORS {
|
||||
$color_code = self::$webcolor[$color];
|
||||
} else {
|
||||
// spot color
|
||||
$returncolor = self::getSpotColor($color, $spotc);
|
||||
$returncolor = self::getSpotColor($hcolor, $spotc);
|
||||
if ($returncolor === false) {
|
||||
$returncolor = $defcol;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class TCPDF_FILTERS {
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCIIHexDecode($data) {
|
||||
// intialize string to return
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
@@ -188,7 +188,7 @@ class TCPDF_FILTERS {
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCII85Decode($data) {
|
||||
// intialize string to return
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
@@ -272,14 +272,14 @@ class TCPDF_FILTERS {
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterLZWDecode($data) {
|
||||
// intialize string to return
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
// convert string to binary string
|
||||
$bitstring = '';
|
||||
for ($i = 0; $i < $data_length; ++$i) {
|
||||
$bitstring .= sprintf('%08b', ord($data{$i}));
|
||||
$bitstring .= sprintf('%08b', ord($data[$i]));
|
||||
}
|
||||
// get the number of bits
|
||||
$data_length = strlen($bitstring);
|
||||
@@ -353,7 +353,7 @@ class TCPDF_FILTERS {
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterFlateDecode($data) {
|
||||
// intialize string to return
|
||||
// initialize string to return
|
||||
$decoded = @gzuncompress($data);
|
||||
if ($decoded === false) {
|
||||
self::Error('decodeFilterFlateDecode: invalid code');
|
||||
@@ -369,14 +369,14 @@ class TCPDF_FILTERS {
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterRunLengthDecode($data) {
|
||||
// intialize string to return
|
||||
// initialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
$i = 0;
|
||||
while($i < $data_length) {
|
||||
// get current byte value
|
||||
$byte = ord($data{$i});
|
||||
$byte = ord($data[$i]);
|
||||
if ($byte == 128) {
|
||||
// a length value of 128 denote EOD
|
||||
break;
|
||||
@@ -389,7 +389,7 @@ class TCPDF_FILTERS {
|
||||
} else {
|
||||
// if length is in the range 129 to 255,
|
||||
// the following single byte shall be copied 257 - length (2 to 128) times during decompression
|
||||
$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
|
||||
$decoded .= str_repeat($data[($i + 1)], (257 - $byte));
|
||||
// move to next block
|
||||
$i += 2;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_fonts.php
|
||||
// Version : 1.0.013
|
||||
// Version : 1.1.0
|
||||
// Begin : 2008-01-01
|
||||
// Last Update : 2014-05-23
|
||||
// Last Update : 2014-12-10
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
@@ -42,7 +42,7 @@
|
||||
* @class TCPDF_FONTS
|
||||
* Font methods for TCPDF library.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.013
|
||||
* @version 1.1.0
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_FONTS {
|
||||
@@ -70,7 +70,7 @@ class TCPDF_FONTS {
|
||||
* @public static
|
||||
*/
|
||||
public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
|
||||
if (!file_exists($fontfile)) {
|
||||
if (!TCPDF_STATIC::file_exists($fontfile)) {
|
||||
// Could not find file
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class TCPDF_FONTS {
|
||||
$outpath = self::_getfontpath();
|
||||
}
|
||||
// check if this font already exist
|
||||
if (@file_exists($outpath.$font_name.'.php')) {
|
||||
if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) {
|
||||
// this font already exist (delete it from fonts folder to rebuild it)
|
||||
return $font_name;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class TCPDF_FONTS {
|
||||
$enc_target = TCPDF_FONT_DATA::$encmap[$enc];
|
||||
$last = 0;
|
||||
for ($i = 32; $i <= 255; ++$i) {
|
||||
if ($enc_target != $enc_ref[$i]) {
|
||||
if ($enc_target[$i] != $enc_ref[$i]) {
|
||||
if ($i != ($last + 1)) {
|
||||
$fmetric['diff'] .= $i.' ';
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class TCPDF_FONTS {
|
||||
$data .= $encrypted;
|
||||
// store compressed font
|
||||
$fmetric['file'] .= '.z';
|
||||
$fp = fopen($outpath.$fmetric['file'], 'wb');
|
||||
$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
|
||||
fwrite($fp, gzcompress($data));
|
||||
fclose($fp);
|
||||
// get font info
|
||||
@@ -354,6 +354,11 @@ class TCPDF_FONTS {
|
||||
$fmetric['AvgWidth'] = round($fmetric['AvgWidth'] / count($cwidths));
|
||||
} else {
|
||||
// ---------- TRUE TYPE ----------
|
||||
$offset = 0; // offset position of the font data
|
||||
if (TCPDF_STATIC::_getULONG($font, $offset) != 0x10000) {
|
||||
// sfnt version must be 0x00010000 for TrueType version 1.0.
|
||||
return false;
|
||||
}
|
||||
if ($fmetric['type'] != 'cidfont0') {
|
||||
if ($link) {
|
||||
// creates a symbolic link to the existing font
|
||||
@@ -361,16 +366,11 @@ class TCPDF_FONTS {
|
||||
} else {
|
||||
// store compressed font
|
||||
$fmetric['file'] .= '.z';
|
||||
$fp = fopen($outpath.$fmetric['file'], 'wb');
|
||||
$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['file'], 'wb');
|
||||
fwrite($fp, gzcompress($font));
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
$offset = 0; // offset position of the font data
|
||||
if (TCPDF_STATIC::_getULONG($font, $offset) != 0x10000) {
|
||||
// sfnt version must be 0x00010000 for TrueType version 1.0.
|
||||
return false;
|
||||
}
|
||||
$offset += 4;
|
||||
// get number of tables
|
||||
$numTables = TCPDF_STATIC::_getUSHORT($font, $offset);
|
||||
@@ -435,6 +435,10 @@ class TCPDF_FONTS {
|
||||
$tot_num_glyphs = floor($table['loca']['length'] / 2); // numGlyphs + 1
|
||||
for ($i = 0; $i < $tot_num_glyphs; ++$i) {
|
||||
$indexToLoc[$i] = TCPDF_STATIC::_getUSHORT($font, $offset) * 2;
|
||||
if (isset($indexToLoc[($i - 1)]) && ($indexToLoc[$i] == $indexToLoc[($i - 1)])) {
|
||||
// the last glyph didn't have an outline
|
||||
unset($indexToLoc[($i - 1)]);
|
||||
}
|
||||
$offset += 2;
|
||||
}
|
||||
} else {
|
||||
@@ -442,6 +446,10 @@ class TCPDF_FONTS {
|
||||
$tot_num_glyphs = floor($table['loca']['length'] / 4); // numGlyphs + 1
|
||||
for ($i = 0; $i < $tot_num_glyphs; ++$i) {
|
||||
$indexToLoc[$i] = TCPDF_STATIC::_getULONG($font, $offset);
|
||||
if (isset($indexToLoc[($i - 1)]) && ($indexToLoc[$i] == $indexToLoc[($i - 1)])) {
|
||||
// the last glyph didn't have an outline
|
||||
unset($indexToLoc[($i - 1)]);
|
||||
}
|
||||
$offset += 4;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +665,7 @@ class TCPDF_FONTS {
|
||||
$glyphIdArray[$k] = TCPDF_STATIC::_getUSHORT($font, $offset);
|
||||
$offset += 2;
|
||||
}
|
||||
for ($k = 0; $k < $segCount; ++$k) {
|
||||
for ($k = 0; $k < $segCount - 1; ++$k) {
|
||||
for ($c = $startCount[$k]; $c <= $endCount[$k]; ++$c) {
|
||||
if ($idRangeOffset[$k] == 0) {
|
||||
$g = ($idDelta[$k] + $c) % 65536;
|
||||
@@ -877,7 +885,7 @@ class TCPDF_FONTS {
|
||||
$cidtogidmap = self::updateCIDtoGIDmap($cidtogidmap, $cid, $ctg[$cid]);
|
||||
}
|
||||
// store compressed CIDToGIDMap
|
||||
$fp = fopen($outpath.$fmetric['ctg'], 'wb');
|
||||
$fp = TCPDF_STATIC::fopenLocal($outpath.$fmetric['ctg'], 'wb');
|
||||
fwrite($fp, gzcompress($cidtogidmap));
|
||||
fclose($fp);
|
||||
}
|
||||
@@ -903,7 +911,7 @@ class TCPDF_FONTS {
|
||||
$pfile .= '$cw=array('.substr($fmetric['cw'], 1).');'."\n";
|
||||
$pfile .= '// --- EOF ---'."\n";
|
||||
// store file
|
||||
$fp = fopen($outpath.$font_name.'.php', 'w');
|
||||
$fp = TCPDF_STATIC::fopenLocal($outpath.$font_name.'.php', 'w');
|
||||
fwrite($fp, $pfile);
|
||||
fclose($fp);
|
||||
// return TCPDF font name
|
||||
@@ -1482,6 +1490,171 @@ class TCPDF_FONTS {
|
||||
return '/W ['.$w.' ]';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update the CIDToGIDMap string with a new value.
|
||||
* @param $map (string) CIDToGIDMap.
|
||||
* @param $cid (int) CID value.
|
||||
* @param $gid (int) GID value.
|
||||
* @return (string) CIDToGIDMap.
|
||||
* @author Nicola Asuni
|
||||
* @since 5.9.123 (2011-09-29)
|
||||
* @public static
|
||||
*/
|
||||
public static function updateCIDtoGIDmap($map, $cid, $gid) {
|
||||
if (($cid >= 0) AND ($cid <= 0xFFFF) AND ($gid >= 0)) {
|
||||
if ($gid > 0xFFFF) {
|
||||
$gid -= 0x10000;
|
||||
}
|
||||
$map[($cid * 2)] = chr($gid >> 8);
|
||||
$map[(($cid * 2) + 1)] = chr($gid & 0xFF);
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return fonts path
|
||||
* @return string
|
||||
* @public static
|
||||
*/
|
||||
public static function _getfontpath() {
|
||||
if (!defined('K_PATH_FONTS') AND is_dir($fdir = realpath(dirname(__FILE__).'/../fonts'))) {
|
||||
if (substr($fdir, -1) != '/') {
|
||||
$fdir .= '/';
|
||||
}
|
||||
define('K_PATH_FONTS', $fdir);
|
||||
}
|
||||
return defined('K_PATH_FONTS') ? K_PATH_FONTS : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return font full path
|
||||
* @param $file (string) Font file name.
|
||||
* @param $fontdir (string) Font directory (set to false fto search on default directories)
|
||||
* @return string Font full path or empty string
|
||||
* @author Nicola Asuni
|
||||
* @since 6.0.025
|
||||
* @public static
|
||||
*/
|
||||
public static function getFontFullPath($file, $fontdir=false) {
|
||||
$fontfile = '';
|
||||
// search files on various directories
|
||||
if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) {
|
||||
$fontfile = $fontdir.$file;
|
||||
} elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) {
|
||||
$fontfile = self::_getfontpath().$file;
|
||||
} elseif (@TCPDF_STATIC::file_exists($file)) {
|
||||
$fontfile = $file;
|
||||
}
|
||||
return $fontfile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a reference font size.
|
||||
* @param $size (string) String containing font size value.
|
||||
* @param $refsize (float) Reference font size in points.
|
||||
* @return float value in points
|
||||
* @public static
|
||||
*/
|
||||
public static function getFontRefSize($size, $refsize=12) {
|
||||
switch ($size) {
|
||||
case 'xx-small': {
|
||||
$size = ($refsize - 4);
|
||||
break;
|
||||
}
|
||||
case 'x-small': {
|
||||
$size = ($refsize - 3);
|
||||
break;
|
||||
}
|
||||
case 'small': {
|
||||
$size = ($refsize - 2);
|
||||
break;
|
||||
}
|
||||
case 'medium': {
|
||||
$size = $refsize;
|
||||
break;
|
||||
}
|
||||
case 'large': {
|
||||
$size = ($refsize + 2);
|
||||
break;
|
||||
}
|
||||
case 'x-large': {
|
||||
$size = ($refsize + 4);
|
||||
break;
|
||||
}
|
||||
case 'xx-large': {
|
||||
$size = ($refsize + 6);
|
||||
break;
|
||||
}
|
||||
case 'smaller': {
|
||||
$size = ($refsize - 3);
|
||||
break;
|
||||
}
|
||||
case 'larger': {
|
||||
$size = ($refsize + 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ====================================================================================================================
|
||||
// REIMPLEMENTED
|
||||
// ====================================================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the unicode caracter specified by the value
|
||||
* @param $c (int) UTF-8 value
|
||||
@@ -1491,6 +1664,7 @@ class TCPDF_FONTS {
|
||||
* @public static
|
||||
*/
|
||||
public static function unichr($c, $unicode=true) {
|
||||
$c = intval($c);
|
||||
if (!$unicode) {
|
||||
return chr($c);
|
||||
} elseif ($c <= 0x7F) {
|
||||
@@ -1655,64 +1829,6 @@ class TCPDF_FONTS {
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the CIDToGIDMap string with a new value.
|
||||
* @param $map (string) CIDToGIDMap.
|
||||
* @param $cid (int) CID value.
|
||||
* @param $gid (int) GID value.
|
||||
* @return (string) CIDToGIDMap.
|
||||
* @author Nicola Asuni
|
||||
* @since 5.9.123 (2011-09-29)
|
||||
* @public static
|
||||
*/
|
||||
public static function updateCIDtoGIDmap($map, $cid, $gid) {
|
||||
if (($cid >= 0) AND ($cid <= 0xFFFF) AND ($gid >= 0)) {
|
||||
if ($gid > 0xFFFF) {
|
||||
$gid -= 0x10000;
|
||||
}
|
||||
$map[($cid * 2)] = chr($gid >> 8);
|
||||
$map[(($cid * 2) + 1)] = chr($gid & 0xFF);
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return fonts path
|
||||
* @return string
|
||||
* @public static
|
||||
*/
|
||||
public static function _getfontpath() {
|
||||
if (!defined('K_PATH_FONTS') AND is_dir($fdir = realpath(dirname(__FILE__).'/../fonts'))) {
|
||||
if (substr($fdir, -1) != '/') {
|
||||
$fdir .= '/';
|
||||
}
|
||||
define('K_PATH_FONTS', $fdir);
|
||||
}
|
||||
return defined('K_PATH_FONTS') ? K_PATH_FONTS : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return font full path
|
||||
* @param $file (string) Font file name.
|
||||
* @param $fontdir (string) Font directory (set to false fto search on default directories)
|
||||
* @return string Font full path or empty string
|
||||
* @author Nicola Asuni
|
||||
* @since 6.0.025
|
||||
* @public static
|
||||
*/
|
||||
public static function getFontFullPath($file, $fontdir=false) {
|
||||
$fontfile = '';
|
||||
// search files on various directories
|
||||
if (($fontdir !== false) AND @file_exists($fontdir.$file)) {
|
||||
$fontfile = $fontdir.$file;
|
||||
} elseif (@file_exists(self::_getfontpath().$file)) {
|
||||
$fontfile = self::_getfontpath().$file;
|
||||
} elseif (@file_exists($file)) {
|
||||
$fontfile = $file;
|
||||
}
|
||||
return $fontfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts UTF-8 characters array to array of Latin1 characters array<br>
|
||||
* @param $unicode (array) array containing UTF-8 unicode values
|
||||
@@ -1888,7 +2004,11 @@ class TCPDF_FONTS {
|
||||
$chars = str_split($str);
|
||||
$carr = array_map('ord', $chars);
|
||||
}
|
||||
$currentfont['subsetchars'] += array_fill_keys($carr, true);
|
||||
if (is_array($currentfont['subsetchars']) && is_array($carr)) {
|
||||
$currentfont['subsetchars'] += array_fill_keys($carr, true);
|
||||
} else {
|
||||
$currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr);
|
||||
}
|
||||
return $carr;
|
||||
}
|
||||
|
||||
@@ -2527,55 +2647,6 @@ class TCPDF_FONTS {
|
||||
return $ordarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference font size.
|
||||
* @param $size (string) String containing font size value.
|
||||
* @param $refsize (float) Reference font size in points.
|
||||
* @return float value in points
|
||||
* @public static
|
||||
*/
|
||||
public static function getFontRefSize($size, $refsize=12) {
|
||||
switch ($size) {
|
||||
case 'xx-small': {
|
||||
$size = ($refsize - 4);
|
||||
break;
|
||||
}
|
||||
case 'x-small': {
|
||||
$size = ($refsize - 3);
|
||||
break;
|
||||
}
|
||||
case 'small': {
|
||||
$size = ($refsize - 2);
|
||||
break;
|
||||
}
|
||||
case 'medium': {
|
||||
$size = $refsize;
|
||||
break;
|
||||
}
|
||||
case 'large': {
|
||||
$size = ($refsize + 2);
|
||||
break;
|
||||
}
|
||||
case 'x-large': {
|
||||
$size = ($refsize + 4);
|
||||
break;
|
||||
}
|
||||
case 'xx-large': {
|
||||
$size = ($refsize + 6);
|
||||
break;
|
||||
}
|
||||
case 'smaller': {
|
||||
$size = ($refsize - 3);
|
||||
break;
|
||||
}
|
||||
case 'larger': {
|
||||
$size = ($refsize + 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
} // END OF TCPDF_FONTS CLASS
|
||||
|
||||
//============================================================+
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_images.php
|
||||
// Version : 1.0.003
|
||||
// Version : 1.0.005
|
||||
// Begin : 2002-08-03
|
||||
// Last Update : 2014-04-03
|
||||
// Last Update : 2014-11-15
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
@@ -38,7 +38,7 @@
|
||||
* This is a PHP class that contains static image methods for the TCPDF class.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.003
|
||||
* @version 1.0.005
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@
|
||||
* Static image methods used by the TCPDF class.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
||||
* @version 1.0.003
|
||||
* @version 1.0.005
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_IMAGES {
|
||||
@@ -56,7 +56,7 @@ class TCPDF_IMAGES {
|
||||
* @since 5.0.000 (2010-05-02)
|
||||
* @public static
|
||||
*/
|
||||
public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
|
||||
public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'display', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -97,11 +97,12 @@ class TCPDF_IMAGES {
|
||||
* @public static
|
||||
*/
|
||||
public static function setGDImageTransparency($new_image, $image) {
|
||||
// default transparency color (white)
|
||||
$tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
|
||||
// transparency index
|
||||
$tid = imagecolortransparent($image);
|
||||
// default transparency color
|
||||
$tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
|
||||
if ($tid >= 0) {
|
||||
$palletsize = imagecolorstotal($image);
|
||||
if (($tid >= 0) AND ($tid < $palletsize)) {
|
||||
// get the colors for the transparency index
|
||||
$tcol = imagecolorsforindex($image, $tid);
|
||||
}
|
||||
@@ -115,23 +116,22 @@ class TCPDF_IMAGES {
|
||||
* Convert the loaded image to a PNG and then return a structure for the PDF creator.
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* @param $tempfile (string) Temporary file name.
|
||||
* return image PNG image object.
|
||||
* @since 4.9.016 (2010-04-20)
|
||||
* @public static
|
||||
*/
|
||||
public static function _toPNG($image) {
|
||||
// set temporary image file name
|
||||
$tempname = TCPDF_STATIC::getObjFilename('img');
|
||||
public static function _toPNG($image, $tempfile) {
|
||||
// turn off interlaced mode
|
||||
imageinterlace($image, 0);
|
||||
// create temporary PNG image
|
||||
imagepng($image, $tempname);
|
||||
imagepng($image, $tempfile);
|
||||
// remove image from memory
|
||||
imagedestroy($image);
|
||||
// get PNG image data
|
||||
$retvars = self::_parsepng($tempname);
|
||||
$retvars = self::_parsepng($tempfile);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempname);
|
||||
unlink($tempfile);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
@@ -140,16 +140,16 @@ class TCPDF_IMAGES {
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* @param $quality (int) JPEG quality.
|
||||
* @param $tempfile (string) Temporary file name.
|
||||
* return image JPEG image object.
|
||||
* @public static
|
||||
*/
|
||||
public static function _toJPEG($image, $quality) {
|
||||
$tempname = TCPDF_STATIC::getObjFilename('img');
|
||||
imagejpeg($image, $tempname, $quality);
|
||||
public static function _toJPEG($image, $quality, $tempfile) {
|
||||
imagejpeg($image, $tempfile, $quality);
|
||||
imagedestroy($image);
|
||||
$retvars = self::_parsejpeg($tempname);
|
||||
$retvars = self::_parsejpeg($tempfile);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempname);
|
||||
unlink($tempfile);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
@@ -160,6 +160,10 @@ class TCPDF_IMAGES {
|
||||
* @public static
|
||||
*/
|
||||
public static function _parsejpeg($file) {
|
||||
// check if is a local file
|
||||
if (!@TCPDF_STATIC::file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
$a = getimagesize($file);
|
||||
if (empty($a)) {
|
||||
//Missing or incorrect image file
|
||||
@@ -289,8 +293,8 @@ class TCPDF_IMAGES {
|
||||
$trns = '';
|
||||
$data = '';
|
||||
$icc = false;
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
do {
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
$type = fread($f, 4);
|
||||
if ($type == 'PLTE') {
|
||||
// read palette
|
||||
@@ -307,7 +311,7 @@ class TCPDF_IMAGES {
|
||||
if ($n > 0) {
|
||||
$trns = array();
|
||||
for ($i = 0; $i < $n; ++ $i) {
|
||||
$trns[] = ord($t{$i});
|
||||
$trns[] = ord($t[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,6 +342,7 @@ class TCPDF_IMAGES {
|
||||
} else {
|
||||
TCPDF_STATIC::rfread($f, $n + 4);
|
||||
}
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
} while ($n);
|
||||
if (($colspace == 'Indexed') AND (empty($pal))) {
|
||||
// Missing palette
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user