/**
*...特殊的字符,如泰文,必须重新实现这个类
*/
//class laya.webgl.text.CharSegment
var CharSegment=(function(){
function CharSegment(){
this._sourceStr=null;
}
__class(CharSegment,'laya.webgl.text.CharSegment');
var __proto=CharSegment.prototype;
Laya.imps(__proto,{"laya.webgl.text.ICharSegment":true})
__proto.textToSpit=function(str){
this._sourceStr=str;
var texLen = str.length;
var idx = -1;
this._words = ;
while (++idx < texLen) {
var character = str.charAt(idx);
var code = str.charCodeAt(idx);
if (code >= 0xD800 && code <= 0xDBFF) {
this._words.push(character + str.charAt(++idx));
} else {
this._words.push(character);
}
}
}
__proto.getChar=function(i){
return this._words;
}
__proto.getCharCode=function(i){
return this._words[i].codePointAt(0);
}
__proto.length=function(){
return this._words.length;
}
return CharSegment;
})()[/i]
[i]把上面的类改一下就可以支持了,如果要htmlelement也支持,改一下:[/i]
__proto._getWords=function(){
if (!Text.CharacterCache)return this._getWords2();
var txt=this._text.text;
if (!txt || txt.length===0)
return null;
var words=this._text.words;
var idx = -1;
var texLen = txt.length;
var w = [];
while (++idx < texLen) {
var character = txt.charAt(idx);
var code = txt.charCodeAt(idx);
if (code >= 0xD800 && code <= 0xDBFF) {
w.push(character + txt.charAt(++idx));
} else {
w.push(character);
}
}
if (words && words.length===w.length)
return words;
words===null && (this._text.words=words=[]);
words.length=w.length;
var size;
var style=this.style;
var fontStr=style.font;
var startX=0;
for(var i=0,l=w.length;i
size=Utils.measureText(w[i],fontStr);
var tHTMLChar=words[i]=new HTMLChar(w[i],size.width,size.height||style.fontSize,style);
if (this.href){
var tSprite=new Sprite();
this.addChild(tSprite);
tHTMLChar.setSprite(tSprite);
}
}
return words;
}