we need more precision when measuring the character width

fixes https://github.com/ajaxorg/editor/issues/issue/8
This commit is contained in:
Fabian Jakobs 2010-12-15 12:35:17 +01:00
commit 9fad3c4eb8

View file

@ -79,7 +79,7 @@ var Text = function(parentEl) {
self.$characterSize = size;
self._dispatchEvent("changeCharaterSize", {data: size});
}
}, 500);
}, 1000);
};
this.$fontStyles = {
@ -108,12 +108,12 @@ var Text = function(parentEl) {
// in FF 3.6 monospace fonts can have a fixed sub pixel width.
// that's why we have to measure many characters
// Note: characterWidth can be a float!
measureNode.innerHTML = new Array(1000).join("Xy");
measureNode.innerHTML = new Array(10000).join("Xy");
document.body.insertBefore(measureNode, document.body.firstChild);
var size = {
height: measureNode.offsetHeight,
width: measureNode.offsetWidth / 2000
width: measureNode.offsetWidth / 20000
};
document.body.removeChild(measureNode);