Updating TCPDF library

This commit is contained in:
Manuel Cillero 2017-08-10 22:10:45 +02:00
parent 1a57ad7292
commit 052824e4b7
28 changed files with 33338 additions and 968 deletions

View file

@ -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.' ';
}
@ -1490,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 @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;
}
/**
* 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
@ -1663,64 +1828,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
@ -2535,55 +2642,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
//============================================================+