Skip to content

Commit f0d29b9

Browse files
committed
Fix a bug with little endian names in EOT files and decode UTF16 string
Add a sample EOT file (Norasi)
1 parent 49224c6 commit f0d29b9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

classes/font_eot.cls.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,20 @@ function parse() {
3939

4040
// TODO
4141
}
42-
43-
public function readUInt16() {
44-
$a = unpack('vv', $this->read(2));
45-
return $a['v'];
46-
}
4742

48-
public function readUInt32() {
49-
$a = unpack('VV', $this->read(4));
50-
return $a['V'];
43+
/**
44+
* Little endian version of the read method
45+
*/
46+
public function read($n) {
47+
if ($n < 1) {
48+
return "";
49+
}
50+
51+
$string = fread($this->f, $n);
52+
$chunks = str_split($string, 2);
53+
$chunks = array_map("strrev", $chunks);
54+
55+
return implode("", $chunks);
5156
}
5257

5358
/**

classes/font_eot_header.cls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function readString($name) {
6868
$size = $font->readUInt16();
6969

7070
$this->data["{$name}Size"] = $size;
71-
$this->data[$name] = $font->read($size);
71+
$this->data[$name] = Font::UTF16ToUTF8($font->read($size));
7272
}
7373

7474
public function encode(){

fonts/Norasi.eot

101 KB
Binary file not shown.

0 commit comments

Comments
 (0)