Adding new font to my custom fonts with AWS lambda not working

0

I'm using AWS lambda with python and ffmpeg to add textual watermark over images. I added a custom font i.e Quicksand to my lambda function like this:

1- Create a fonts directory in the root of the function and add the font file (.ttf) and a font.conf file with the following contents:

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

2- Added an environment variable like this

FONTCONFIG_PATH = "/var/task/fonts"

It was working fine until I chose to add more fonts. Now when I try to use some font other than the Quicksand e.g Arial, it still uses the Quicksand font. I'm not sure why? In the CloudWatch Logs I can see it is still trying to access the Quicksand font rather than the Arial one even when the code is right. Any caching issue or something else?

My Folder Structure: Enter image description here

My docker file:

COPY requirements.txt ./
RUN yum update -y && \
    pip install -r requirements.txt

COPY . .
CMD ["app.handler"]

Cloudwatch logs:

[Parsed_drawtext_0 @ 0x70b5bc0] Using "/var/task/fonts/Quicksand.ttf"

Maybe its a caching issue? I'm not sure.

1回答
0

I am guessing this is something in your own code. Or maybe in your fonts.config file.

profile pictureAWS
エキスパート
Uri
回答済み 2年前
  • Which fonts.config file? I only have fonts.conf file and I've added that in the question. Also, the code is fine. I've added the logs and have also tried to use hardcoded font names. But it still uses the Quicksand (added first). If I remove Quicksand font then it uses the second one. But still doesn't let me use any other.

  • I meant the font.conf file, sorry. I am not familiar with ffmpeg, What I am saying is that it is most probably not related to Lambda, but to the library itself. I did a quick search and found the following answer, which I think can help you as well.

  • Thank you. I ended up storing the fonts on s3 bucket and copying them to /tmp storage for usage inside the function. Nothing else was working

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ