Search code examples
phpfontsgoogle-font-apiphp-gd

Using Google Font in PHP GD


I am trying to use a custom font in an image made with PHP GD.

I intend to call int imageloadfont(string $file), but I'm not sure what $file to give if I want to get a Google Font directly from their website.

Do I need to download the font or is there a way to get it remotely?


Solution

  • You can use the .ttf file from Google servers directly if you have allow_url_fopen enabled in your PHP installation. Look into the stylesheet to get the correct url.

    However, for best performance, availability and security, you should download the file and use a local path.