we need more precision when measuring the character width
fixes https://github.com/ajaxorg/editor/issues/issue/8
This commit is contained in:
parent
19eecaaefc
commit
9fad3c4eb8
1 changed files with 3 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ var Text = function(parentEl) {
|
||||||
self.$characterSize = size;
|
self.$characterSize = size;
|
||||||
self._dispatchEvent("changeCharaterSize", {data: size});
|
self._dispatchEvent("changeCharaterSize", {data: size});
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$fontStyles = {
|
this.$fontStyles = {
|
||||||
|
|
@ -108,12 +108,12 @@ var Text = function(parentEl) {
|
||||||
// in FF 3.6 monospace fonts can have a fixed sub pixel width.
|
// in FF 3.6 monospace fonts can have a fixed sub pixel width.
|
||||||
// that's why we have to measure many characters
|
// that's why we have to measure many characters
|
||||||
// Note: characterWidth can be a float!
|
// 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);
|
document.body.insertBefore(measureNode, document.body.firstChild);
|
||||||
|
|
||||||
var size = {
|
var size = {
|
||||||
height: measureNode.offsetHeight,
|
height: measureNode.offsetHeight,
|
||||||
width: measureNode.offsetWidth / 2000
|
width: measureNode.offsetWidth / 20000
|
||||||
};
|
};
|
||||||
|
|
||||||
document.body.removeChild(measureNode);
|
document.body.removeChild(measureNode);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue