示例#1
0
 /**
  * Output CID-0 fonts.
  * A Type 0 CIDFont contains glyph descriptions based on the Adobe Type 1 font format
  * @param $font (array) font data
  * @protected
  * @author Andrew Whitehead, Nicola Asuni, Yukihiro Nakadaira
  * @since 3.2.000 (2008-06-23)
  */
 protected function _putcidfont0($font)
 {
     $cidoffset = 0;
     if (!isset($font['cw'][1])) {
         $cidoffset = 31;
     }
     if (isset($font['cidinfo']['uni2cid'])) {
         // convert unicode to cid.
         $uni2cid = $font['cidinfo']['uni2cid'];
         $cw = array();
         foreach ($font['cw'] as $uni => $width) {
             if (isset($uni2cid[$uni])) {
                 $cw[$uni2cid[$uni] + $cidoffset] = $width;
             } elseif ($uni < 256) {
                 $cw[$uni] = $width;
             }
             // else unknown character
         }
         $font = array_merge($font, array('cw' => $cw));
     }
     $name = $font['name'];
     $enc = $font['enc'];
     if ($enc) {
         $longname = $name . '-' . $enc;
     } else {
         $longname = $name;
     }
     $out = $this->_getobj($this->font_obj_ids[$font['fontkey']]) . "\n";
     $out .= '<</Type /Font';
     $out .= ' /Subtype /Type0';
     $out .= ' /BaseFont /' . $longname;
     $out .= ' /Name /F' . $font['i'];
     if ($enc) {
         $out .= ' /Encoding /' . $enc;
     }
     $out .= ' /DescendantFonts [' . ($this->n + 1) . ' 0 R]';
     $out .= ' >>';
     $out .= "\n" . 'endobj';
     $this->_out($out);
     $oid = $this->_newobj();
     $out = '<</Type /Font';
     $out .= ' /Subtype /CIDFontType0';
     $out .= ' /BaseFont /' . $name;
     $cidinfo = '/Registry ' . $this->_datastring($font['cidinfo']['Registry'], $oid);
     $cidinfo .= ' /Ordering ' . $this->_datastring($font['cidinfo']['Ordering'], $oid);
     $cidinfo .= ' /Supplement ' . $font['cidinfo']['Supplement'];
     $out .= ' /CIDSystemInfo <<' . $cidinfo . '>>';
     $out .= ' /FontDescriptor ' . ($this->n + 1) . ' 0 R';
     $out .= ' /DW ' . $font['dw'];
     $out .= "\n" . TCPDF_FONTS::_putfontwidths($font, $cidoffset);
     $out .= ' >>';
     $out .= "\n" . 'endobj';
     $this->_out($out);
     $this->_newobj();
     $s = '<</Type /FontDescriptor /FontName /' . $name;
     foreach ($font['desc'] as $k => $v) {
         if ($k != 'Style') {
             if (is_float($v)) {
                 $v = sprintf('%F', $v);
             }
             $s .= ' /' . $k . ' ' . $v . '';
         }
     }
     $s .= '>>';
     $s .= "\n" . 'endobj';
     $this->_out($s);
 }