Merge pull request #582 from tmyt/propose/row-height

Support checking height in checkBoldBroken
This commit is contained in:
Daniel Imms
2017-03-10 12:53:12 -08:00
committed by GitHub
+10 -8
View File
@@ -34,7 +34,7 @@ export class Renderer {
// Figure out whether boldness affects
// the character width of monospace fonts.
if (brokenBold === null) {
brokenBold = checkBoldBroken((<any>this._terminal).document);
brokenBold = checkBoldBroken((<any>this._terminal).element);
}
// TODO: Pull more DOM interactions into Renderer.constructor, element for
@@ -291,14 +291,16 @@ export class Renderer {
// if bold is broken, we can't
// use it in the terminal.
function checkBoldBroken(document) {
const body = document.getElementsByTagName('body')[0];
function checkBoldBroken(terminal) {
const document = terminal.ownerDocument;
const el = document.createElement('span');
el.innerHTML = 'hello world';
body.appendChild(el);
const w1 = el.scrollWidth;
terminal.appendChild(el);
const w1 = el.offsetWidth;
const h1 = el.offsetHeight;
el.style.fontWeight = 'bold';
const w2 = el.scrollWidth;
body.removeChild(el);
return w1 !== w2;
const w2 = el.offsetWidth;
const h2 = el.offsetHeight;
terminal.removeChild(el);
return w1 !== w2 || h1 !== h2;
}