1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
<?php
include "head.inc";
require_once "../dompdf_config.inc.php";
function to_bytes($string) {
$string = strtolower(trim($string));
if (!preg_match("/(.*)([kmgt])/", $string, $matches)) {
return intval($string);
}
list($string, $value, $suffix) = $matches;
switch($suffix) {
case 't': $value *= 1024;
case 'g': $value *= 1024;
case 'm': $value *= 1024;
case 'k': $value *= 1024;
}
return intval($value);
}
?>
<a name="setup"> </a>
<h2>Font manager</h2>
<ul>
<li style="list-style-image: url('images/star_02.gif');"><a href="#installed-fonts">Installed fonts</a></li>
<li style="list-style-image: url('images/star_02.gif');"><a href="#install-fonts">Install new fonts</a></li>
</ul>
<h3 id="installed-fonts">Installed fonts</h3>
<?php
Font_Metrics::init();
$fonts = Font_Metrics::get_font_families();
$extensions = array("ttf", "afm", "afm.php", "ufm", "ufm.php");
?>
<button onclick="$('#clear-font-cache-message').load('controller.php?cmd=clear-font-cache', function(){ location.reload(); })">Clear font cache</button>
<span id="clear-font-cache-message"></span>
<table class="setup">
<tr>
<th rowspan="2">Font family</th>
<th rowspan="2">Variants</th>
<th colspan="6">File versions</th>
</tr>
<tr>
<th>TTF</th>
<th>AFM</th>
<th>AFM cache</th>
<th>UFM</th>
<th>UFM cache</th>
</tr>
<?php foreach($fonts as $family => $variants) { ?>
<tr>
<td class="title" rowspan="<?php echo count($variants); ?>">
<?php
echo htmlentities($family);
if ($family == DOMPDF_DEFAULT_FONT) {
echo ' <strong>(default)</strong>';
}
?>
</td>
<?php
$i = 0;
foreach($variants as $name => $path) {
if ($i > 0) {
echo "<tr>";
}
echo "
<td>
<strong style='width: 10em;'>".htmlentities($name)."</strong> : ".htmlentities($path)."<br />
</td>";
foreach ($extensions as $ext) {
$v = "";
$class = "";
if (is_readable("$path.$ext")) {
// if not cache file
if (strpos($ext, ".php") === false) {
$class = "ok";
$v = $ext;
}
// cache file
else {
// check if old cache format
$content = file_get_contents("$path.$ext", null, null, null, 50);
if (strpos($content, '$this->')) {
$v = "DEPREC.";
}
else {
ob_start();
$d = include "$path.$ext";
ob_end_clean();
if ($d == 1)
$v = "DEPREC.";
else {
$class = "ok";
$v = $d["_version_"];
}
}
}
}
echo "<td style='width: 2em; text-align: center;' class='$class'>$v</td>";
}
echo "</tr>";
$i++;
}
?>
<?php } ?>
</table>
<h3 id="install-fonts">Install new fonts</h3>
<script type="text/javascript">
function checkFileName(form) {
var fields = {
normal: "Normal",
bold: "Bold",
bold_italic: "Bold italic",
italic: "Italic"
};
var pattern = /\.[ot]tf$/i;
var ok = true;
if (!form.elements.family.value) {
alert("The font name is required");
form.elements.family.focus();
return false;
}
$.each(fields, function(key, name){
var value = form.elements["file["+key+"]"].value;
if (!value) return;
if (!value.match(pattern)) {
alert("The font name specified for "+name+" is not a TrueType font");
ok = false;
return false;
}
});
return ok;
}
</script>
<?php
if (auth_ok()) {
$max_size = min(to_bytes(ini_get('post_max_size')), to_bytes(ini_get('upload_max_filesize')));
?>
<form name="upload-font" method="post" action="controller.php?cmd=install-font" target="upload-font" enctype="multipart/form-data" onsubmit="return checkFileName(this)">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>" />
<table class="setup">
<tr>
<td class="title">Name</td>
<td><input type="text" name="family" /></td>
<td rowspan="6"><iframe name="upload-font" id="upload-font" style="border: 0; width: 500px;"></iframe></td>
</tr>
<tr>
<td class="title">Normal</td>
<td><input type="file" name="file[normal]" /></td>
</tr>
<tr>
<td class="title">Bold</td>
<td><input type="file" name="file[bold]" /></td>
</tr>
<tr>
<td class="title">Bold italic</td>
<td><input type="file" name="file[bold_italic]" /></td>
</tr>
<tr>
<td class="title">Italic</td>
<td><input type="file" name="file[italic]" /></td>
</tr>
<tr>
<td></td>
<td><button>Install !!</button></td>
</tr>
</table>
</form>
<?php }
else {
echo auth_get_link();
} ?>
<?php include("foot.inc"); ?>
|