Search code examples
fabricjs

Font Family Does Not Change


I am using fabricjs. I let the user change the font family. However, these changes are not reflected on the canvas after they are made. I need to change the width or height of the text box. When I make this change, the textbox on the canvas is rendered and the new font appears. How can I solve this problem?

canvas.renderAll() doesn't solve the problem.

enter image description here


Solution

  • The browser loads a font only after using it in the DOM. So you need to install fonts before using them.

    You can use -> https://github.com/typekit/webfontloader

    Include this in your application and ensure that fonts are added to the DOM during the installation process.