useSubstitutions = true;
if ($checkdir) {
$ttfdir = $checkdir;
} else {
$ttfdir = _MPDF_TTFONTPATH;
}
$mqr = ini_get("magic_quotes_runtime");
if ($mqr) {
set_magic_quotes_runtime(0);
}
if (!class_exists('TTFontFile_Analysis', false)) {
include(_MPDF_PATH . 'classes/ttfontsuni_analysis.php');
}
$ttf = new TTFontFile_Analysis();
$tempfontdata = array();
$tempsansfonts = array();
$tempseriffonts = array();
$tempmonofonts = array();
$tempfonttrans = array();
$ff = scandir($ttfdir);
foreach ($ff AS $f) {
$ret = array();
$isTTC = false;
if (strtolower(substr($f, -4, 4)) == '.ttc' || strtolower(substr($f, -5, 5)) == '.ttcf') { // Mac ttcf
$isTTC = true;
$ttf->getTTCFonts($ttfdir . $f);
$nf = $ttf->numTTCFonts;
for ($i = 1; $i <= $nf; $i++) {
$ret[] = $ttf->extractCoreInfo($ttfdir . $f, $i);
}
} else if (strtolower(substr($f, -4, 4)) == '.ttf' || strtolower(substr($f, -4, 4)) == '.otf') {
$ret[] = $ttf->extractCoreInfo($ttfdir . $f);
}
for ($i = 0; $i < count($ret); $i++) {
if (!is_array($ret[$i])) {
if (!$pdf)
echo $ret[$i] . '
';
}
else {
$tfname = $ret[$i][0];
$bold = $ret[$i][1];
$italic = $ret[$i][2];
$fname = strtolower($tfname);
$fname = preg_replace('/[ ()]/', '', $fname);
$tempfonttrans[$tfname] = $fname;
$style = '';
if ($bold) {
$style .= 'B';
}
if ($italic) {
$style .= 'I';
}
if (!$style) {
$style = 'R';
}
$tempfontdata[$fname][$style] = $f;
if ($isTTC) {
$tempfontdata[$fname]['TTCfontID'][$style] = $ret[$i][4];
}
//if ($ret[$i][5]) { $tempfontdata[$fname]['rtl'] = true; }
//if ($ret[$i][7]) { $tempfontdata[$fname]['cjk'] = true; }
if ($ret[$i][8]) {
$tempfontdata[$fname]['sip'] = true;
}
if ($ret[$i][9]) {
$tempfontdata[$fname]['smp'] = true;
}
if ($ret[$i][10]) {
$tempfontdata[$fname]['puaag'] = true;
}
if ($ret[$i][11]) {
$tempfontdata[$fname]['pua'] = true;
}
if ($ret[$i][12]) {
$tempfontdata[$fname]['unAGlyphs'] = true;
}
$ftype = $ret[$i][3]; // mono, sans or serif
if ($ftype == 'sans') {
$tempsansfonts[] = $fname;
} else if ($ftype == 'serif') {
$tempseriffonts[] = $fname;
} else if ($ftype == 'mono') {
$tempmonofonts[] = $fname;
}
}
}
}
$tempsansfonts = array_unique($tempsansfonts);
$tempseriffonts = array_unique($tempseriffonts);
$tempmonofonts = array_unique($tempmonofonts);
$tempfonttrans = array_unique($tempfonttrans);
if (!$pdf) {
echo '
' . $ond . ' font is available as ' . $mn; if (isset($mpdf->fontdata[$mn]['sip-ext']) && $mpdf->fontdata[$mn]['sip-ext']) { $html .= '; CJK ExtB: ' . $mpdf->fontdata[$mn]['sip-ext']; } $html .= '
'; } if ($pdf) { $mpdf->WriteHTML($html); $mpdf->Output(); exit; } foreach ($tempfonttrans AS $on => $mn) { $ond = '"' . $on . '"'; echo '';
ksort($tempfontdata);
echo '$this->fontdata = ' . var_export($tempfontdata, true) . ";\n";
sort($tempsansfonts);
echo '$this->sans_fonts = array(\'' . implode("', '", $tempsansfonts) . "');\n";
sort($tempseriffonts);
echo '$this->serif_fonts = array(\'' . implode("', '", $tempseriffonts) . "');\n";
sort($tempmonofonts);
echo '$this->mono_fonts = array(\'' . implode("', '", $tempmonofonts) . "');\n";
echo '';
exit;
?>