dompdf, Laravel Vapor and CSS font link error - fopen in /tmp/storage/fonts, no such file or directory

Author: JamiewarbCreated Oct 17, 2022Updated Feb 4, 2026
Labelsstale

Hi there,

When attempting to use dompdf with Laravel Vapor and importing a google font via CSS import, I'm getting the following issue:

fopen(/tmp/storage/fonts/work_sans_normal_d6eeffee426555fe4bcfe67ec779bf1d.ufm): Failed to open stream: No such file or directory

The font link I'm using is

<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;600&display=swap" rel="stylesheet">

It gets to dompdf's FontMetrics methods, and then tries to open this file using fopen('/tmp/storage/fonts/work_sans_normal_d6eeffee426555fe4bcfe67ec779bf1d.ufm', w+), and fails with this error.


I read the following PR within this repo, which mentions setting dompdf's font cache etc to /tmp: https://github.com/barryvdh/laravel-dompdf/issues/687

However, from the error message, it looks like this is already set to /tmp, as it's trying to open this file there.

Has anyone else gotten dompdf to work with Laravel vapor and a custom font?