本文整理汇总了PHP中ReadMap函数的典型用法代码示例。如果您正苦于以下问题:PHP ReadMap函数的具体用法?PHP ReadMap怎么用?PHP ReadMap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadMap函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakeFontEncoding
function MakeFontEncoding($map)
{
//Build differences from reference encoding
$ref = ReadMap('cp1252');
$s = '';
$last = 0;
for ($i = 32; $i <= 255; $i++) {
if ($map[$i] != $ref[$i]) {
if ($i != $last + 1) {
$s .= $i . ' ';
}
$last = $i;
$s .= '/' . $map[$i] . ' ';
}
}
return rtrim($s);
}
示例2: MakeFont
function MakeFont($fontfile, $afmfile, $enc = 'cp1252', $patch = array(), $type = 'TrueType')
{
//Generate a font definition file
set_magic_quotes_runtime(0);
ini_set('auto_detect_line_endings', '1');
if ($enc) {
$map = ReadMap($enc);
foreach ($patch as $cc => $gn) {
$map[$cc] = $gn;
}
} else {
$map = array();
}
if (!file_exists($afmfile)) {
die('<B>Error:</B> AFM file not found: ' . $afmfile);
}
$fm = ReadAFM($afmfile, $map);
if ($enc) {
$diff = MakeFontEncoding($map);
} else {
$diff = '';
}
$fd = MakeFontDescriptor($fm, empty($map));
//Find font type
if ($fontfile) {
$ext = strtolower(substr($fontfile, -3));
if ($ext == 'ttf') {
$type = 'TrueType';
} elseif ($ext == 'pfb') {
$type = 'Type1';
} else {
die('<B>Error:</B> unrecognized font file extension: ' . $ext);
}
} else {
if ($type != 'TrueType' and $type != 'Type1') {
die('<B>Error:</B> incorrect font type: ' . $type);
}
}
//Start generation
$s = '<?php' . "\n";
$s .= '$type=\'' . $type . "';\n";
$s .= '$name=\'' . $fm['FontName'] . "';\n";
$s .= '$desc=' . $fd . ";\n";
if (!isset($fm['UnderlinePosition'])) {
$fm['UnderlinePosition'] = -100;
}
if (!isset($fm['UnderlineThickness'])) {
$fm['UnderlineThickness'] = 50;
}
$s .= '$up=' . $fm['UnderlinePosition'] . ";\n";
$s .= '$ut=' . $fm['UnderlineThickness'] . ";\n";
$w = MakeWidthArray($fm);
$s .= '$cw=' . $w . ";\n";
$s .= '$enc=\'' . $enc . "';\n";
$s .= '$diff=\'' . $diff . "';\n";
$basename = substr(basename($afmfile), 0, -4);
if ($fontfile) {
//Embedded font
if (!file_exists($fontfile)) {
die('<B>Error:</B> font file not found: ' . $fontfile);
}
if ($type == 'TrueType') {
CheckTTF($fontfile);
}
$f = fopen($fontfile, 'rb');
if (!$f) {
die('<B>Error:</B> Can\'t open ' . $fontfile);
}
$file = fread($f, filesize($fontfile));
fclose($f);
if ($type == 'Type1') {
//Find first two sections and discard third one
$header = ord($file[0]) == 128;
if ($header) {
//Strip first binary header
$file = substr($file, 6);
}
$pos = strpos($file, 'eexec');
if (!$pos) {
die('<B>Error:</B> font file does not seem to be valid Type1');
}
$size1 = $pos + 6;
if ($header and ord($file[$size1]) == 128) {
//Strip second binary header
$file = substr($file, 0, $size1) . substr($file, $size1 + 6);
}
$pos = strpos($file, '00000000');
if (!$pos) {
die('<B>Error:</B> font file does not seem to be valid Type1');
}
$size2 = $pos - $size1;
$file = substr($file, 0, $size1 + $size2);
}
if (function_exists('gzcompress')) {
$cmp = $basename . '.z';
SaveToFile($cmp, gzcompress($file), 'b');
$s .= '$file=\'' . $cmp . "';\n";
echo 'Font file compressed (' . $cmp . ')<BR>';
} else {
$s .= '$file=\'' . basename($fontfile) . "';\n";
//.........这里部分代码省略.........
示例3: MakeFont
function MakeFont($fontfile, $afmfile, $enc = 'cp1252', $patch = array())
{
//Generate a font definition file
set_magic_quotes_runtime(0);
if ($enc) {
$map = ReadMap($enc);
foreach ($patch as $cc => $gn) {
$map[$cc] = $gn;
}
} else {
$map = array();
}
if (!file_exists($afmfile)) {
die('<B>Error:</B> AFM file not found: ' . $afmfile);
}
$fm = ReadAFM($afmfile, $map);
if ($enc) {
$diff = MakeFontEncoding($map);
} else {
$diff = '';
}
$fd = MakeFontDescriptor($fm, empty($map));
$s = '<?php' . "\n";
$s .= '$type=\'TrueType' . "';\n";
$s .= '$name=\'' . $fm['FontName'] . "';\n";
$s .= '$desc=' . $fd . ";\n";
if (!isset($fm['UnderlinePosition'])) {
$fm['UnderlinePosition'] = -100;
}
if (!isset($fm['UnderlineThickness'])) {
$fm['UnderlineThickness'] = 50;
}
$s .= '$up=' . $fm['UnderlinePosition'] . ";\n";
$s .= '$ut=' . $fm['UnderlineThickness'] . ";\n";
$w = MakeWidthArray($fm);
$s .= '$cw=' . $w . ";\n";
$s .= '$enc=\'' . $enc . "';\n";
$s .= '$diff=\'' . $diff . "';\n";
$basename = substr(basename($afmfile), 0, -4);
if ($fontfile) {
//Embedded font
if (!file_exists($fontfile)) {
die('<B>Error:</B> font file not found: ' . $fontfile);
}
if (function_exists('gzcompress')) {
$f = fopen($fontfile, 'rb');
$ttf = fread($f, filesize($fontfile));
fclose($f);
$cmp = $basename . '.z';
SaveToFile($cmp, gzcompress($ttf), 'b');
$s .= '$file=\'' . $cmp . "';\n";
echo 'Font file compressed (' . $cmp . ')<BR>';
} else {
echo '<B>Notice:</B> font file could not be compressed (gzcompress not available)<BR>';
$s .= '$file=\'' . basename($fontfile) . "';\n";
}
$s .= '$originalsize=' . filesize($fontfile) . ";\n";
} else {
//Not embedded font
$s .= '$file=' . "'';\n";
}
$s .= "?>\n";
SaveToFile($basename . '.php', $s);
echo 'Font definition file generated (' . $basename . '.php' . ')<BR>';
}