Add more info for showText operator in stepper.

Adds a table that shows original char code, font char code, and unicode.
This commit is contained in:
Brendan Dahl 2021-06-04 09:48:30 -07:00
parent 9165dc0659
commit 17f1857556
3 changed files with 43 additions and 13 deletions

View File

@ -159,6 +159,7 @@ function adjustToUnicode(properties, builtInEncoding) {
class Glyph { class Glyph {
constructor( constructor(
originalCharCode,
fontChar, fontChar,
unicode, unicode,
accent, accent,
@ -168,6 +169,7 @@ class Glyph {
isSpace, isSpace,
isInFont isInFont
) { ) {
this.originalCharCode = originalCharCode;
this.fontChar = fontChar; this.fontChar = fontChar;
this.unicode = unicode; this.unicode = unicode;
this.accent = accent; this.accent = accent;
@ -179,6 +181,7 @@ class Glyph {
} }
matchesForCache( matchesForCache(
originalCharCode,
fontChar, fontChar,
unicode, unicode,
accent, accent,
@ -189,6 +192,7 @@ class Glyph {
isInFont isInFont
) { ) {
return ( return (
this.originalCharCode === originalCharCode &&
this.fontChar === fontChar && this.fontChar === fontChar &&
this.unicode === unicode && this.unicode === unicode &&
this.accent === accent && this.accent === accent &&
@ -2956,6 +2960,7 @@ class Font {
if ( if (
!glyph || !glyph ||
!glyph.matchesForCache( !glyph.matchesForCache(
charcode,
fontChar, fontChar,
unicode, unicode,
accent, accent,
@ -2967,6 +2972,7 @@ class Font {
) )
) { ) {
glyph = new Glyph( glyph = new Glyph(
charcode,
fontChar, fontChar,
unicode, unicode,
accent, accent,

View File

@ -357,28 +357,39 @@ const Stepper = (function StepperClosure() {
let decArgs = args; let decArgs = args;
if (fn === "showText") { if (fn === "showText") {
const glyphs = args[0]; const glyphs = args[0];
const newArgs = []; const charCodeRow = c("tr");
let str = []; const fontCharRow = c("tr");
const unicodeRow = c("tr");
for (let j = 0; j < glyphs.length; j++) { for (let j = 0; j < glyphs.length; j++) {
const glyph = glyphs[j]; const glyph = glyphs[j];
if (typeof glyph === "object" && glyph !== null) { if (typeof glyph === "object" && glyph !== null) {
str.push(glyph.fontChar); charCodeRow.appendChild(c("td", glyph.originalCharCode));
fontCharRow.appendChild(c("td", glyph.fontChar));
unicodeRow.appendChild(c("td", glyph.unicode));
} else { } else {
if (str.length > 0) { // null or number
newArgs.push(str.join("")); const advanceEl = c("td", glyph);
str = []; advanceEl.classList.add("advance");
} charCodeRow.appendChild(advanceEl);
newArgs.push(glyph); // null or number fontCharRow.appendChild(c("td"));
unicodeRow.appendChild(c("td"));
} }
} }
if (str.length > 0) { decArgs = c("td");
newArgs.push(str.join("")); const table = c("table");
} table.classList.add("showText");
decArgs = [newArgs]; decArgs.appendChild(table);
table.appendChild(charCodeRow);
table.appendChild(fontCharRow);
table.appendChild(unicodeRow);
} }
line.appendChild(c("td", fn)); line.appendChild(c("td", fn));
if (decArgs instanceof HTMLElement) {
line.appendChild(decArgs);
} else {
line.appendChild(c("td", JSON.stringify(simplifyArgs(decArgs)))); line.appendChild(c("td", JSON.stringify(simplifyArgs(decArgs))));
} }
}
if (operatorsToDisplay < operatorList.fnArray.length) { if (operatorsToDisplay < operatorList.fnArray.length) {
const lastCell = c("td", "..."); const lastCell = c("td", "...");
lastCell.colspan = 4; lastCell.colspan = 4;

View File

@ -1699,6 +1699,19 @@ html[dir="rtl"] #documentPropertiesOverlay .row > * {
#PDFBug table { #PDFBug table {
font-size: 10px; font-size: 10px;
} }
#PDFBug table.showText {
border-collapse: collapse;
text-align: center;
}
#PDFBug table.showText,
#PDFBug table.showText tr,
#PDFBug table.showText td {
border: 1px solid black;
padding: 1px;
}
#PDFBug table.showText td.advance {
color: grey;
}
#viewer.textLayer-visible .textLayer { #viewer.textLayer-visible .textLayer {
opacity: 1; opacity: 1;