fix character size measurement
This commit is contained in:
parent
a2d271677f
commit
633293ee5e
1 changed files with 2 additions and 3 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue