Fonts in node-canvas

Make sure you’re using pango-cairo

Set FONTCONFIG_PATH and place fonts.conf there

  1. Create a directory, assets/fonts, and copy/paste the fonts.conf from above into it.
  2. Copy all font files for your project into assets/fonts/. They should be .ttf and .otf files.
  3. Before using node-canvas, set the environment variable FONTCONFIG_PATH to point to the directory that holds fonts.conf. You can either do this in your shell (Bash: FONTCONFIG_PATH=assets/fonts node render.js) or within your script (Node: process.env.FONTCONFIG_PATH = './path/to/assets/fonts').

Force FontConfig on Mac OS X and Windows

Use ctx._setFont()

Debug with FC_DEBUG, fc-match, fc-list and pango-view

My parting thoughts




Journalist, ex software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Hooper

Adam Hooper

Journalist, ex software engineer

More from Medium

Clean Code with ESLint

Webpack 5 Module Federation A-Z: React Foodie App (Part I)

Overmind, the state management library you don’t know (yet) (but should)