Skip to content

Commit a9edfe2

Browse files
committed
Added a glyph viewer (only simple glyphs in the "glyf" table)
1 parent 290ac51 commit a9edfe2

35 files changed

+3205
-2748
lines changed

classes/adobe_font_metrics.cls.php

Lines changed: 201 additions & 208 deletions
Large diffs are not rendered by default.

classes/encoding_map.cls.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
<?php
2-
/**
3-
* @package php-font-lib
4-
* @link http://php-font-lib.googlecode.com/
5-
* @author Fabien Ménager <[email protected]>
6-
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7-
* @version $Id: encoding_map.cls.php 34 2011-10-23 13:53:25Z fabien.menager $
8-
*/
9-
10-
/**
11-
* Encoding map used to map a code point to a Unicode char.
12-
*
13-
* @package php-font-lib
14-
*/
15-
class Encoding_Map {
16-
private $f;
17-
18-
function __construct($file) {
19-
$this->f = fopen($file, "r");
20-
}
21-
22-
function parse(){
23-
$map = array();
24-
25-
while($line = fgets($this->f)) {
26-
if (preg_match("/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/", $line, $matches)) {
27-
$unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]);
28-
$map[hexdec($matches[1])] = array($unicode, $matches[4]);
29-
}
30-
}
31-
32-
ksort($map);
33-
34-
return $map;
35-
}
36-
}
1+
<?php
2+
/**
3+
* @package php-font-lib
4+
* @link http://php-font-lib.googlecode.com/
5+
* @author Fabien Ménager <[email protected]>
6+
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7+
* @version $Id$
8+
*/
9+
10+
/**
11+
* Encoding map used to map a code point to a Unicode char.
12+
*
13+
* @package php-font-lib
14+
*/
15+
class Encoding_Map {
16+
private $f;
17+
18+
function __construct($file) {
19+
$this->f = fopen($file, "r");
20+
}
21+
22+
function parse(){
23+
$map = array();
24+
25+
while($line = fgets($this->f)) {
26+
if (preg_match("/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/", $line, $matches)) {
27+
$unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]);
28+
$map[hexdec($matches[1])] = array($unicode, $matches[4]);
29+
}
30+
}
31+
32+
ksort($map);
33+
34+
return $map;
35+
}
36+
}

classes/font.cls.php

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
<?php
2-
/**
3-
* @package php-font-lib
4-
* @link http://php-font-lib.googlecode.com/
5-
* @author Fabien Ménager <[email protected]>
6-
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7-
* @version $Id: font.cls.php 41 2012-02-04 18:01:38Z fabien.menager $
8-
*/
9-
10-
/**
11-
* Generic font file.
12-
*
13-
* @package php-font-lib
14-
*/
15-
class Font {
16-
static $debug = false;
17-
18-
/**
19-
* @param string $file The font file
20-
* @return Font_TrueType $file
21-
*/
22-
public static function load($file) {
23-
$header = file_get_contents($file, false, null, null, 4);
24-
$class = null;
25-
26-
switch($header) {
27-
case "\x00\x01\x00\x00":
28-
case "true":
29-
case "typ1":
30-
$class = "Font_TrueType"; break;
31-
32-
case "OTTO":
33-
$class = "Font_OpenType"; break;
34-
35-
case "wOFF":
36-
$class = "Font_WOFF"; break;
37-
38-
case "ttcf":
39-
$class = "Font_TrueType_Collection"; break;
40-
41-
// Unknown type or EOT
42-
default:
43-
$magicNumber = file_get_contents($file, false, null, 34, 2);
44-
45-
if ($magicNumber === "LP") {
46-
$class = "Font_EOT";
47-
}
48-
}
49-
50-
if ($class) {
51-
require_once dirname(__FILE__)."/".strtolower($class).".cls.php";
52-
53-
$obj = new $class;
54-
$obj->load($file);
55-
56-
return $obj;
57-
}
58-
}
59-
60-
static function d($str) {
61-
if (!self::$debug) return;
62-
echo "$str\n";
63-
}
64-
65-
static function UTF16ToUTF8($str) {
66-
return mb_convert_encoding($str, "utf-8", "utf-16");
67-
}
68-
69-
static function UTF8ToUTF16($str) {
70-
return mb_convert_encoding($str, "utf-16", "utf-8");
71-
}
72-
}
1+
<?php
2+
/**
3+
* @package php-font-lib
4+
* @link http://php-font-lib.googlecode.com/
5+
* @author Fabien Ménager <[email protected]>
6+
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7+
* @version $Id$
8+
*/
9+
10+
/**
11+
* Generic font file.
12+
*
13+
* @package php-font-lib
14+
*/
15+
class Font {
16+
static $debug = false;
17+
18+
/**
19+
* @param string $file The font file
20+
* @return Font_TrueType $file
21+
*/
22+
public static function load($file) {
23+
$header = file_get_contents($file, false, null, null, 4);
24+
$class = null;
25+
26+
switch($header) {
27+
case "\x00\x01\x00\x00":
28+
case "true":
29+
case "typ1":
30+
$class = "Font_TrueType"; break;
31+
32+
case "OTTO":
33+
$class = "Font_OpenType"; break;
34+
35+
case "wOFF":
36+
$class = "Font_WOFF"; break;
37+
38+
case "ttcf":
39+
$class = "Font_TrueType_Collection"; break;
40+
41+
// Unknown type or EOT
42+
default:
43+
$magicNumber = file_get_contents($file, false, null, 34, 2);
44+
45+
if ($magicNumber === "LP") {
46+
$class = "Font_EOT";
47+
}
48+
}
49+
50+
if ($class) {
51+
require_once dirname(__FILE__)."/".strtolower($class).".cls.php";
52+
53+
$obj = new $class;
54+
$obj->load($file);
55+
56+
return $obj;
57+
}
58+
}
59+
60+
static function d($str) {
61+
if (!self::$debug) return;
62+
echo "$str\n";
63+
}
64+
65+
static function UTF16ToUTF8($str) {
66+
return mb_convert_encoding($str, "utf-8", "utf-16");
67+
}
68+
69+
static function UTF8ToUTF16($str) {
70+
return mb_convert_encoding($str, "utf-16", "utf-8");
71+
}
72+
}

0 commit comments

Comments
 (0)