Fix the font inspector.
This commit is contained in:
parent
c04ab5fe45
commit
45e3db77f2
@ -7,31 +7,26 @@ var FontInspector = (function FontInspectorClosure() {
|
|||||||
var fonts;
|
var fonts;
|
||||||
var panelWidth = 300;
|
var panelWidth = 300;
|
||||||
var active = false;
|
var active = false;
|
||||||
|
var fontAttribute = 'data-font-name';
|
||||||
function removeSelection() {
|
function removeSelection() {
|
||||||
var divs = document.getElementsByTagName('div');
|
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
|
||||||
for (var i = 0; i < divs.length; ++i) {
|
for (var i = 0; i < divs.length; ++i) {
|
||||||
var div = divs[i], style = div.getAttribute('style');
|
var div = divs[i];
|
||||||
if (!style || style.indexOf('pdfFont') < 0) continue;
|
|
||||||
var m = /(pdfFont\d+)/.exec(style);
|
|
||||||
div.dataset.fontName = '';
|
|
||||||
div.className = '';
|
div.className = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function resetSelection() {
|
function resetSelection() {
|
||||||
var divs = document.getElementsByTagName('div');
|
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
|
||||||
for (var i = 0; i < divs.length; ++i) {
|
for (var i = 0; i < divs.length; ++i) {
|
||||||
var div = divs[i], style = div.getAttribute('style');
|
var div = divs[i];
|
||||||
if (!style || style.indexOf('pdfFont') < 0) continue;
|
|
||||||
var m = /(pdfFont\d+)/.exec(style);
|
|
||||||
div.dataset.fontName = m[1];
|
|
||||||
div.className = 'debuggerHideText';
|
div.className = 'debuggerHideText';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function selectFont(fontName, show) {
|
function selectFont(fontName, show) {
|
||||||
var divs = document.getElementsByTagName('div');
|
var divs = document.querySelectorAll('div[' + fontAttribute + '=' +
|
||||||
|
fontName + ']');
|
||||||
for (var i = 0; i < divs.length; ++i) {
|
for (var i = 0; i < divs.length; ++i) {
|
||||||
var div = divs[i], style = div.getAttribute('style');
|
var div = divs[i];
|
||||||
if (div.dataset.fontName != fontName) continue;
|
|
||||||
div.className = show ? 'debuggerShowText' : 'debuggerHideText';
|
div.className = show ? 'debuggerShowText' : 'debuggerHideText';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +70,7 @@ var FontInspector = (function FontInspectorClosure() {
|
|||||||
document.body.addEventListener('click', textLayerClick, true);
|
document.body.addEventListener('click', textLayerClick, true);
|
||||||
resetSelection();
|
resetSelection();
|
||||||
} else {
|
} else {
|
||||||
document.body.removeEventListener('click', textLayerClick);
|
document.body.removeEventListener('click', textLayerClick, true);
|
||||||
removeSelection();
|
removeSelection();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1085,6 +1085,7 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
|
|||||||
// vScale and hScale already contain the scaling to pixel units
|
// vScale and hScale already contain the scaling to pixel units
|
||||||
var fontHeight = fontSize * text.geom.vScale;
|
var fontHeight = fontSize * text.geom.vScale;
|
||||||
textDiv.dataset.canvasWidth = text.canvasWidth * text.geom.hScale;
|
textDiv.dataset.canvasWidth = text.canvasWidth * text.geom.hScale;
|
||||||
|
textDiv.dataset.fontName = fontName;
|
||||||
|
|
||||||
textDiv.style.fontSize = fontHeight + 'px';
|
textDiv.style.fontSize = fontHeight + 'px';
|
||||||
textDiv.style.left = text.geom.x + 'px';
|
textDiv.style.left = text.geom.x + 'px';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user