Fix FF 3.6 issue, where mono spaced characters can

have fixed sub pixel widths.
This commit is contained in:
Fabian Jakobs 2010-04-07 17:40:42 +02:00
commit cc5cd114e6
6 changed files with 17 additions and 15 deletions

View file

@ -30,11 +30,14 @@ TextLayer.prototype._measureSizes = function()
style.position = "absolute";
style.overflow = "visible";
measureNode.innerHTML = "X<br>X";
measureNode.innerHTML = new Array(1000).join("Xy");
this.element.appendChild(measureNode);
this.lineHeight = Math.round(measureNode.offsetHeight / 2);
this.characterWidth = measureNode.offsetWidth;
// 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!
this.lineHeight = measureNode.offsetHeight;
this.characterWidth = measureNode.offsetWidth / 2000;
this.element.removeChild(measureNode);
};