fix character size measurement

This commit is contained in:
Fabian Jakobs 2010-12-15 15:41:08 +01:00
commit 633293ee5e

View file

@ -92,6 +92,7 @@ var Text = function(parentEl) {
},
this.$measureSizes = function() {
var n = 1000;
if (!this.$measureNode) {
var measureNode = this.$measureNode = document.createElement("div");
var style = measureNode.style;
@ -107,12 +108,11 @@ 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!
var n = 1000;
measureNode.innerHTML = lang.stringRepeat("Xy", n);
document.body.insertBefore(measureNode, document.body.firstChild);
}
var style = this.$measureNode;
var style = this.$measureNode.style;
for (var prop in this.$fontStyles) {
var value = dom.computedStyle(this.element, prop);
style[prop] = value;
@ -122,7 +122,6 @@ var Text = function(parentEl) {
height: this.$measureNode.offsetHeight,
width: this.$measureNode.offsetWidth / (n * 2)
};
return size;
};