Include custom fonts in AWS Lambda

后端 未结 5 1751
独厮守ぢ
独厮守ぢ 2021-01-25 17:16

Does Anyone know something like ebextensions[2] in EC2 for AWS Lambda?

The goal is to install custom fonts in the AWS Lambda execution environment.

5条回答
  •  悲&欢浪女
    2021-01-25 17:45

    Here's what I just got to work for custom fonts on AWS Lambda with pandoc/xelatex.

    I created a fonts directory in my project and placed all of my fonts there. Also in that directory I created a fonts.conf file that looks like this:

    
    
    
      /var/task/fonts/
      /tmp/fonts-cache/
      
    
    

    And then in my (node.js based) handler function before shelling out to call pandoc I set an ENV var to tell fontconfig where to find the fonts.

    process.env.FONTCONFIG_PATH='/var/task/fonts'
    

    After doing that I can refer to a font, like Bitter, in my template by name (just Bitter) and then pandoc/xelatex/fontconfig/whatever knows which version of the font to use (like Bitter-Bold.otf vs Bitter-Italic.otf) based on the styling that any bit of text is supposed to have.

    I figured this out based on the tips in this project for getting RSVG to work with custom fonts on Lambda: https://github.com/claudiajs/rsvg-convert-aws-lambda-binary/blob/master/README.md#using-custom-fonts

提交回复
热议问题