32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-01 03:02:32 +00:00

6.0.007 (2013-03-29)

- HTML/CSS font size conversion were improved.
This commit is contained in:
nicolaasuni 2013-03-29 17:30:37 +00:00
parent c4e39163a7
commit db650c6dfa
6 changed files with 138 additions and 68 deletions

View File

@ -1,3 +1,6 @@
6.0.007 (2013-03-29)
- HTML/CSS font size conversion were improved.
6.0.006 (2013-03-27) 6.0.006 (2013-03-27)
- Bug related to SVG and EPS files on xobjects were fixed. - Bug related to SVG and EPS files on xobjects were fixed.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 6.0.006 Version: 6.0.007
Release date: 2013-03-27 Release date: 2013-03-29
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2013: Copyright (c) 2002-2013:

View File

@ -1,6 +1,6 @@
{ {
"name": "tecnick.com/tcpdf", "name": "tecnick.com/tcpdf",
"version": "6.0.006", "version": "6.0.007",
"homepage": "http://www.tcpdf.org/", "homepage": "http://www.tcpdf.org/",
"type": "library", "type": "library",
"description": "TCPDF is a PHP class for generating PDF documents.", "description": "TCPDF is a PHP class for generating PDF documents.",

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf_fonts.php // File name : tcpdf_fonts.php
// Version : 1.0.003 // Version : 1.0.004
// Begin : 2008-01-01 // Begin : 2008-01-01
// Last Update : 2013-03-26 // Last Update : 2013-03-29
// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -42,7 +42,7 @@
* @class TCPDF_FONTS * @class TCPDF_FONTS
* Font methods for TCPDF library. * Font methods for TCPDF library.
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @version 1.0.002 * @version 1.0.004
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF_FONTS { class TCPDF_FONTS {
@ -2476,6 +2476,55 @@ class TCPDF_FONTS {
return $ordarray; 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 CLASS --- } // --- END OF CLASS ---
//============================================================+ //============================================================+

View File

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version. * Current TCPDF version.
* @private static * @private static
*/ */
private static $tcpdf_version = '6.0.006'; private static $tcpdf_version = '6.0.007';
/** /**
* String alias for total number of pages. * String alias for total number of pages.

140
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 6.0.006 // Version : 6.0.007
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2013-03-26 // Last Update : 2013-03-29
// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -139,7 +139,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 6.0.006 * @version 6.0.007
*/ */
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
@ -168,7 +168,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php');
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br> * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 6.0.006 * @version 6.0.007
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -16007,11 +16007,11 @@ class TCPDF {
break; break;
} }
case 'wider': { case 'wider': {
$val = $parent + 10; $val = ($parent + 10);
break; break;
} }
case 'narrower': { case 'narrower': {
$val = $parent - 10; $val = ($parent - 10);
break; break;
} }
case 'inherit': { case 'inherit': {
@ -16029,6 +16029,62 @@ class TCPDF {
return $val; return $val;
} }
/**
* Convert HTML string containing font size value to points
* @param $val (string) String containing font size value and unit.
* @param $refsize (float) Reference font size in points.
* @param $parent_size (float) Parent font size in points.
* @param $defaultunit (string) Default unit (can be one of the following: %, em, ex, px, in, mm, pc, pt).
* @return float value in points
* @public
*/
public function getHTMLFontUnits($val, $refsize=12, $parent_size=12, $defaultunit='pt') {
$refsize = TCPDF_FONTS::getFontRefSize($refsize);
$parent_size = TCPDF_FONTS::getFontRefSize($parent_size, $refsize);
switch ($val) {
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 = ($parent_size - 3);
break;
}
case 'larger': {
$size = ($parent_size + 3);
break;
}
default: {
$size = $this->getHTMLUnitToUnits($val, $parent_size, $defaultunit, true);
}
}
return $size;
}
/** /**
* Returns the HTML DOM array. * Returns the HTML DOM array.
* @param $html (string) html code * @param $html (string) html code
@ -16379,49 +16435,7 @@ class TCPDF {
// font size // font size
if (isset($dom[$key]['style']['font-size'])) { if (isset($dom[$key]['style']['font-size'])) {
$fsize = trim($dom[$key]['style']['font-size']); $fsize = trim($dom[$key]['style']['font-size']);
switch ($fsize) { $dom[$key]['fontsize'] = $this->getHTMLFontUnits($fsize, $dom[0]['fontsize'], $dom[$parentkey]['fontsize'], 'pt');
// absolute-size
case 'xx-small': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] - 4;
break;
}
case 'x-small': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] - 3;
break;
}
case 'small': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] - 2;
break;
}
case 'medium': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'];
break;
}
case 'large': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] + 2;
break;
}
case 'x-large': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] + 4;
break;
}
case 'xx-large': {
$dom[$key]['fontsize'] = $dom[0]['fontsize'] + 6;
break;
}
// relative-size
case 'smaller': {
$dom[$key]['fontsize'] = $dom[$parentkey]['fontsize'] - 3;
break;
}
case 'larger': {
$dom[$key]['fontsize'] = $dom[$parentkey]['fontsize'] + 3;
break;
}
default: {
$dom[$key]['fontsize'] = $this->getHTMLUnitToUnits($fsize, $dom[$parentkey]['fontsize'], 'pt', true);
}
}
} }
// font-stretch // font-stretch
if (isset($dom[$key]['style']['font-stretch'])) { if (isset($dom[$key]['style']['font-stretch'])) {
@ -19977,10 +19991,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
/** /**
* Convert HTML string containing value and unit of measure to user's units or points. * Convert HTML string containing value and unit of measure to user's units or points.
* @param $htmlval (string) string containing values and unit * @param $htmlval (string) String containing values and unit.
* @param $refsize (string) reference value in points * @param $refsize (string) Reference value in points.
* @param $defaultunit (string) default unit (can be one of the following: %, em, ex, px, in, mm, pc, pt). * @param $defaultunit (string) Default unit (can be one of the following: %, em, ex, px, in, mm, pc, pt).
* @param $points (boolean) if true returns points, otherwise returns value in user's units * @param $points (boolean) If true returns points, otherwise returns value in user's units.
* @return float value in user's unit or point if $points=true * @return float value in user's unit or point if $points=true
* @public * @public
* @since 4.4.004 (2008-12-10) * @since 4.4.004 (2008-12-10)
@ -19990,9 +20004,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$retval = 0; $retval = 0;
$value = 0; $value = 0;
$unit = 'px'; $unit = 'px';
$k = $this->k;
if ($points) { if ($points) {
$k = 1; $k = 1;
} else {
$k = $this->k;
} }
if (in_array($defaultunit, $supportedunits)) { if (in_array($defaultunit, $supportedunits)) {
$unit = $defaultunit; $unit = $defaultunit;
@ -20020,37 +20035,40 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
// height of lower case 'x' (about half the font-size) // height of lower case 'x' (about half the font-size)
case 'ex': { case 'ex': {
$retval = $value * ($refsize / 2); $retval = ($value * ($refsize / 2));
break; break;
} }
// absolute-size // absolute-size
case 'in': { case 'in': {
$retval = ($value * $this->dpi) / $k; $retval = (($value * $this->dpi) / $k);
break; break;
} }
// centimeters // centimeters
case 'cm': { case 'cm': {
$retval = ($value / 2.54 * $this->dpi) / $k; $retval = (($value / 2.54 * $this->dpi) / $k);
break; break;
} }
// millimeters // millimeters
case 'mm': { case 'mm': {
$retval = ($value / 25.4 * $this->dpi) / $k; $retval = (($value / 25.4 * $this->dpi) / $k);
break; break;
} }
// one pica is 12 points // one pica is 12 points
case 'pc': { case 'pc': {
$retval = ($value * 12) / $k; $retval = (($value * 12) / $k);
break; break;
} }
// points // points
case 'pt': { case 'pt': {
$retval = $value / $k; $retval = ($value / $k);
break; break;
} }
// pixels // pixels
case 'px': { case 'px': {
$retval = $this->pixelsToUnits($value); $retval = $this->pixelsToUnits($value);
if ($points) {
$retval *= $this->k;
}
break; break;
} }
} }
@ -23006,7 +23024,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$font_stretch = $svgstyle['font-stretch']; $font_stretch = $svgstyle['font-stretch'];
$font_spacing = $svgstyle['letter-spacing']; $font_spacing = $svgstyle['letter-spacing'];
} }
$font_size = $this->getHTMLUnitToUnits($font_size, $prevsvgstyle['font-size'], $this->svgunit, false) * $this->k; $font_size = $this->getHTMLFontUnits($font_size, $this->svgstyles[0]['font-size'], $prevsvgstyle['font-size'], $this->svgunit);
$font_stretch = $this->getCSSFontStretching($font_stretch, $svgstyle['font-stretch']); $font_stretch = $this->getCSSFontStretching($font_stretch, $svgstyle['font-stretch']);
$font_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle['letter-spacing']); $font_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle['letter-spacing']);
switch ($font_style) { switch ($font_style) {