32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-10-31 18:52:35 +00:00

5.9.166 (2012-06-21)

- Array to string conversion on file_id creation was fixed.
- Thai language rendering was fixed (thanks to Atsawin Chaowanakritsanakul).
This commit is contained in:
nick 2012-06-21 21:56:49 +01:00
parent 4bfc80dce0
commit 9ea87e1c44
3 changed files with 109 additions and 53 deletions

View File

@ -1,3 +1,7 @@
5.9.166 (2012-06-21)
- Array to string conversion on file_id creation was fixed.
- Thai language rendering was fixed (thanks to Atsawin Chaowanakritsanakul).
5.9.165 (2012-06-07)
- Some HTML form related bugs were fixed.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 5.9.165
Release date: 2012-06-07
Version: 5.9.166
Release date: 2012-06-21
Author: Nicola Asuni
Copyright (c) 2002-2012:

154
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 5.9.165
// Version : 5.9.166
// Begin : 2002-08-03
// Last Update : 2012-06-07
// Last Update : 2012-06-21
// 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
// -------------------------------------------------------------------
@ -137,7 +137,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 5.9.165
* @version 5.9.166
*/
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -149,7 +149,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>
* @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions.
* @version 5.9.165
* @version 5.9.166
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@ -160,7 +160,7 @@ class TCPDF {
* Current TCPDF version.
* @private
*/
private $tcpdf_version = '5.9.165';
private $tcpdf_version = '5.9.166';
// Protected properties
@ -2050,7 +2050,8 @@ class TCPDF {
}
$this->default_form_prop = array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 255), 'strokeColor'=>array(128, 128, 128));
// set file ID for trailer
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$format.$encoding));
$serformat = (is_array($format) ? serialize($format) : $format);
$this->file_id = md5($this->getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding));
// set document creation and modification timestamp
$this->doc_creation_timestamp = time();
$this->doc_modification_timestamp = $this->doc_creation_timestamp;
@ -6036,34 +6037,106 @@ class TCPDF {
} else {
$unicode = $this->UTF8StringToArray($txt); // array of UTF-8 unicode values
$unicode = $this->utf8Bidi($unicode, '', $this->tmprtl);
// replace thai chars (if any)
if (defined('K_THAI_TOPCHARS') AND (K_THAI_TOPCHARS == true)) {
// ---- Fix for bug #2977340 "Incorrect Thai characters position arrangement" ----
// NOTE: this doesn't work with HTML justification
// Symbols that could overlap on the font top (only works in LTR)
$topchar = array(3611, 3613, 3615, 3650, 3651, 3652); // chars that extends on top
$topsym = array(3633, 3636, 3637, 3638, 3639, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662); // symbols with top position
$numchars = count($unicode); // number of chars
$unik = 0;
$uniblock = array();
$uniblock[$unik] = array();
$uniblock[$unik][] = $unicode[0];
// resolve overlapping conflicts by splitting the string in several parts
for ($i = 1; $i < $numchars; ++$i) {
// check if symbols overlaps at top
if (in_array($unicode[$i], $topsym) AND (in_array($unicode[($i - 1)], $topsym) OR in_array($unicode[($i - 1)], $topchar))) {
// move symbols to another array
++$unik;
$uniblock[$unik] = array();
$uniblock[$unik][] = $unicode[$i];
++$unik;
$uniblock[$unik] = array();
$unicode[$i] = 0x200b; // Unicode Character 'ZERO WIDTH SPACE' (DEC:8203, U+200B)
// number of chars
$numchars = count($unicode);
// po pla, for far, for fan
$longtail = array(0x0e1b, 0x0e1d, 0x0e1f);
// do chada, to patak
$lowtail = array(0x0e0e, 0x0e0f);
// mai hun arkad, sara i, sara ii, sara ue, sara uee
$upvowel = array(0x0e31, 0x0e34, 0x0e35, 0x0e36, 0x0e37);
// mai ek, mai tho, mai tri, mai chattawa, karan
$tonemark = array(0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c);
// sara u, sara uu, pinthu
$lowvowel = array(0x0e38, 0x0e39, 0x0e3a);
$output = array();
for ($i = 0; $i < $numchars; $i++) {
if (($unicode[$i] >= 0x0e00) && ($unicode[$i] <= 0x0e5b)) {
$ch0 = $unicode[$i];
$ch1 = ($i > 0) ? $unicode[($i - 1)] : 0;
$ch2 = ($i > 1) ? $unicode[($i - 2)] : 0;
$chn = ($i < ($numchars - 1)) ? $unicode[($i + 1)] : 0;
if (in_array($ch0, $tonemark)) {
if ($chn == 0x0e33) {
// sara um
if (in_array($ch1, $longtail)) {
// tonemark at upper left
$newchr = (0xf713 + $ch0 - 0x0e48);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
} else {
// tonemark at upper right (normal position)
$output[] = $ch0;
}
} elseif (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $lowvowel))) {
// tonemark at lower left
$newchr = (0xf705 + $ch0 - 0x0e48);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
} elseif (in_array($ch1, $upvowel)) {
if (in_array($ch2, $longtail)) {
// tonemark at upper left
$newchr = (0xf713 + $ch0 - 0x0e48);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
} else {
// tonemark at upper right (normal position)
$output[] = $ch0;
}
} else {
// tonemark at lower right
$newchr = (0xf70a + $ch0 - 0x0e48);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
}
} elseif (($ch0 == 0x0e33) AND (in_array($ch1, $longtail) OR (in_array($ch2, $longtail) AND in_array($ch1, $tonemark)))) {
// add lower left nikhahit and sara aa
$output[] = 0xf711;
$this->CurrentFont['subsetchars'][0xf711] = true;
$output[] = 0x0e32;
$this->CurrentFont['subsetchars'][0x0e32] = true;
} elseif (in_array($ch1, $longtail)) {
if ($ch0 == 0x0e31) {
// lower left mai hun arkad
$output[] = 0xf710;
$this->CurrentFont['subsetchars'][0xf710] = true;
} elseif (in_array($ch0, $upvowel)) {
// lower left
$newchr = (0xf701 + $ch0 - 0x0e34);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
} elseif ($ch0 == 0x0e47) {
// lower left mai tai koo
$output[] = 0xf712;
$this->CurrentFont['subsetchars'][0xf712] = true;
} else {
// normal character
$output[] = $ch0;
}
} elseif (in_array($ch1, $lowtail) AND in_array($ch0, $lowvowel)) {
// lower vowel
$newchr = (0xf718 + $ch0 - 0x0e38);
$output[] = $newchr;
$this->CurrentFont['subsetchars'][$newchr] = true;
} elseif (($ch0 == 0x0e0d) AND in_array($chn, $lowvowel)) {
// yo ying without lower part
$output[] = 0xf70f;
$this->CurrentFont['subsetchars'][0xf70f] = true;
} elseif (($ch0 == 0x0e10) AND in_array($chn, $lowvowel)) {
// tho santan without lower part
$output[] = 0xf700;
$this->CurrentFont['subsetchars'][0xf700] = true;
} else {
$output[] = $ch0;
}
} else {
$uniblock[$unik][] = $unicode[$i];
// non-thai character
$output[] = $unicode[$i];
}
}
// ---- END OF Fix for bug #2977340
}
} // end of K_THAI_TOPCHARS
$txt2 = $this->arrUTF8ToUTF16BE($unicode, false);
}
}
@ -6180,27 +6253,6 @@ class TCPDF {
$xdk = $xdx * $k;
// print text
$s .= sprintf('BT %F %F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
if (isset($uniblock)) {
// print overlapping characters as separate string
$xshift = 0; // horizontal shift
$ty = (($this->h - $basefonty + (0.2 * $this->FontSize)) * $k);
$spw = (($w - $txwidth - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns?$ns:1));
foreach ($uniblock as $uk => $uniarr) {
if (($uk % 2) == 0) {
// x space to skip
if ($spacewidth != 0) {
// justification shift
$xshift += (count(array_keys($uniarr, 32)) * $spw);
}
$xshift += $this->GetArrStringWidth($uniarr); // + shift justification
} else {
// character to print
$topchr = $this->arrUTF8ToUTF16BE($uniarr, false);
$topchr = $this->_escape($topchr);
$s .= sprintf(' BT %F %F Td [(%s)] TJ ET', ($xdk + ($xshift * $k)), $ty, $topchr);
}
}
}
if ($this->underline) {
$s .= ' '.$this->_dounderlinew($xdx, $basefonty, $width);
}