PIXIJS中Text文本实现多行文本,换行,首行缩进;解决换行失效问题

在PIXIJS中,对于多行文本是支持的,但是会有一些问题

 

Name Type Default Description

wordWrap

boolean false optional

Indicates if word wrap should be used

wordWrapWidth number 100 optional

The width at which text will wrap, it needs wordWrap to be set to true

多行文本可以这么设置:
wordWrap: true,//开启换行
wordWrapWidth: 900//代表换行长度

问题1:中文不支持多行文本

breakWords: true可以添加这个属性,支持中文

但不支持中英文来回切换

问题2:首行缩进无法实现

首先pixi没有相关首行缩进API,其次如果直接首部加2个空格会被清除,这里可以使用空白字符来代替空格。

猜你喜欢

转载自blog.csdn.net/HuoYiHengYuan/article/details/106127748