mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Debugger] Add some info about substitution font
When pdfBug is true, the substitution font is used in the text layer in order to be able to know what is the font really used thanks to the devtools. And to be sure that fonts are loaded, the font cache isn't cleaned up when the debugger is active.
This commit is contained in:
parent
b4cd8ad215
commit
7851c0da8d
5 changed files with 41 additions and 18 deletions
|
@ -1816,7 +1816,9 @@ const PDFViewerApplication = {
|
|||
this.pdfViewer.cleanup();
|
||||
this.pdfThumbnailViewer?.cleanup();
|
||||
|
||||
this.pdfDocument.cleanup();
|
||||
this.pdfDocument.cleanup(
|
||||
/* keepLoadedFonts = */ AppOptions.get("fontExtraProperties")
|
||||
);
|
||||
},
|
||||
|
||||
forceRendering() {
|
||||
|
|
|
@ -111,21 +111,29 @@ const FontInspector = (function FontInspectorClosure() {
|
|||
}
|
||||
return moreInfo;
|
||||
}
|
||||
const moreInfo = properties(fontObj, ["name", "type"]);
|
||||
|
||||
const moreInfo = fontObj.css
|
||||
? properties(fontObj, ["baseFontName"])
|
||||
: properties(fontObj, ["name", "type"]);
|
||||
|
||||
const fontName = fontObj.loadedName;
|
||||
const font = document.createElement("div");
|
||||
const name = document.createElement("span");
|
||||
name.textContent = fontName;
|
||||
const download = document.createElement("a");
|
||||
if (url) {
|
||||
url = /url\(['"]?([^)"']+)/.exec(url);
|
||||
download.href = url[1];
|
||||
} else if (fontObj.data) {
|
||||
download.href = URL.createObjectURL(
|
||||
new Blob([fontObj.data], { type: fontObj.mimetype })
|
||||
);
|
||||
let download;
|
||||
if (!fontObj.css) {
|
||||
download = document.createElement("a");
|
||||
if (url) {
|
||||
url = /url\(['"]?([^)"']+)/.exec(url);
|
||||
download.href = url[1];
|
||||
} else if (fontObj.data) {
|
||||
download.href = URL.createObjectURL(
|
||||
new Blob([fontObj.data], { type: fontObj.mimetype })
|
||||
);
|
||||
}
|
||||
download.textContent = "Download";
|
||||
}
|
||||
download.textContent = "Download";
|
||||
|
||||
const logIt = document.createElement("a");
|
||||
logIt.href = "";
|
||||
logIt.textContent = "Log";
|
||||
|
@ -139,7 +147,11 @@ const FontInspector = (function FontInspectorClosure() {
|
|||
select.addEventListener("click", function () {
|
||||
selectFont(fontName, select.checked);
|
||||
});
|
||||
font.append(select, name, " ", download, " ", logIt, moreInfo);
|
||||
if (download) {
|
||||
font.append(select, name, " ", download, " ", logIt, moreInfo);
|
||||
} else {
|
||||
font.append(select, name, " ", logIt, moreInfo);
|
||||
}
|
||||
fonts.append(font);
|
||||
// Somewhat of a hack, should probably add a hook for when the text layer
|
||||
// is done rendering.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue