diff --git a/src/Intervention/Image/Gd/Font.php b/src/Intervention/Image/Gd/Font.php index 47a7b15b..142b7944 100644 --- a/src/Intervention/Image/Gd/Font.php +++ b/src/Intervention/Image/Gd/Font.php @@ -82,6 +82,13 @@ class Font extends \Intervention\Image\AbstractFont if ($this->hasApplicableFontFile()) { + // imagettfbbox() converts numeric entities to their respective + // character. Preserve any originally double encoded entities to be + // represented as is. + // eg:   will render   rather than its character. + $this->text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&\1', $this->text); + $this->text = mb_encode_numericentity($this->text, array(0x0080, 0xffff, 0, 0xffff), 'UTF-8'); + // get bounding box with angle 0 $box = imagettfbbox($this->getPointSize(), 0, $this->file, $this->text);