diff --git a/src/FontLib/AdobeFontMetrics.php b/src/FontLib/AdobeFontMetrics.php index a62daaa..a0e973b 100644 --- a/src/FontLib/AdobeFontMetrics.php +++ b/src/FontLib/AdobeFontMetrics.php @@ -139,7 +139,7 @@ function write($file, $encoding = null) { $this->endSection("CharMetrics"); $kern = $font->getData("kern", "subtable"); - $tree = $kern["tree"]; + $tree = is_array($kern) ? $kern["tree"] : null; if (!$encoding && is_array($tree)) { $this->startSection("KernData"); diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index ab10454..414ef03 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -38,16 +38,17 @@ class BinaryStream { const modeReadWrite = "rb+"; static function backtrace() { - var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); + var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); } - /** - * Open a font file in read mode - * - * @param string $filename The file name of the font to open - * - * @return bool - */ + /** + * Open a font file in read mode + * + * @param string $filename The file name of the font to open + * + * @return bool + * @throws \Exception + */ public function load($filename) { return $this->open($filename, self::modeRead); } @@ -142,7 +143,8 @@ public function read($n) { return ""; } - return fread($this->f, $n); + // handle the return data, DO NOT spew E_NOTICEs + return @fread($this->f, $n); } public function write($data, $length = null) { @@ -150,7 +152,8 @@ public function write($data, $length = null) { return 0; } - return fwrite($this->f, $data, $length); + // handle the return data, DO NOT spew E_NOTICEs + return @fwrite($this->f, $data, $length); } public function readUInt8() {