1

I have a firebase function that generates and returns a pdf blob.

Locally, and using firebase serve, I can use a font loaded from a url and locally.

On firebase, the font is not ever loaded. I have tried variations of this in my template.html

<style>

  @import url('./fonts/helvetica-neue.ttf'); and
  @import url('http://somewebsite.com/fonts/helvetica-neue.ttf');
  @import url('https://somewebsite.com/fonts/helvetica-neue.ttf');

  body > * {
   font-family: 'Helvetica Neue', sans-serif;
   font-weight: regular;
  }
</style>

I have also tried importing google fonts using the link tag. This does not work either.

Remember firebase serve and locally installed Node works fine and the font is fetched and used.

There are no errors in firebase logs.

Has anyone had success loading a custom font using firebase functions? I am using node-html-pdf to generate the pdf. The pdf generates fine, but it uses DevaVu Sans font (I assume this is standard san-serif font on Firebase)

cdelambert
  • 21
  • 5

1 Answers1

0

From the link here, It seem that your font Helvetica Neue is not supported in Linux Based OS. So, maybe because firebase cloud functions is running on linux based machine, thus your font cannot be rendered and use the default font instead.

Maybe it will be another story, if we can install the font manually on the cloud functions server machine.

Faruk
  • 5,438
  • 3
  • 30
  • 46
  • You pointed me in the right direction faruk. PhantomJS requires the fonts to be installed on the machine to render the html correctly. I am not sure if it's possible to install fonts on Firebase servers so I'll have to go with another platform. Thanks for the suggestion! – cdelambert Feb 19 '19 at 23:43