I want to use Arial and Arial Bold for my PDF. It works flawlessly on my Windows Laptop with simple css body { font-family: "Arial"; }
But when I put it on Ubuntu-based Server, the font doesn't load and use another font instead.
I tried
@font-face {
font-family: 'Arial';
src: url('{{storage_path('fonts/arial.ttf')}}');
}
but it gives me error
The exit status code '1' says something went wrong: stderr
"Loading pages (1/6) [> ] 0% [======> ] 10%
QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files
...
It's now working by append file:// on path given in src: url('');
Previously I tried append file:/// (note an extra slash) from an issue in wkthmltopdf's github and it doesn't work so this time I skip read it. Hence noticing it late.
I don't know if it's mentioned anywhere, but appending file:// is only needed IF the url given is a file path on local/server. If it's an actual url, adding file:// before http:// or the likes will result in error
@hilmanfaiz Could you show me the example that worked for you?
I'm having exactly the same problem and I still can't solve it.
@lucasjsandrade This is what I use
@font-face {
font-family: 'pathArial';
src: url("file://{{storage_path('fonts/arial.ttf')}}") format('truetype');
}
@font-face {
font-family: 'pathArialBlack';
src: url("file://{{storage_path('fonts/arial-black.ttf')}}") format('truetype');
}
@font-face {
font-family: 'urlArial';
src: url("{{url('fonts/arial.ttf')}}") format('truetype');
}
@font-face {
font-family: 'urlArialBlack';
src: url("{{url('fonts/arial-black.ttf')}}") format('truetype');
}
body {
font-family: "Arial", "pathArial", "urlArial";
}
h1 {
font-family: "Arial Black", "pathArialBlack", "urlArialBlack";
}
Unfortunately for me, it works for Arial but not for Arial Black on my server (Ubuntu 16.04 LTS).
Fortunately for me, I only need Arial Black for a fixed string. So I screenshot that string with correct font and place it as an image.
I need to find a solution, because I use Times New Roman in the headers of company reports, this is a standard font, I use domPdf in smaller reports, it works perfectly on the same server, but I had a problem with several pages, I am implementing the snappy for more reports complex, I need to find a way to apply that font. if i find a solution, i will share it here, thanks.
@hilmanfaiz
I managed to solve using your code as a parameter, thank you very much for your help.
Most helpful comment
@lucasjsandrade This is what I use
Unfortunately for me, it works for
Arialbut not forArial Blackon my server (Ubuntu 16.04 LTS).Fortunately for me, I only need
Arial Blackfor a fixed string. So I screenshot that string with correct font and place it as an image.