Reputation: 1125
I'm using Intervention package in Laravel5 for Inserting a text in image, and its is working well. But if I add font(.ttf) it shows the following error. The directory is correct.
NotSupportedException in Font.php line 30: Internal GD font () not available. Use only 1-5.
$image = Image::make(public_path('/userimage/') . "user.png");
$image->text('text string', 10, 5, function($font) {
$font->file(asset('/web/fonts/OpenSans-Regular.ttf'));
$font->size(50);
$font->color('#fdf6e3');
$font->angle(45);
});
Upvotes: 2
Views: 10686
Reputation: 2081
Removing public_path() worked for me.
$image = Image::make('userimage/') . "user.png";
$image->text('text string', 10, 5, function($font) {
$font->file('web/fonts/OpenSans-Regular.ttf');
$font->size(50);
$font->color('#fdf6e3');
$font->angle(45);
});
Upvotes: 1
Reputation: 196
Use base_path()
instead of asset()
.
Example:
$font->file(base_path('public/web/fonts/OpenSans-Regular.ttf'));
Upvotes: 3
Reputation: 31
The GD library does not support custom fonts. You are supposed to use Imagick. Go to config/image.php and edit the driver value to 'imagick' (after you actually install the extension for it):
'driver' => 'imagick'
asset('/web/fonts/OpenSans-Regular.ttf')
returns an URL. You have to provide a path. Use public_path('web/fonts/OpenSans-Regular.ttf')
instead.
Upvotes: 3
Reputation: 15457
Two things you can try:
$font->file(asset('web/fonts/OpenSans-Regular.ttf'));
chmod 755 path/to/web/fonts/OpenSans-Regular.ttf
just in case.Upvotes: 1
Reputation: 567
I would do this:
dd(asset('/web/fonts/OpenSans-Regular.ttf'))
and see if it matches
expected path.Upvotes: 1