A
A
Andrey Godin2015-09-26 23:32:06
Canvas
Andrey Godin, 2015-09-26 23:32:06

How to make Fabric.js friends with Russian text and make fontFamily show correctly?

I am doing a rather complicated project and everything seems to work out, but there is one thing that I don’t understand at all. In kitchensink, this is easy and simple, but their code is not freely available and it is very complex and confusing to figure it out right away.
I have two problems when working with text. And both are related to fontFamily
1. If I generate text immediately on button click, then everything is fine. If I saved several texts, and then I load them, then they are displayed in some standard font. Any click on the canvas changes the font to the one you need.
canvas.add(text);
canvas.setActiveObject(text);
canvas.renderAll();
canvas.calcOffset();
All this is used.
The second problem is the Russian language. The font family does not change on it. If you write "new Vasyuki" in one text, then new will change the font, and Vasyuki will be displayed in the standard font.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fairwind, 2015-09-27
@xilix

Most likely, the text is rendered before the font is loaded.
If so, you can, as an option, pre-load the fonts.
For example, using github.com/typekit/webfontloader .
As for the Russian language - is the font generally Cyrillic?

A
Andrey Godin, 2015-09-27
@xilix

Interesting about fonts. Need to check. But after all, just the text value of fontFamily is used. Where are the fonts loaded from?
I also noticed that if you first draw a graphic object, then the text, then the font is displayed normally. But not in the case of the Russian language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question