简体   繁体   English

Python - 如何在 AWS Lambda 上安装字体?

[英]Python - How to install font on AWS Lambda?

I'm trying to install a font on AWS Lambda to use TextClip() function of moviepy.我正在尝试在 AWS Lambda 上安装字体以使用 Moviepy 的 TextClip() function。 I followed step by step this answer https://stackoverflow.com/a/51622335/6673340 , but the font still doesn't want to instal...我一步一步跟着这个答案https://stackoverflow.com/a/51622335/6673340 ,但字体仍然不想安装......

I have the following files and dir in my deployement package:我的部署 package 中有以下文件和目录:

在此处输入图像描述

This is my fonts.conf:这是我的 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我还补充说: 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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