Amend width calculation for wide characters

This commit is contained in:
hhclaw.eb@gmail.com
2013-09-06 20:00:08 +08:00
parent 36eb0ecd94
commit 2c163ae2c2
+7 -1
View File
@@ -70,6 +70,7 @@ iD.svg.Labels = function(projection, context) {
function textWidth(text, size, elem) {
var c = textWidthCache[size];
var str;
if (!c) c = textWidthCache[size] = {};
if (c[text]) {
@@ -80,7 +81,12 @@ iD.svg.Labels = function(projection, context) {
return c[text];
} else {
return size / 3 * 2 * text.length;
str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
if (str == null) {
return size / 3 * 2 * text.length;
} else {
return size / 3 * ( 2 * text.length + str.length);
}
}
}