Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Load fonts from given directory. #14654

Closed
gaurav-sharma-mt opened this issue Nov 21, 2016 · 10 comments
Closed

Load fonts from given directory. #14654

gaurav-sharma-mt opened this issue Nov 21, 2016 · 10 comments

Comments

@gaurav-sharma-mt
Copy link

  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

  4. Which operating system are you using?
    Linux ip---- 4.4.23-31.54.amzn1.x86_64 proxy support #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.

@vitallium
Copy link
Collaborator

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

@gaurav-sharma-mt
Copy link
Author

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.`

@dominikkukacka
Copy link

dominikkukacka commented Mar 10, 2017

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

@gaurav-sharma-mt
Copy link
Author

gaurav-sharma-mt commented Mar 14, 2017

@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.

@dominikkukacka
Copy link

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

@netmanuy
Copy link

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
Copy link

netmanuy commented Apr 4, 2017

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

@rowan-met
Copy link

@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?

@netmanuy
Copy link

Hi @rowan-met

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

@PierBover
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants