|
@@ -133,8 +133,8 @@ class Text extends Drawable {
|
|
|
return text;
|
|
|
var lines = [], rest = text, restPos = 0;
|
|
|
var x = leftMargin, prevChar = -1;
|
|
|
- for( i in 0...text.length ) {
|
|
|
- var cc = text.charCodeAt(i);
|
|
|
+ for( i in 0...haxe.Utf8.length(text) ) {
|
|
|
+ var cc = haxe.Utf8.charCodeAt(text, i);
|
|
|
var e = font.getChar(cc);
|
|
|
var newline = cc == '\n'.code;
|
|
|
var esize = e.width + e.getKerningOffset(prevChar);
|
|
@@ -144,10 +144,10 @@ class Text extends Drawable {
|
|
|
x -= leftMargin;
|
|
|
}
|
|
|
var size = x + esize + letterSpacing;
|
|
|
- var k = i + 1, max = text.length;
|
|
|
+ var k = i + 1, max = haxe.Utf8.length(text);
|
|
|
var prevChar = prevChar;
|
|
|
- while( size <= maxWidth && k < text.length ) {
|
|
|
- var cc = text.charCodeAt(k++);
|
|
|
+ while( size <= maxWidth && k < max ) {
|
|
|
+ var cc = haxe.Utf8.charCodeAt(text, k++);
|
|
|
if( font.charset.isSpace(cc) || cc == '\n'.code ) break;
|
|
|
var e = font.getChar(cc);
|
|
|
size += e.width + letterSpacing + e.getKerningOffset(prevChar);
|
|
@@ -155,7 +155,7 @@ class Text extends Drawable {
|
|
|
}
|
|
|
if( size > maxWidth ) {
|
|
|
newline = true;
|
|
|
- lines.push(text.substr(restPos, i - restPos));
|
|
|
+ lines.push(haxe.Utf8.sub(text,restPos, i - restPos));
|
|
|
restPos = i;
|
|
|
if( font.charset.isSpace(cc) ) {
|
|
|
e = null;
|
|
@@ -171,10 +171,10 @@ class Text extends Drawable {
|
|
|
} else
|
|
|
prevChar = cc;
|
|
|
}
|
|
|
- if( restPos < text.length ) {
|
|
|
+ if( restPos < haxe.Utf8.length(text) ) {
|
|
|
if( lines.length == 0 && leftMargin > 0 && x > maxWidth )
|
|
|
lines.push("");
|
|
|
- lines.push(text.substr(restPos, text.length - restPos));
|
|
|
+ lines.push(haxe.Utf8.sub(text, restPos, haxe.Utf8.length(text) - restPos));
|
|
|
}
|
|
|
return lines.join("\n");
|
|
|
}
|
|
@@ -197,18 +197,18 @@ class Text extends Drawable {
|
|
|
var dl = font.lineHeight + lineSpacing;
|
|
|
var calcLines = !rebuild && lines != null;
|
|
|
var yMin = 0;
|
|
|
- for( i in 0...text.length ) {
|
|
|
- var cc = text.charCodeAt(i);
|
|
|
+ for( i in 0...haxe.Utf8.length(text) ) {
|
|
|
+ var cc = haxe.Utf8.charCodeAt(text,i);
|
|
|
var e = font.getChar(cc);
|
|
|
var newline = cc == '\n'.code;
|
|
|
var esize = e.width + e.getKerningOffset(prevChar);
|
|
|
// if the next word goes past the max width, change it into a newline
|
|
|
if( font.charset.isBreakChar(cc) && maxWidth != null ) {
|
|
|
var size = x + esize + letterSpacing;
|
|
|
- var k = i + 1, max = text.length;
|
|
|
+ var k = i + 1, max = haxe.Utf8.length(text);
|
|
|
var prevChar = prevChar;
|
|
|
- while( size <= maxWidth && k < text.length ) {
|
|
|
- var cc = text.charCodeAt(k++);
|
|
|
+ while( size <= maxWidth && k < max ) {
|
|
|
+ var cc = haxe.Utf8.charCodeAt(text, k++);
|
|
|
if( font.charset.isSpace(cc) || cc == '\n'.code ) break;
|
|
|
var e = font.getChar(cc);
|
|
|
size += e.width + letterSpacing + e.getKerningOffset(prevChar);
|