简体   繁体   中英

FabricJS is not support russian letters

I have a trouble with FabricJS. When I create a russian text with follow constructor, I have no russian text only symbol '!'. What am I doing wrong?

 var textObject = new fabric.Text('Привет!', { originX: 'center', originY: 'center', left: zone.left, top: zone.getCenterPoint().y, textAlign: 'center', fill: finalFill, stroke: '#000', strokeWidth: bezel, fontSize: fontSize, spacing: 5, fontFamily: 'Arial', fontWeight: 'bold', fontStyle: 'normal' }); 

I've checked your example. It looks good. Generally, the Russian text shouldn't be a problem, because we use it in our project. I didn't see any problems with it.

What can I guess: 1. Your left and top values are so, that text is outside of the canvas, and you see only the symbol "!". 2. Other, but hardly - some of your variables have wrong values. Try to set values, as in my example (I've tested it with fabric 2.0.3 and 1.7.22).

https://jsfiddle.net/Eugene_Ilyin/o2drxd0L/

 var canvas = new fabric.Canvas('c'); var textObject = new fabric.Text('Привет!', { originX: 'center', originY: 'center', left: 100, top: 100, textAlign: 'center', fill: 'red', stroke: '#000', strokeWidth: 1, fontSize: 20, spacing: 5, fontFamily: 'Arial', fontWeight: 'bold', fontStyle: 'normal' }); canvas.add(textObject); canvas.renderAll(); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.0.3/fabric.min.js"></script> <canvas id="c"></canvas> 

For me it is rendered like this:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM