chrome-aws-lambda
chrome-aws-lambda copied to clipboard
[REQUEST] fonts for rendering special characters
Hi,
I have been trying, without much success, to compile an HTML template into PDF in a AWS lambda function with the correct special characters.
I have included in the head
of my HTML template the following:
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap" rel="stylesheet">
and in css I have this:
html {
-webkit-print-color-adjust: exact;
--font-family-sans-serif: "Montserrat",Helvetica,Arial,serif;
--font-family-monospace: "Montserrat",Helvetica,Arial,serif;
}
* {
color: rgb(14,17,17);
font-size: 1rem;
font-family: "Montserrat",Helvetica,Arial,serif;
}
It renders all the fonts correctly, with the exception of this special character: V̇
, which can also be written like this in HTML: V̇
.
Looking at the google fonts website, it looks like this font can indeed render this character: https://fonts.google.com/specimen/Montserrat?query=montserrat&preview.text=V%CC%87&preview.text_type=custom
However, my PDF is rendered as squares. I was wondering if I should be installing another font in order for this to work?
I'm facing the same issue, is there a way to workaround this?
Here is the solution that worked for me. Download Montserrat.ttf
file and place it in your project folder like my-project/fonts/Montserrat.ttf
. Now set your fonts directory in FONTCONFIG_PATH
environment variable as process.env.FONTCONFIG_PATH=/var/task/my-project/fonts
(/var/task
is the folder where lambda places your project). Deploy your function and it should work.