Skip to content

Commit 83700f3

Browse files
committed
Improved font subsetter tool
1 parent 9fc2e80 commit 83700f3

File tree

7 files changed

+46
-30
lines changed

7 files changed

+46
-30
lines changed

www/font_explorer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8" />
45
<title>PHP font lib - Font explorer</title>
56
</head>
67
<frameset rows="28,*">

www/font_info.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
?><!DOCTYPE html>
99
<html>
1010
<head>
11+
<meta charset="utf-8" />
12+
<title>Font information</title>
1113
<link rel="stylesheet" href="css/style.css" />
1214
<link rel="stylesheet" href="css/blitzer/jquery-ui-1.8.14.custom.css" />
1315
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>

www/font_list.php

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
<?php
2-
/**
3-
* @package php-font-lib
4-
* @link https://github.com/PhenX/php-font-lib
5-
* @author Fabien Ménager <[email protected]>
6-
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7-
*/
8-
?><!DOCTYPE html>
9-
<html>
10-
<head>
11-
<link rel="stylesheet" href="css/style.css" />
12-
</head>
13-
<body>
14-
<?php
15-
16-
$fonts = glob("../fonts/*.{ttf,TTF,otf,OTF,ttc,TTC,eot,EOT,woff,WOFF}", GLOB_BRACE);
17-
sort($fonts);
18-
19-
echo "<ul>";
20-
foreach($fonts as $font) {
21-
echo "<li><a href=\"font_info.php?fontfile=$font\" target=\"font-info\">".basename($font)."</a></li>";
22-
}
23-
echo "</ul>";
24-
25-
?>
26-
</body>
1+
<?php
2+
/**
3+
* @package php-font-lib
4+
* @link https://github.com/PhenX/php-font-lib
5+
* @author Fabien Ménager <[email protected]>
6+
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7+
*/
8+
?><!DOCTYPE html>
9+
<html>
10+
<head>
11+
<meta charset="utf-8" />
12+
<link rel="stylesheet" href="css/style.css" />
13+
</head>
14+
<body>
15+
<?php
16+
17+
$fonts = glob("../fonts/*.{ttf,TTF,otf,OTF,ttc,TTC,eot,EOT,woff,WOFF}", GLOB_BRACE);
18+
sort($fonts);
19+
20+
echo "<ul>";
21+
foreach($fonts as $font) {
22+
echo "<li><a href=\"font_info.php?fontfile=$font\" target=\"font-info\">".basename($font)."</a></li>";
23+
}
24+
echo "</ul>";
25+
26+
?>
27+
</body>
2728
</html>

www/header.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8" />
45
<link rel="stylesheet" href="css/style.css" />
56
</head>
67
<body style="background: #eee;">

www/make_subset.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
$fontfile = "../fonts/$fontfile";
1313
}
1414

15-
$name = isset($_GET["name"]) ? $_GET["name"] : null;
15+
if (!file_exists($fontfile)) {
16+
return;
17+
}
18+
19+
$name = isset($_GET["name"]) ? $_GET["name"] : null;
1620

1721
if (isset($_POST["subset"])) {
18-
$subset = $_POST["subset"];
22+
$subset = utf8_encode($_POST["subset"]);
1923

2024
ob_start();
2125

@@ -26,9 +30,12 @@
2630

2731
$font->setSubset($subset);
2832
$font->reduce();
33+
34+
$new_filename = basename($fontfile);
35+
$new_filename = substr($new_filename, 0, -4)."-subset.".substr($new_filename, -3);
2936

30-
header('Content-Type: font/truetype');
31-
header('Content-Disposition: attachment; filename="subset.ttf"');
37+
header("Content-Type: font/truetype");
38+
header("Content-Disposition: attachment; filename=\"$new_filename\"");
3239

3340
$tmp = tempnam(sys_get_temp_dir(), "fnt");
3441
$font->open($tmp, Font_Binary_Stream::modeWrite);
@@ -45,6 +52,8 @@
4552
<!DOCTYPE html>
4653
<html>
4754
<head>
55+
<meta charset="utf-8" />
56+
<title>Subset maker</title>
4857
<link rel="stylesheet" href="css/style.css" />
4958
</head>
5059
<body>

www/readme.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8" />
45
<link rel="stylesheet" href="css/style.css" />
56
</head>
67
<body>

www/test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8" />
45
<link rel="stylesheet" href="css/style.css" />
56
<link rel="stylesheet" href="css/blitzer/jquery-ui-1.8.14.custom.css" />
67
</head>

0 commit comments

Comments
 (0)