phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

Load fonts from given directory.

Open gaurav-sharma-mt opened this issue 10 years ago • 10 comments

  1. Which version of PhantomJS are you using? Tip: run phantomjs --version. version: 2.1.1

  2. What steps will reproduce the problem?

  3. package and run on AWS lambda 2. 3.

  4. Which operating system are you using? Linux ip---- 4.4.23-31.54.amzn1.x86_64 #1 SMP Tue Oct 18 22:02:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

  5. Did you use binary PhantomJS or did you compile it from source? binary PhantomJS

  6. Please provide any additional information below. Not able to load fonts as phantomJS use root directory(system fonts) and Do not have permission in AWS lambda Is there a way to pass an argument to phantomjs to load fonts from a given directory.

gaurav-sharma-mt avatar Nov 21 '16 14:11 gaurav-sharma-mt

You can use QT_QPA_FONTDIR environment variable to specify the directory to load fonts from.

vitallium avatar Nov 21 '16 14:11 vitallium

I ended up setting HOME environment variable. Apparently phantom looks for fonts in ~/.fonts/TTF. I will switch to this as this appears to be better.`

gaurav-sharma-mt avatar Nov 22 '16 07:11 gaurav-sharma-mt

I am also trying to get phantomJS to load custom TTF fonts on AWS Lambda, but somehow it neither recognises QT_QPA_FONTDIR nor HOME/.fonts/TTF Is there any indicator in the phantomJS logs if it was able to load the fonts. What does the folder structure look like in both cases? PhantomJS complains about WOFF support requires QtWebKit to be built with zlib support. but this is not the problem, right?

@Vitallium @gaurav-sharma-mt

dominikkukacka avatar Mar 10 '17 16:03 dominikkukacka

@dominikkukacka dominikkukacka What have you stored in HOME variable. it should be set to /var/task . Your aws binary is stored in in this location.

gaurav-sharma-mt avatar Mar 14 '17 09:03 gaurav-sharma-mt

Thanks, I just solved it. I had to upgrade to the latest phantomjs stable.

dominikkukacka avatar Mar 14 '17 10:03 dominikkukacka

Hi Guys

I'm having the same issue , I have set 2 environments HOME and QT_QPA_FONTDIR on my lambda function but to be honest I can read them but I do not know what to do with them later

This is the command I use inside my NodeJs lambda function

./phantomjs_linux-x86_64 --debug=yes --ignore-ssl-errors=true takescreens.js "${url}" /tmp/${fileHash}.png

I'm using the official package downloaded from http://phantomjs.org/download.html and try to put the fonts inside my projects .fonts/TTF and set the variables HOME & QT_QPA_FONTDIR with this value

HOME = /var/task QT_QPA_FONTDIR = /var/task/.fonts/TTF

Any suggestions would be greatly appreciated

Thanks

netmanuy avatar Mar 31 '17 19:03 netmanuy

Hi Guys.

I found the solution and it's simple, you just need to add the HOME variable directly on your lambda function as environment variable.

Thanks

netmanuy avatar Apr 04 '17 17:04 netmanuy

@netmanuy I'm experiencing this issue - when you say:

you just need to add the HOME variable directly on your lambda function as environment variable

Do you mean in the lambda console or some other means?

rowan-met avatar Aug 21 '17 08:08 rowan-met

Hi @rowan-met

Yes, on Lambda Console under "Environment variables" you need to set HOME as variable name and "/var/task" as value

netmanuy avatar Aug 21 '17 16:08 netmanuy

Still it would be great to be able to specify a custom folder with fonts.

AFAIK in Google Cloud Functions for example we can't really define ENV vars.

PierBover avatar Mar 09 '18 19:03 PierBover