Load fonts from given directory.
-
Which version of PhantomJS are you using? Tip: run
phantomjs --version. version: 2.1.1 -
What steps will reproduce the problem?
-
package and run on AWS lambda 2. 3.
-
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
-
Did you use binary PhantomJS or did you compile it from source? binary PhantomJS
-
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.
You can use QT_QPA_FONTDIR environment variable to specify the directory to load fonts from.
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.`
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 dominikkukacka What have you stored in HOME variable. it should be set to /var/task . Your aws binary is stored in in this location.
Thanks, I just solved it. I had to upgrade to the latest phantomjs stable.
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
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 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?
Hi @rowan-met
Yes, on Lambda Console under "Environment variables" you need to set HOME as variable name and "/var/task" as value
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.