【问题标题】:Python - How to install font on AWS Lambda?Python - 如何在 AWS Lambda 上安装字体?
【发布时间】:2020-12-05 15:48:44
【问题描述】:

我正在尝试在 AWS Lambda 上安装字体以使用 moviepy 的 TextClip() 函数。 我一步一步跟着这个答案https://stackoverflow.com/a/51622335/6673340,但字体还是不想安装...

我的部署包中有以下文件和目录:

这是我的 fonts.conf :

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

我还要补充:FONTCONFIG_PATH=/opt/fonts

但我仍然收到以下错误:

[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

你们知道为什么这对我不起作用吗?

【问题讨论】:

  • 嘿,我也面临同样的问题。你能解决这个问题吗?

标签: python fonts aws-lambda installation


【解决方案1】:
/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>

【讨论】:

  • 不要只是在答案中添加代码,解释代码并具体解决提问者的问题。
猜你喜欢
  • 1970-01-01
  • 2017-02-15
  • 1970-01-01
  • 1970-01-01
  • 2019-11-09
  • 1970-01-01
  • 2017-11-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多