32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2025-02-04 09:58:26 +00:00
This commit is contained in:
nicolaasuni 2011-06-19 17:16:58 +02:00
parent 5500260a34
commit 0bf02281e7
3 changed files with 38 additions and 45 deletions

View File

@ -1,3 +1,6 @@
5.9.096 (2011-06-19)
- Bug item #3322234 "Surrogate pairs codes in arrUTF8ToUTF16BE" was fixed.
5.9.095 (2011-06-18) 5.9.095 (2011-06-18)
- Numbers alignment for Table-Of-Content methods was improved and fixed. - Numbers alignment for Table-Of-Content methods was improved and fixed.
- Font subsetting was fixed to include all parts of composite fonts. - Font subsetting was fixed to include all parts of composite fonts.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 5.9.095 Version: 5.9.096
Release date: 2011-06-18 Release date: 2011-06-19
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2011: Copyright (c) 2002-2011:

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.9.095 // Version : 5.9.096
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2011-06-18 // Last Update : 2011-06-19
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS. // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 + YOU CAN'T REMOVE ANY TCPDF COPYRIGHT NOTICE OR LINK FROM THE GENERATED PDF DOCUMENTS.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -134,7 +134,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 5.9.095 * @version 5.9.096
*/ */
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -146,7 +146,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.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 5.9.095 * @version 5.9.096
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -157,7 +157,7 @@ class TCPDF {
* Current TCPDF version. * Current TCPDF version.
* @private * @private
*/ */
private $tcpdf_version = '5.9.095'; private $tcpdf_version = '5.9.096';
// Protected properties // Protected properties
@ -9516,15 +9516,15 @@ class TCPDF {
$offset = $table['loca']['offset']; $offset = $table['loca']['offset'];
if ($short_offset) { if ($short_offset) {
// short version // short version
$n = $table['loca']['length'] / 2; // numGlyphs + 1 $tot_num_glyphs = ($table['loca']['length'] / 2); // numGlyphs + 1
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $tot_num_glyphs; ++$i) {
$indexToLoc[$i] = $this->_getUSHORT($font, $offset) * 2; $indexToLoc[$i] = $this->_getUSHORT($font, $offset) * 2;
$offset += 2; $offset += 2;
} }
} else { } else {
// long version // long version
$n = $table['loca']['length'] / 4; // numGlyphs + 1 $tot_num_glyphs = ($table['loca']['length'] / 4); // numGlyphs + 1
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $tot_num_glyphs; ++$i) {
$indexToLoc[$i] = $this->_getULONG($font, $offset); $indexToLoc[$i] = $this->_getULONG($font, $offset);
$offset += 4; $offset += 4;
} }
@ -9556,8 +9556,8 @@ class TCPDF {
switch ($format) { switch ($format) {
case 0: { // Format 0: Byte encoding table case 0: { // Format 0: Byte encoding table
$offset += 4; // skip length and version/language $offset += 4; // skip length and version/language
for ($k = 0; $k < 256; ++$k) { for ($c = 0; $c < 256; ++$c) {
if (isset($subsetchars[$k])) { if (isset($subsetchars[$c])) {
$g = $this->_getBYTE($font, $offset); $g = $this->_getBYTE($font, $offset);
$subsetglyphs[$g] = true; $subsetglyphs[$g] = true;
} }
@ -9601,7 +9601,8 @@ class TCPDF {
$k = $subHeaderKeys[$i]; $k = $subHeaderKeys[$i];
if ($k == 0) { if ($k == 0) {
// one byte code // one byte code
if (isset($subsetchars[$i])) { $c = $i;
if (isset($subsetchars[$c])) {
$g = $glyphIndexArray[0]; $g = $glyphIndexArray[0];
$subsetglyphs[$g] = true; $subsetglyphs[$g] = true;
} }
@ -9782,7 +9783,7 @@ class TCPDF {
$new_sga = array(); $new_sga = array();
foreach ($sga as $key => $val) { foreach ($sga as $key => $val) {
if (isset($indexToLoc[$key])) { if (isset($indexToLoc[$key])) {
$offset = $table['glyf']['offset'] + $indexToLoc[$key]; $offset = ($table['glyf']['offset'] + $indexToLoc[$key]);
$numberOfContours = $this->_getSHORT($font, $offset); $numberOfContours = $this->_getSHORT($font, $offset);
$offset += 2; $offset += 2;
if ($numberOfContours < 0) { // composite glyph if ($numberOfContours < 0) { // composite glyph
@ -9792,10 +9793,6 @@ class TCPDF {
$offset += 2; $offset += 2;
$glyphIndex = $this->_getUSHORT($font, $offset); $glyphIndex = $this->_getUSHORT($font, $offset);
$offset += 2; $offset += 2;
if (!isset($subsetglyphs[($glyphIndex - 1)])) {
// add missing glyphs
$new_sga[($glyphIndex - 1)] = true;
}
if (!isset($subsetglyphs[$glyphIndex])) { if (!isset($subsetglyphs[$glyphIndex])) {
// add missing glyphs // add missing glyphs
$new_sga[$glyphIndex] = true; $new_sga[$glyphIndex] = true;
@ -9815,42 +9812,32 @@ class TCPDF {
} }
} while ($flags & 32); } while ($flags & 32);
} }
} else {
unset($subsetglyphs[$key]);
} }
} }
$subsetglyphs += $new_sga; $subsetglyphs += $new_sga;
} }
// sort glyphs by key (and remove duplicates) // sort glyphs by key (and remove duplicates)
ksort($subsetglyphs); ksort($subsetglyphs);
// build new glyf table with only used glyphs // build new glyf and loca tables
$glyf = ''; $glyf = '';
$glyfSize = 0;
// create new empty indexToLoc table
$newIndexToLoc = array_fill(0, count($indexToLoc), 0);
$goffset = 0;
foreach ($subsetglyphs as $glyphID => $val) {
if (isset($indexToLoc[$glyphID]) AND isset($indexToLoc[($glyphID + 1)])) {
$start = $indexToLoc[$glyphID];
$length = ($indexToLoc[($glyphID + 1)] - $start);
$glyf .= substr($font, ($table['glyf']['offset'] + $start), $length);
$newIndexToLoc[$glyphID] = $goffset;
$goffset += $length;
}
}
// build new loca table
$loca = ''; $loca = '';
if ($short_offset) { $offset = 0;
foreach ($newIndexToLoc as $glyphID => $offset) { $glyf_offset = $table['glyf']['offset'];
$loca .= pack('n', ($offset / 2)); for ($i = 0; $i < $tot_num_glyphs; ++$i) {
} if (isset($subsetglyphs[$i])) {
$length = ($indexToLoc[($i + 1)] - $indexToLoc[$i]);
$glyf .= substr($font, ($glyf_offset + $indexToLoc[$i]), $length);
} else {
$length = 0;
}
if ($short_offset) {
$loca .= pack('n', ($offset / 2));
} else { } else {
foreach ($newIndexToLoc as $glyphID => $offset) {
$loca .= pack('N', $offset); $loca .= pack('N', $offset);
} }
$offset += $length;
} }
// array of table names to preserve (loca and glyf tables will be added later) // array of table names to preserve (loca and glyf tables will be added later)
// additional maps includes: 'cmap', 'name', 'OS/2', 'post';
// the cmap table is not needed and shall not be present, since the mapping from character codes to glyph descriptions is provided separately // the cmap table is not needed and shall not be present, since the mapping from character codes to glyph descriptions is provided separately
$table_names = array ('head', 'hhea', 'hmtx', 'maxp', 'cvt ', 'fpgm', 'prep'); // minimum required table names $table_names = array ('head', 'hhea', 'hmtx', 'maxp', 'cvt ', 'fpgm', 'prep'); // minimum required table names
// get the tables to preserve // get the tables to preserve
@ -10084,11 +10071,11 @@ class TCPDF {
if ((!$compressed) AND (isset($info['length2']))) { if ((!$compressed) AND (isset($info['length2']))) {
$header = (ord($font{0}) == 128); $header = (ord($font{0}) == 128);
if ($header) { if ($header) {
//Strip first binary header // strip first binary header
$font = substr($font, 6); $font = substr($font, 6);
} }
if ($header AND (ord($font{$info['length1']}) == 128)) { if ($header AND (ord($font{$info['length1']}) == 128)) {
//Strip second binary header // strip second binary header
$font = substr($font, 0, $info['length1']).substr($font, ($info['length1'] + 6)); $font = substr($font, 0, $info['length1']).substr($font, ($info['length1'] + 6));
} }
} elseif ($info['subset'] AND ((!$compressed) OR ($compressed AND function_exists('gzcompress')))) { } elseif ($info['subset'] AND ((!$compressed) OR ($compressed AND function_exists('gzcompress')))) {
@ -10102,7 +10089,10 @@ class TCPDF {
$fontinfo = $this->getFontBuffer($fontkey); $fontinfo = $this->getFontBuffer($fontkey);
$subsetchars += $fontinfo['subsetchars']; $subsetchars += $fontinfo['subsetchars'];
} }
// rebuild a font subset
$font = $this->_getTrueTypeFontSubset($font, $subsetchars); $font = $this->_getTrueTypeFontSubset($font, $subsetchars);
// calculate new font lenght
$info['length1'] = strlen($font);
if ($compressed) { if ($compressed) {
// recompress font // recompress font
$font = gzcompress($font); $font = gzcompress($font);
@ -11799,7 +11789,7 @@ class TCPDF {
$outstr .= chr($char & 0xFF); $outstr .= chr($char & 0xFF);
} else { } else {
$char -= 0x10000; $char -= 0x10000;
$w1 = 0xD800 | ($char >> 0x10); $w1 = 0xD800 | ($char >> 0x0a);
$w2 = 0xDC00 | ($char & 0x3FF); $w2 = 0xDC00 | ($char & 0x3FF);
$outstr .= chr($w1 >> 0x08); $outstr .= chr($w1 >> 0x08);
$outstr .= chr($w1 & 0xFF); $outstr .= chr($w1 & 0xFF);