t('endobj'); // CIDFontType2 // A CIDFont whose glyph descriptions are based on TrueType font technology $this->_newobj(); $this->_out('<_out('/Subtype /CIDFontType2'); $this->_out('/BaseFont /'.$font['name'].''); $this->_out('/CIDSystemInfo '.($this->n + 2).' 0 R'); $this->_out('/FontDescriptor '.($this->n + 3).' 0 R'); if (isset($font['desc']['MissingWidth'])){ $this->_out('/DW '.$font['desc']['MissingWidth'].''); // The default width for glyphs in the CIDFont MissingWidth } $w = ""; foreach ($font['cw'] as $cid => $width) { $w .= ''.$cid.' ['.$width.'] '; // define a specific width for each individual CID } $this->_out('/W ['.$w.']'); // A description of the widths for the glyphs in the CIDFont $this->_out('/CIDToGIDMap '.($this->n + 4).' 0 R'); $this->_out('>>'); $this->_out('endobj'); // ToUnicode // is a stream object that contains the definition of the CMap // (PDF Reference 1.3 chap. 5.9) $this->_newobj(); $this->_out('<>'); $this->_out('stream'); $this->_out('/CIDInit /ProcSet findresource begin'); $this->_out('12 dict begin'); $this->_out('begincmap'); $this->_out('/CIDSystemInfo'); $this->_out('<_out('/Ordering (UCS)'); $this->_out('/Supplement 0'); $this->_out('>> def'); $this->_out('/CMapName /Adobe-Identity-UCS def'); $this->_out('/CMapType 2 def'); $this->_out('1 begincodespacerange'); $this->_out('<0000> '); $this->_out('endcodespacerange'); $this->_out('1 beginbfrange'); $this->_out('<0000> <0000>'); $this->_out('endbfrange'); $this->_out('endcmap'); $this->_out('CMapName currentdict /CMap defineresource pop'); $this->_out('end'); $this->_out('end'); $this->_out('endstream'); $this->_out('endobj'); // CIDSystemInfo dictionary // A dictionary containing entries that define the character collection of the CIDFont. $this->_newobj(); $this->_out('<_out('/Ordering (UCS)'); // A string that uniquely names a character collection issued by a specific registry $this->_out('/Supplement 0'); // The supplement number of the character collection. $this->_out('>>'); $this->_out('endobj'); // Font descriptor // A font descriptor describing the CIDFont default metrics other than its glyph widths $this->_newobj(); $this->_out('<_out('/FontName /'.$font['name']); foreach ($font['desc'] as $key => $value) { $this->_out('/'.$key.' '.$value); } if ($font['file']) { // A stream containing a TrueType font program $this->_out('/FontFile2 '.$this->FontFiles[$font['file']]['n'].' 0 R'); } $this->_out('>>'); $this->_out('endobj'); // Embed CIDToGIDMap // A specification of the mapping from CIDs to glyph indices $this->_newobj(); $ctgfile = $this->_getfontpath().strtolower($font['ctg']); if(!file_exists($ctgfile)) { $this->Error('Font file not found: '.$ctgfile); } $size = filesize($ctgfile); $this->_out('<_out('/Filter /FlateDecode'); } $this->_out('>>'); $this->_putstream(file_get_contents($ctgfile)); $this->_out('endobj'); } /** * Converts UTF-8 strings to codepoints array.
* Invalid byte sequences will be replaced with 0xFFFD (replacement character)
* Based on: http://www.faqs.org/rfcs/rfc3629.html *
		 * 	  Char. number range  |        UTF-8 octet sequence
		 *       (hexadecimal)    |              (binary)
		 *    --------------------+-----------------------------------------------
		 *    0000 0000-0000 007F | 0xxxxxxx
		 *    0000 0080-0000 07FF | 110xxxxx 10xxxxxx
		 *    0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
		 *    0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
		 *    ---------------------------------------------------------------------
		 *
		 *   ABFN notation:
		 *   ---------------------------------------------------------------------
		 *   UTF8-octets = *( UTF8-char )
		 *   UTF8-char   = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
		 *   UTF8-1      = %x00-7F
		 *   UTF8-2      = %xC2-DF UTF8-tail
		 *
		 *   UTF8-3      = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
		 *                 %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
		 *   UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
		 *                 %xF4 %x80-8F 2( UTF8-tail )
		 *   UTF8-tail   = %x80-BF
		 *   ---------------------------------------------------------------------
		 * 
* @param string $str string to process. * @return array containing codepoints (UTF-8 characters values) * @access protected * @author Nicola Asuni * @since 1.53.0.TC005 (2005-01-05) */ function UTF8StringToArray($str) { if(!$this->isunicode) { // split string into array of chars $strarr = str_split($str); // convert chars to equivalent code while(list($pos,$char)=each($strarr)) { $strarr[$pos] = ord($char); } return $strarr; } $unicode = array(); // array containing unicode values $bytes = array(); // array containing single character byte sequences $numbytes = 1; // number of octetc needed to represent the UTF-8 character $str .= ""; // force $str to be a string $length = strlen($str); for($i = 0; $i < $length; $i++) { $char = ord($str{$i}); // get one string character at time if(count($bytes) == 0) { // get starting octect if ($char <= 0x7F) { $unicode[] = $char; // use the character "as is" because is ASCII $numbytes = 1; } elseif (($char >> 0x05) == 0x06) { // 2 bytes character (0x06 = 110 BIN) $bytes[] = ($char - 0xC0) << 0x06; $numbytes = 2; } elseif (($char >> 0x04) == 0x0E) { // 3 bytes character (0x0E = 1110 BIN) $bytes[] = ($char - 0xE0) << 0x0C; $numbytes = 3; } elseif (($char >> 0x03) == 0x1E) { // 4 bytes character (0x1E = 11110 BIN) $bytes[] = ($char - 0xF0) << 0x12; $numbytes = 4; } else { // use replacement character for other invalid sequences $unicode[] = 0xFFFD; $bytes = array(); $numbytes = 1; } } elseif (($char >> 0x06) == 0x02) { // bytes 2, 3 and 4 must start with 0x02 = 10 BIN $bytes[] = $char - 0x80; if (count($bytes) == $numbytes) { // compose UTF-8 bytes to a single unicode value $char = $bytes[0]; for($j = 1; $j < $numbytes; $j++) { $char += ($bytes[$j] << (($numbytes - $j - 1) * 0x06)); } if ((($char >= 0xD800) AND ($char <= 0xDFFF)) OR ($char >= 0x10FFFF)) { /* The definition of UTF-8 prohibits encoding character numbers between U+D800 a