Image: Loading custom font file not working

Created on 29 Dec 2015  路  7Comments  路  Source: Intervention/image

I am getting either of the two problems below, even after specifying the correct public path.

Call to undefined function Intervention\Image\Gd\imagettfbbox()

or

Intervention \ Image \ Exception \ NotSupportedException
Internal GD font () not available. Use only 1-5.`

I also viewed this issue but could not get any help : https://github.com/Intervention/image/issues/149 Can anyone find out the cause of such errors?
My code is :

$img->text($text, 275, 200, function($font) {
            $font->file(public_path('assets/fonts/Alpaca.ttf'));
            $font->size(60);
            $font->color('#fdf6e3');
            $font->align('center');
            $font->valign('middle');
            $font->angle(45);
        });

Most helpful comment

I've solved this in a docker image with

apt-get install -y libpng-dev libfreetype6-dev libjpeg62-turbo-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd

All 7 comments

Call to undefined function Intervention\Image\Gd\imagettfbbox()

I would say for some reason the GD function imagettfbbox is missing on your system. Maybe GD is not installed completely or not installed at all?

Thank you for your reply.
The problem though was that my server had GD support enabled but Freetype was not installed.
Its working like a charm now.

I installed Freetype, but how do I activate it for PHP?

If you are on a Mac (like I was), MAMP will do the heavy lifting for you. That was what I did at this particular case : after installing Freetype, use MAMP as the local development server.

I'm using Homestead and Vagrant.

I'm using Homestead and Vagrant.

It has to be installed inside the vagrant box. You can SSH inside your machine via 'vagrant ssh'.

I've solved this in a docker image with

apt-get install -y libpng-dev libfreetype6-dev libjpeg62-turbo-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd
Was this page helpful?
0 / 5 - 0 ratings

Related issues

txusramone picture txusramone  路  6Comments

REPTILEHAUS picture REPTILEHAUS  路  5Comments

cherrycoding picture cherrycoding  路  3Comments

knif3rdev picture knif3rdev  路  6Comments

ctf0 picture ctf0  路  4Comments