From 73b436e180d91cb0e9897242ccfb4b49fc498901 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Oct 2014 21:02:38 +0100 Subject: [PATCH] 6.0.097 (2014-10-20) - Bug item #988 "hyphenateText - charmin parameter not work" was fixed. --- CHANGELOG.TXT | 3 ++ README.TXT | 4 +-- composer.json | 2 +- include/tcpdf_static.php | 2 +- tcpdf.php | 25 ++++++++------- tcpdf_barcodes_1d.php | 66 ++++++++++++++++++++++++++++++++++++---- 6 files changed, 79 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 857ab1b..672f1a5 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.097 (2014-10-20) + - Bug item #988 "hyphenateText - charmin parameter not work" was fixed. + 6.0.096 (2014-10-06) - Bug item #982 "Display style is not inherited in SVG" was fixed. - Bug item #984 "Double quote url in CSS" was fixed. diff --git a/README.TXT b/README.TXT index 8b897ef..030c990 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.096 -Release date: 2014-10-06 +Version: 6.0.097 +Release date: 2014-10-20 Author: Nicola Asuni Copyright (c) 2002-2014: diff --git a/composer.json b/composer.json index 73c126d..61984e5 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.096", + "version": "6.0.097", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index d7c438f..feb4c15 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.096'; + private static $tcpdf_version = '6.0.097'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index e3cefa4..6b926d5 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.096 + * @version 6.0.097 */ // TCPDF configuration @@ -128,7 +128,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.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.096 + * @version 6.0.097 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -7411,10 +7411,9 @@ class TCPDF { $this->x = $this->lMargin + $cellpadding; } if (is_string($h)) { - $this->y += $this->lasth; - } else { - $this->y += $h; + $h = $this->lasth; } + $this->y += $h; $this->newline = true; } @@ -22150,10 +22149,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: * Returns an array of chars containing soft hyphens. * @param $word (array) array of chars * @param $patterns (array) Array of hypenation patterns. - * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm. + * @param $dictionary (array) Array of words to be returned without applying the hyphenation algorithm. * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens. * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens. - * @param $charmin (int) Minimum word length to apply the hyphenation algoritm. + * @param $charmin (int) Minimum word length to apply the hyphenation algorithm. * @param $charmax (int) Maximum length of broken piece of word. * @return array text with soft hyphens * @author Nicola Asuni @@ -22184,10 +22183,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: // surround word with '_' characters $tmpword = array_merge(array(46), $word, array(46)); $tmpnumchars = $numchars + 2; - $maxpos = $tmpnumchars - $charmin; + $maxpos = $tmpnumchars - 1; for ($pos = 0; $pos < $maxpos; ++$pos) { $imax = min(($tmpnumchars - $pos), $charmax); - for ($i = $charmin; $i <= $imax; ++$i) { + for ($i = 1; $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->isunicode, $this->CurrentFont); @@ -22230,10 +22229,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: * Returns text with soft hyphens. * @param $text (string) text to process * @param $patterns (mixed) Array of hypenation patterns or a TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/ - * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm. + * @param $dictionary (array) Array of words to be returned without applying the hyphenation algorithm. * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens. * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens. - * @param $charmin (int) Minimum word length to apply the hyphenation algoritm. + * @param $charmin (int) Minimum word length to apply the hyphenation algorithm. * @param $charmax (int) Maximum length of broken piece of word. * @return array text with soft hyphens * @author Nicola Asuni diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index 09dfaf4..c3f3f8b 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf - * @version 1.0.026 + * @version 1.0.027 * @author Nicola Asuni */ class TCPDFBarcode { @@ -242,7 +242,7 @@ class TCPDFBarcode { /** * Set the barcode. * @param $code (string) code to print - * @param $type (string) type of barcode: + * @param $type (string) type of barcode: * @return array barcode array * @public */ @@ -352,6 +352,10 @@ class TCPDFBarcode { $arrcode = $this->barcode_imb($code); break; } + case 'IMBPRE': { // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200- pre-processed + $arrcode = $this->barcode_imb_pre($code); + break; + } case 'CODABAR': { // CODABAR $arrcode = $this->barcode_codabar($code); break; @@ -2038,7 +2042,6 @@ class TCPDFBarcode { return $bararray; } - /** * IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 * (requires PHP bcmath extension) @@ -2166,6 +2169,57 @@ class TCPDFBarcode { return $bararray; } + /** + * IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 + * + * @param $code (string) pre-formatted IMB barcode (65 chars "FADT") + * @return array barcode representation. + * @protected + */ + protected function barcode_imb_pre($code) { + if (!preg_match('/^[fadtFADT]{65}$/', $code) == 1) { + return false; + } + $characters = str_split(strtolower($code), 1); + // build bars + $k = 0; + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array()); + for ($i = 0; $i < 65; ++$i) { + switch($characters[$i]) { + case 'f': { + // full bar + $p = 0; + $h = 3; + break; + } + case 'a': { + // ascender + $p = 0; + $h = 2; + break; + } + case 'd': { + // descender + $p = 1; + $h = 2; + break; + } + case 't': { + // tracker (short) + $p = 1; + $h = 1; + break; + } + } + $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p); + $bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0); + $bararray['maxw'] += 2; + } + unset($bararray['bcode'][($k - 1)]); + --$bararray['maxw']; + return $bararray; + } + /** * Convert large integer number to hexadecimal representation. * (requires PHP bcmath extension)