简体   繁体   中英

Python - How to install font on AWS Lambda?

I'm trying to install a font on AWS Lambda to use TextClip() function of moviepy. I followed step by step this answer https://stackoverflow.com/a/51622335/6673340 , but the font still doesn't want to instal...

I have the following files and dir in my deployement package:

在此处输入图像描述

This is my fonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/opt/fonts/</dir>
  <cachedir>/tmp/fonts-cache/</cachedir>
  <config></config>
</fontconfig>

And I also add: FONTCONFIG_PATH=/opt/fonts

But I still get the following error:

[ERROR] OSError: MoviePy Error: creation of None failed because of the following error:

convert: unable to read font `Rubik-Regular' @ warning/annotate.c/RenderType/955.
convert: delegate library support not built-in 'Rubik-Regular' (Freetype) @ warning/annotate.c/RenderFreetype/1808.
convert: no images defined `PNG32:/tmp/tmp3h8xrg3n.png' @ error/convert.c/ConvertImageCommand/3300

Do either of you know why this isn't working for me?

/var/task is the directory where you codebase lives as per lambda convention 

so as per your current structure i think FONTCONFIG_PATH=/var/task/fonts

and font.conf should be 

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/var/task/fonts/</dir>
  <cachedir>/tmp/fonts-cache/</cachedir>
  <config></config>
</fontconfig>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM