canvas - Wrap text to a new line once maxWidth is reached in EaselJS -
i new easeljs. set maxwidth property of text 200px , after maximum width reached, text starts getting compressed. how ensure text wraps new line after max width reached?
var text = new createjs.text(); text.set({ text: "lorem ipsum dolor sit amet, consectetur adipiscing elit. nam elementum elit vitae nisl elementum, et aliquet quam malesuada. pellentesque porta consequat pellentesque. quisque vel molestie quam. aliquam in vehicula magna. integer ac congue sem, et tempor libero. etiam pharetra, quam et posuere porta, lectus odio iaculis nibh, eget porttitor magna elit id felis. mauris luctus lobortis tincidunt." x: 0, y: 0, font: "16px arial black", maxwidth: 200 })
you want linewidth
instead of maxwidth
. maxwidth
mirrors default html canvas behaviour of shrinking text fit, whereas linewidth
wrap text new line.
var text = new createjs.text().set({ text: "lorem ipsum dolor sit amet, consectetur adipiscing elit. nam elementum elit vitae nisl elementum, et aliquet quam malesuada. pellentesque porta consequat pellentesque. quisque vel molestie quam. aliquam in vehicula magna. integer ac congue sem, et tempor libero. etiam pharetra, quam et posuere porta, lectus odio iaculis nibh, eget porttitor magna elit id felis. mauris luctus lobortis tincidunt.", x: 0, y: 0, font: "16px arial black", linewidth: 200 });
here sample: http://jsfiddle.net/lannymcnie/sh0s6t30/
Comments
Post a Comment