32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-25 22:07:33 +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)
- 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
Version: 6.0.006
Release date: 2013-03-27
Version: 6.0.007
Release date: 2013-03-29
Author: Nicola Asuni
Copyright (c) 2002-2013:

View File

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

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf_fonts.php
// Version : 1.0.003
// Version : 1.0.004
// 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
// 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.002
* @version 1.0.004
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_FONTS {
@ -2476,6 +2476,55 @@ 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 CLASS ---
//============================================================+

View File

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

140
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 6.0.006
// Version : 6.0.007
// 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
// 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>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 6.0.006
* @version 6.0.007
*/
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>
* @package com.tecnick.tcpdf
* @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
*/
class TCPDF {
@ -16007,11 +16007,11 @@ class TCPDF {
break;
}
case 'wider': {
$val = $parent + 10;
$val = ($parent + 10);
break;
}
case 'narrower': {
$val = $parent - 10;
$val = ($parent - 10);
break;
}
case 'inherit': {
@ -16029,6 +16029,62 @@ class TCPDF {
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.
* @param $html (string) html code
@ -16379,49 +16435,7 @@ class TCPDF {
// font size
if (isset($dom[$key]['style']['font-size'])) {
$fsize = trim($dom[$key]['style']['font-size']);
switch ($fsize) {
// 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);
}
}
$dom[$key]['fontsize'] = $this->getHTMLFontUnits($fsize, $dom[0]['fontsize'], $dom[$parentkey]['fontsize'], 'pt');
}
// 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.
* @param $htmlval (string) string containing values and unit
* @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 $points (boolean) if true returns points, otherwise returns value in user's units
* @param $htmlval (string) String containing values and unit.
* @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 $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
* @public
* @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;
$value = 0;
$unit = 'px';
$k = $this->k;
if ($points) {
$k = 1;
} else {
$k = $this->k;
}
if (in_array($defaultunit, $supportedunits)) {
$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)
case 'ex': {
$retval = $value * ($refsize / 2);
$retval = ($value * ($refsize / 2));
break;
}
// absolute-size
case 'in': {
$retval = ($value * $this->dpi) / $k;
$retval = (($value * $this->dpi) / $k);
break;
}
// centimeters
case 'cm': {
$retval = ($value / 2.54 * $this->dpi) / $k;
$retval = (($value / 2.54 * $this->dpi) / $k);
break;
}
// millimeters
case 'mm': {
$retval = ($value / 25.4 * $this->dpi) / $k;
$retval = (($value / 25.4 * $this->dpi) / $k);
break;
}
// one pica is 12 points
case 'pc': {
$retval = ($value * 12) / $k;
$retval = (($value * 12) / $k);
break;
}
// points
case 'pt': {
$retval = $value / $k;
$retval = ($value / $k);
break;
}
// pixels
case 'px': {
$retval = $this->pixelsToUnits($value);
if ($points) {
$retval *= $this->k;
}
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_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_spacing = $this->getCSSFontSpacing($font_spacing, $svgstyle['letter-spacing']);
switch ($font_style) {