本文整理汇总了PHP中TCPDF_FONTS::_getTrueTypeFontSubset方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_FONTS::_getTrueTypeFontSubset方法的具体用法?PHP TCPDF_FONTS::_getTrueTypeFontSubset怎么用?PHP TCPDF_FONTS::_getTrueTypeFontSubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_FONTS
的用法示例。
在下文中一共展示了TCPDF_FONTS::_getTrueTypeFontSubset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _putfonts
/**
* Output fonts.
* @author Nicola Asuni
* @protected
*/
protected function _putfonts()
{
$nf = $this->n;
foreach ($this->diffs as $diff) {
//Encodings
$this->_newobj();
$this->_out('<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . '] >>' . "\n" . 'endobj');
}
$mqr = TCPDF_STATIC::get_mqr();
TCPDF_STATIC::set_mqr(false);
foreach ($this->FontFiles as $file => $info) {
// search and get font file to embedd
$fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
if (!TCPDF_STATIC::empty_string($fontfile)) {
$font = file_get_contents($fontfile);
$compressed = substr($file, -2) == '.z';
if (!$compressed and isset($info['length2'])) {
$header = ord($font[0]) == 128;
if ($header) {
// strip first binary header
$font = substr($font, 6);
}
if ($header and ord($font[$info['length1']]) == 128) {
// strip second binary header
$font = substr($font, 0, $info['length1']) . substr($font, $info['length1'] + 6);
}
} elseif ($info['subset'] and (!$compressed or $compressed and function_exists('gzcompress'))) {
if ($compressed) {
// uncompress font
$font = gzuncompress($font);
}
// merge subset characters
$subsetchars = array();
// used chars
foreach ($info['fontkeys'] as $fontkey) {
$fontinfo = $this->getFontBuffer($fontkey);
$subsetchars += $fontinfo['subsetchars'];
}
// rebuild a font subset
$font = TCPDF_FONTS::_getTrueTypeFontSubset($font, $subsetchars);
// calculate new font length
$info['length1'] = strlen($font);
if ($compressed) {
// recompress font
$font = gzcompress($font);
}
}
$this->_newobj();
$this->FontFiles[$file]['n'] = $this->n;
$stream = $this->_getrawstream($font);
$out = '<< /Length ' . strlen($stream);
if ($compressed) {
$out .= ' /Filter /FlateDecode';
}
$out .= ' /Length1 ' . $info['length1'];
if (isset($info['length2'])) {
$out .= ' /Length2 ' . $info['length2'] . ' /Length3 0';
}
$out .= ' >>';
$out .= ' stream' . "\n" . $stream . "\n" . 'endstream';
$out .= "\n" . 'endobj';
$this->_out($out);
}
}
TCPDF_STATIC::set_mqr($mqr);
foreach ($this->fontkeys as $k) {
//Font objects
$font = $this->getFontBuffer($k);
$type = $font['type'];
$name = $font['name'];
if ($type == 'core') {
// standard core font
$out = $this->_getobj($this->font_obj_ids[$k]) . "\n";
$out .= '<</Type /Font';
$out .= ' /Subtype /Type1';
$out .= ' /BaseFont /' . $name;
$out .= ' /Name /F' . $font['i'];
if (strtolower($name) != 'symbol' and strtolower($name) != 'zapfdingbats') {
$out .= ' /Encoding /WinAnsiEncoding';
}
if ($k == 'helvetica') {
// add default font for annotations
$this->annotation_fonts[$k] = $font['i'];
}
$out .= ' >>';
$out .= "\n" . 'endobj';
$this->_out($out);
} elseif ($type == 'Type1' or $type == 'TrueType') {
// additional Type1 or TrueType font
$out = $this->_getobj($this->font_obj_ids[$k]) . "\n";
$out .= '<</Type /Font';
$out .= ' /Subtype /' . $type;
$out .= ' /BaseFont /' . $name;
$out .= ' /Name /F' . $font['i'];
$out .= ' /FirstChar 32 /LastChar 255';
//.........这里部分代码省略.........