From 85cb7e398f0f5503d772aaf2a546722516f9a0b2 Mon Sep 17 00:00:00 2001 From: Bruno De Barros Date: Wed, 3 Feb 2016 16:09:23 +0000 Subject: [PATCH] Fixes an "Undefined offset: 1" PHP Notice. When using DejaVu Sans or any @font-face font, this would always throw PHP errors in my app. It makes sense to check if it's set to prevent the notice. Ideally, though, this shouldn't even be throwing errors, but I don't know enough about php-font-lib's code to figure out what is going on. Here's a minimal test case HTML that causes the error: http://i.28hours.org/files/php-font-lib-undefined-offset.html --- src/FontLib/BinaryStream.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index 2b6b7eb..c93b83c 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -411,7 +411,9 @@ public function w($type, $data) { $ret = 0; for ($i = 0; $i < $type[1]; $i++) { - $ret += $this->w($type[0], $data[$i]); + if (isset($data[$i])) { + $ret += $this->w($type[0], $data[$i]); + } } return $ret;