I’m using dompdf 3.1.0. The template html resides in public/templates/reports, while the custom fonts are at public/templates/reports/fonts. My CSS inside the template:
@font-face {
font-family: "Ubuntu";
src: url("./fonts/Ubuntu-Regular.ttf"); // I tried absolute path as well, no effect
}
body {
font-family: "Ubuntu", serif;
font-weight: 400;
font-style: normal;
font-size: 10pt;
}
The DomPdf configuration:
$options = new Options();
$options->setIsRemoteEnabled(true);
$options->setFontDir(APPPATH . '../public/templates/reports/fonts');
$options->setFontCache(APPPATH . '../public/templates/reports/fonts');
$options->setChroot(APPPATH . '../public/templates/reports/');
$this->dompdf = new Dompdf($options);
At my local Apache server everything works as expected, however when I try it on the docker container, the font is the default one (even if I set the defaultFont on $options).
Docker image specification:
FROM php:8.3-fpm-alpine3.20
...
WORKDIR /var/www/html
COPY . .
RUN apk add --no-cache curl
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
&& composer install --no-dev
&& chown -R www-data:www-data .
&& chmod -R +r public
According to everything, DomPdf should find the font file. I would appreciate any help.