32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-22 04:45:17 +00:00

6.0.003 (2013-03-20)

- A bug related to non-unicode mode was fixed.
This commit is contained in:
nicolaasuni 2013-03-20 18:27:44 +00:00
parent 1d88afff1d
commit 3fa01d8e99
5 changed files with 51 additions and 39 deletions

View File

@ -1,3 +1,6 @@
6.0.003 (2013-03-20)
- A bug related to non-unicode mode was fixed.
6.0.002 (2013-03-18)
- _getFIXED call on tcpdf_fonts.php was fixed.

View File

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

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf_fonts.php
// Version : 1.0.000
// Version : 1.0.001
// Begin : 2008-01-01
// Last Update : 2013-03-18
// Last Update : 2013-03-20
// 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.000
* @version 1.0.001
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_FONTS {
@ -1758,8 +1758,10 @@ class TCPDF_FONTS {
*/
public static function uniord($uch) {
if (function_exists('mb_convert_encoding')) {
list(, $char) = unpack('N', mb_convert_encoding($uch, 'UCS-4BE', 'UTF-8'));
return $char;
list(, $char) = @unpack('N', mb_convert_encoding($uch, 'UCS-4BE', 'UTF-8'));
if ($char >= 0) {
return $char;
}
}
$bytes = array(); // array containing single character byte sequences
$countbytes = 0;
@ -1817,29 +1819,36 @@ class TCPDF_FONTS {
* Converts UTF-8 strings to codepoints array.<br>
* Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br>
* @param $str (string) string to process.
* @param $isunicode (boolean) True when the documetn is in Unicode mode, false otherwise.
* @param $currentfont (array) Reference to current font array.
* @return array containing codepoints (UTF-8 characters values)
* @author Nicola Asuni
* @public static
*/
public static function UTF8StringToArray($str, &$currentfont) {
// requires PCRE unicode support turned on
$uchars = preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
$uarr = array_map(array('self', 'uniord'), $uchars);
$currentfont['subsetchars'] += array_fill_keys($uarr, true);
return $uarr;
public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
if ($isunicode) {
// requires PCRE unicode support turned on
$chars = preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
$carr = array_map(array('self', 'uniord'), $chars);
} else {
$chars = str_split($str);
$carr = array_map('ord', $chars);
}
$currentfont['subsetchars'] += array_fill_keys($carr, true);
return $carr;
}
/**
* Converts UTF-8 strings to Latin1 when using the standard 14 core fonts.<br>
* @param $str (string) string to process.
* @param $isunicode (boolean) True when the documetn is in Unicode mode, false otherwise.
* @param $currentfont (array) Reference to current font array.
* @return string
* @since 3.2.000 (2008-06-23)
* @public static
*/
public static function UTF8ToLatin1($str, &$currentfont) {
$unicode = self::UTF8StringToArray($str, $currentfont); // array containing UTF-8 unicode values
public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont) {
$unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values
return self::UTF8ArrToLatin1($unicode);
}
@ -1858,7 +1867,7 @@ class TCPDF_FONTS {
if (!$isunicode) {
return $str; // string is not in unicode
}
$unicode = self::UTF8StringToArray($str, $currentfont); // array containing UTF-8 unicode values
$unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values
return self::arrUTF8ToUTF16BE($unicode, $setbom);
}
@ -1875,7 +1884,7 @@ class TCPDF_FONTS {
* @public static
*/
public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) {
return self::utf8StrArrRev(self::UTF8StringToArray($str, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont);
return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont);
}
/**

View File

@ -3,7 +3,7 @@
// File name : tcpdf_static.php
// Version : 1.0.000
// Begin : 2002-08-03
// Last Update : 2013-03-16
// Last Update : 2013-03-20
// 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
// -------------------------------------------------------------------
@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.0.002';
private static $tcpdf_version = '6.0.003';
/**
* String alias for total number of pages.

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 6.0.002
// Version : 6.0.003
// Begin : 2002-08-03
// Last Update : 2013-03-18
// Last Update : 2013-03-20
// 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.002
* @version 6.0.003
*/
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.002
* @version 6.0.003
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@ -1859,7 +1859,7 @@ class TCPDF {
* @param $unit (string) User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
* @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() or an array of parameters specified at setPageFormat().
* @param $unicode (boolean) TRUE means that the input text is unicode (default = true)
* @param $encoding (string) Charset encoding; default is UTF-8.
* @param $encoding (string) Charset encoding (used only when converting back html entities); default is UTF-8.
* @param $diskcache (boolean) If TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
* @param $pdfa (boolean) If TRUE set the document to PDF/A mode.
* @public
@ -4022,7 +4022,7 @@ class TCPDF {
* @since 1.2
*/
public function GetStringWidth($s, $fontname='', $fontstyle='', $fontsize=0, $getarray=false) {
return $this->GetArrStringWidth(TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($s, $this->CurrentFont), $s, $this->tmprtl, $this->isunicode, $this->CurrentFont), $fontname, $fontstyle, $fontsize, $getarray);
return $this->GetArrStringWidth(TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont), $s, $this->tmprtl, $this->isunicode, $this->CurrentFont), $fontname, $fontstyle, $fontsize, $getarray);
}
/**
@ -4126,7 +4126,7 @@ class TCPDF {
*/
public function GetNumChars($s) {
if ($this->isUnicodeFont()) {
return count(TCPDF_FONTS::UTF8StringToArray($s, $this->CurrentFont));
return count(TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont));
}
return strlen($s);
}
@ -4643,7 +4643,7 @@ class TCPDF {
public function isCharDefined($char, $font='', $style='') {
if (is_string($char)) {
// get character code
$char = TCPDF_FONTS::UTF8StringToArray($char, $this->CurrentFont);
$char = TCPDF_FONTS::UTF8StringToArray($char, $this->isunicode, $this->CurrentFont);
$char = $char[0];
}
if (TCPDF_STATIC::empty_string($font)) {
@ -4676,7 +4676,7 @@ class TCPDF {
}
$fontdata = $this->AddFont($font, $style);
$fontinfo = $this->getFontBuffer($fontdata['fontkey']);
$uniarr = TCPDF_FONTS::UTF8StringToArray($text, $this->CurrentFont);
$uniarr = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
foreach ($uniarr as $k => $chr) {
if (!isset($fontinfo['cw'][$chr])) {
// this character is missing on the selected font
@ -5251,9 +5251,9 @@ class TCPDF {
$txt2 = $txt;
if ($this->isunicode) {
if (($this->CurrentFont['type'] == 'core') OR ($this->CurrentFont['type'] == 'TrueType') OR ($this->CurrentFont['type'] == 'Type1')) {
$txt2 = TCPDF_FONTS::UTF8ToLatin1($txt2, $this->CurrentFont);
$txt2 = TCPDF_FONTS::UTF8ToLatin1($txt2, $this->isunicode, $this->CurrentFont);
} else {
$unicode = TCPDF_FONTS::UTF8StringToArray($txt, $this->CurrentFont); // array of UTF-8 unicode values
$unicode = TCPDF_FONTS::UTF8StringToArray($txt, $this->isunicode, $this->CurrentFont); // array of UTF-8 unicode values
$unicode = TCPDF_FONTS::utf8Bidi($unicode, '', $this->tmprtl, $this->isunicode, $this->CurrentFont);
// replace thai chars (if any)
if (defined('K_THAI_TOPCHARS') AND (K_THAI_TOPCHARS == true)) {
@ -6153,7 +6153,7 @@ class TCPDF {
}
$lines = 1;
$sum = 0;
$chars = TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($txt, $this->CurrentFont), $txt, $this->tmprtl, $this->isunicode, $this->CurrentFont);
$chars = TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($txt, $this->isunicode, $this->CurrentFont), $txt, $this->tmprtl, $this->isunicode, $this->CurrentFont);
$charsWidth = $this->GetArrStringWidth($chars, '', '', 0, true);
$length = count($chars);
$lastSeparator = -1;
@ -6298,7 +6298,7 @@ class TCPDF {
// get a char width
$chrwidth = $this->GetCharWidth(46); // dot character
// get array of unicode values
$chars = TCPDF_FONTS::UTF8StringToArray($s, $this->CurrentFont);
$chars = TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont);
// calculate maximum width for a single character on string
$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);
array_walk($chrw, array($this, 'getRawCharWidth'));
@ -7784,9 +7784,9 @@ class TCPDF {
$u = '{'.$a.'}';
$alias['u'][] = TCPDF_STATIC::_escape($u);
if ($this->isunicode) {
$alias['u'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::UTF8ToLatin1($u, $this->CurrentFont));
$alias['u'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::UTF8ToLatin1($u, $this->isunicode, $this->CurrentFont));
$alias['u'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::utf8StrRev($u, false, $this->tmprtl, $this->isunicode, $this->CurrentFont));
$alias['a'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::UTF8ToLatin1($a, $this->CurrentFont));
$alias['a'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::UTF8ToLatin1($a, $this->isunicode, $this->CurrentFont));
$alias['a'][] = TCPDF_STATIC::_escape(TCPDF_FONTS::utf8StrRev($a, false, $this->tmprtl, $this->isunicode, $this->CurrentFont));
}
$alias['a'][] = TCPDF_STATIC::_escape($a);
@ -10236,7 +10236,7 @@ class TCPDF {
protected function _escapetext($s) {
if ($this->isunicode) {
if (($this->CurrentFont['type'] == 'core') OR ($this->CurrentFont['type'] == 'TrueType') OR ($this->CurrentFont['type'] == 'Type1')) {
$s = TCPDF_FONTS::UTF8ToLatin1($s, $this->CurrentFont);
$s = TCPDF_FONTS::UTF8ToLatin1($s, $this->isunicode, $this->CurrentFont);
} else {
//Convert string to UTF-16BE and reverse RTL language
$s = TCPDF_FONTS::utf8StrRev($s, false, $this->tmprtl, $this->isunicode, $this->CurrentFont);
@ -10728,7 +10728,7 @@ class TCPDF {
*/
protected function _fixAES256Password($password) {
$psw = ''; // password to be returned
$psw_array = TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($password, $this->CurrentFont), $password, $this->rtl, $this->isunicode, $this->CurrentFont);
$psw_array = TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($password, $this->isunicode, $this->CurrentFont), $password, $this->rtl, $this->isunicode, $this->CurrentFont);
foreach ($psw_array as $c) {
$psw .= TCPDF_FONTS::unichr($c, $this->isunicode);
}
@ -21769,7 +21769,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
return $word;
}
if (isset($dictionary[$word_string])) {
return TCPDF_FONTS::UTF8StringToArray($dictionary[$word_string], $this->CurrentFont);
return TCPDF_FONTS::UTF8StringToArray($dictionary[$word_string], $this->isunicode, $this->CurrentFont);
}
// suround word with '_' characters
$tmpword = array_merge(array(95), $word, array(95));
@ -21780,7 +21780,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
for ($i = $charmin; $i <= $imax; ++$i) {
$subword = strtolower(TCPDF_FONTS::UTF8ArrSubString($tmpword, $pos, ($pos + $i), $this->isunicode));
if (isset($patterns[$subword])) {
$pattern = TCPDF_FONTS::UTF8StringToArray($patterns[$subword], $this->CurrentFont);
$pattern = TCPDF_FONTS::UTF8StringToArray($patterns[$subword], $this->isunicode, $this->CurrentFont);
$pattern_length = count($pattern);
$digits = 1;
for ($j = 0; $j < $pattern_length; ++$j) {
@ -21835,7 +21835,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patterns);
}
// get array of characters
$unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->CurrentFont);
$unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
// for each char
foreach ($unichars as $char) {
if ((!$intag) AND TCPDF_FONT_DATA::$uni_type[$char] == 'L') {