2016-09-30 18 views

答えて

0

私はそれを現在行う方法がないと思います。サブレンジスタイルは文字単位で設定され、行のすべての文字に同じtextAlignを指定しても、テキストの配置方法には影響しません。 textAlignはオブジェクト全体に対してのみ機能します。

window.canvas = new fabric.Canvas('c', { selection: false, preserveObjectStacking:true }); 
 

 
canvas.add(new fabric.IText(`some text 
 
here on 
 
multiple lines`,{ 
 
    left: 100, 
 
    top: 100, 
 
    fill: 'red', 
 
    originX: 'left', 
 
    originY: 'top', 
 
    centeredRotation: true, 
 
    textAlign: 'center', 
 
    styles: { 
 
    \t 0: { 
 
    \t 0: { fill: 'blue', textAlign: 'right' }, 
 
    \t 1: { fill: 'blue', textAlign: 'right' }, 
 
    \t 2: { fill: 'blue', textAlign: 'right' }, 
 
    \t 3: { fill: 'blue', textAlign: 'right' }, 
 
    \t 4: { fill: 'green', textAlign: 'right' }, 
 
    \t 5: { fill: 'green', textAlign: 'right' }, 
 
    \t 6: { fill: 'green', textAlign: 'right' }, 
 
    \t 7: { fill: 'green', textAlign: 'right' }, 
 
    \t 8: { fill: 'green', textAlign: 'right' } 
 
    } 
 
    } 
 
}));
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.4/fabric.min.js"></script> 
 
<canvas id="c" width="600" height="600"></canvas>