Sharp: Pango Error: Fonts failed to load.

Created on 17 Mar 2018  路  9Comments  路  Source: lovell/sharp

So, basically. I'm trying to overlay an image with svg text.

const text = new Buffer(
<svg height="90" width="200"><text x="45" y="65" fill="white" font-weight="bold">Some text</text></svg>
);

sharp(file) .overlayWith(text) .resize(65, 65) .toFile(outputFile, (error) => { if(error){ console.log(error); } else { //do something }

When I do this, I get the following errors.

*`(sharp:7696): Pango-WARNING *: couldn't load font "Times New Roman, Not-Rotated
12", falling back to "Sans Not-Rotated 12", expect ugly output.

(sharp:7696): Pango-WARNING **: couldn't load font "Sans Not-Rotated 12", fallin
g back to "Sans Not-Rotated 12", expect ugly output.

(sharp:7696): Pango-WARNING **: All font fallbacks failed!!!!

(sharp:7696): Pango-WARNING : All font fallbacks failed!!!!`

I'm not sure what I'm doing wrong. I'm rather new to programming so if someone could tell me what I'm doing wrong, I would greatly appreciate it.

question

Most helpful comment

Hello, libvips renders SVG files with librsvg, which renders fonts with pango, which searches for fonts with fontconfig, which should look in your system font directory/ies.

You haven't said which platform you're using, but on Linux fonts are usually in /usr/share/fonts/ and on OS X in /System/Library/Fonts or /Library/Fonts.

Do these paths exist? Do they contain the font you're looking for, in this case "Times New Roman"?

All 9 comments

Hello, libvips renders SVG files with librsvg, which renders fonts with pango, which searches for fonts with fontconfig, which should look in your system font directory/ies.

You haven't said which platform you're using, but on Linux fonts are usually in /usr/share/fonts/ and on OS X in /System/Library/Fonts or /Library/Fonts.

Do these paths exist? Do they contain the font you're looking for, in this case "Times New Roman"?

I'm currently using Windows. I know for a fact that the font does exist because it does render the SVG sometimes, and then it randomly gives an error.

If the problem is randomly occuring then I suspect a problem local to font discovery on your machine. Perhaps try setting the FC_DEBUG environment variable, with the most verbose level being FC_DEBUG=8191. Good luck!

https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#DEBUG

Thanks! I'll look into this.

awesome. save my time.

I'm literally using font-family='Arial' and getting the same issue. So it's not just that the font can't be found. I'm running on a single machine with the same exact same overlaid SVG. The image is normally cached, but I've added a random cache busting timestamp.

I think it must be a resources / race condition type of issue - it's an Angular application which auto reloads. When I refresh the app the server gets bombarded with requests from all the devices I'm testing on (iPad/iPhone/multiple browser windows/multiple images). So I think the server just can't cope.

I'll try to add FC_DEBUG but I'm new to NodeServices under dotnetcore and will have to lookup tomorrow how to do that.

If the problem is randomly occuring then I suspect a problem local to font discovery on your machine. Perhaps try setting the FC_DEBUG environment variable, with the most verbose level being FC_DEBUG=8191. Good luck!

https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#DEBUG

Hello,

I've got the same errors occured randomly in async mode in a little loop (maximum 5 times, could be only maximum 2 times).
So to resolve this issue I've used "await" operator and no more errors with the font issue.

Nicolas.

Error comes up when processing multiple images in parallel:

files.map(([source, dest]) =>
  sharp(path).toFile(dest)
)

When in sequence - it doesn't:

for (let [source, dest] of files) {
  await sharp(source).toFile(dest)
}

Please see #1277 for why this occurs on Windows.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

henbenla picture henbenla  路  3Comments

jaydenseric picture jaydenseric  路  3Comments

paulieo10 picture paulieo10  路  3Comments

natural-law picture natural-law  路  3Comments

vermin1337 picture vermin1337  路  3Comments