mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-25 01:25:51 +02:00
Compare commits
No commits in common. "50c573d16d2dbd8c2bdb3bd4c6f5e85f46602c79" and "da17c7b82f5146cdcceb231e8f3e8b81e04085b7" have entirely different histories.
50c573d16d
...
da17c7b82f
@ -1177,7 +1177,9 @@ class Catalog {
|
||||
this.pageDictCache.clear();
|
||||
this.nonBlendModesSet.clear();
|
||||
|
||||
for (const { dict } of await Promise.all(this.fontCache)) {
|
||||
const translatedFonts = await Promise.all(this.fontCache);
|
||||
|
||||
for (const { dict } of translatedFonts) {
|
||||
delete dict.cacheKey;
|
||||
}
|
||||
this.fontCache.clear();
|
||||
|
||||
@ -1046,19 +1046,27 @@ class PartialEvaluator {
|
||||
) {
|
||||
const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null;
|
||||
|
||||
const translated = await this.loadFont(
|
||||
let translated = await this.loadFont(
|
||||
fontName,
|
||||
fontRef,
|
||||
resources,
|
||||
task,
|
||||
fallbackFontDict,
|
||||
cssFontInfo
|
||||
);
|
||||
|
||||
if (translated.font.isType3Font) {
|
||||
// Add the dependencies to the parent operatorList so they are
|
||||
// resolved before Type3 operatorLists are executed synchronously.
|
||||
operatorList.addDependencies(translated.type3Dependencies);
|
||||
try {
|
||||
await translated.loadType3Data(this, resources, task);
|
||||
// Add the dependencies to the parent operatorList so they are
|
||||
// resolved before Type3 operatorLists are executed synchronously.
|
||||
operatorList.addDependencies(translated.type3Dependencies);
|
||||
} catch (reason) {
|
||||
translated = new TranslatedFont({
|
||||
loadedName: "g_font_error",
|
||||
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
||||
dict: translated.font,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
state.font = translated.font;
|
||||
@ -1220,7 +1228,6 @@ class PartialEvaluator {
|
||||
fontName,
|
||||
font,
|
||||
resources,
|
||||
task,
|
||||
fallbackFontDict = null,
|
||||
cssFontInfo = null
|
||||
) {
|
||||
@ -1349,21 +1356,14 @@ class PartialEvaluator {
|
||||
font.loadedName = `${this.idFactory.getDocId()}_${fontID}`;
|
||||
|
||||
this.translateFont(preEvaluatedFont)
|
||||
.then(async translatedFont => {
|
||||
const translated = new TranslatedFont({
|
||||
loadedName: font.loadedName,
|
||||
font: translatedFont,
|
||||
dict: font,
|
||||
});
|
||||
|
||||
if (translatedFont.isType3Font) {
|
||||
try {
|
||||
await translated.loadType3Data(this, resources, task);
|
||||
} catch (reason) {
|
||||
throw new Error(`Type3 font load error: ${reason}`);
|
||||
}
|
||||
}
|
||||
resolve(translated);
|
||||
.then(translatedFont => {
|
||||
resolve(
|
||||
new TranslatedFont({
|
||||
loadedName: font.loadedName,
|
||||
font: translatedFont,
|
||||
dict: font,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch(reason => {
|
||||
// TODO reject?
|
||||
@ -1372,7 +1372,9 @@ class PartialEvaluator {
|
||||
resolve(
|
||||
new TranslatedFont({
|
||||
loadedName: font.loadedName,
|
||||
font: new ErrorFont(reason?.message),
|
||||
font: new ErrorFont(
|
||||
reason instanceof Error ? reason.message : reason
|
||||
),
|
||||
dict: font,
|
||||
})
|
||||
);
|
||||
@ -2614,12 +2616,16 @@ class PartialEvaluator {
|
||||
}
|
||||
|
||||
async function handleSetFont(fontName, fontRef) {
|
||||
const translated = await self.loadFont(
|
||||
fontName,
|
||||
fontRef,
|
||||
resources,
|
||||
task
|
||||
);
|
||||
const translated = await self.loadFont(fontName, fontRef, resources);
|
||||
|
||||
if (translated.font.isType3Font) {
|
||||
try {
|
||||
await translated.loadType3Data(self, resources, task);
|
||||
} catch {
|
||||
// Ignore Type3-parsing errors, since we only use `loadType3Data`
|
||||
// here to ensure that we'll always obtain a useful /FontBBox.
|
||||
}
|
||||
}
|
||||
|
||||
textState.loadedName = translated.loadedName;
|
||||
textState.font = translated.font;
|
||||
@ -4596,22 +4602,20 @@ class PartialEvaluator {
|
||||
}
|
||||
|
||||
class TranslatedFont {
|
||||
#sent = false;
|
||||
|
||||
#type3Loaded = null;
|
||||
|
||||
constructor({ loadedName, font, dict }) {
|
||||
this.loadedName = loadedName;
|
||||
this.font = font;
|
||||
this.dict = dict;
|
||||
this.type3Loaded = null;
|
||||
this.type3Dependencies = font.isType3Font ? new Set() : null;
|
||||
this.sent = false;
|
||||
}
|
||||
|
||||
send(handler) {
|
||||
if (this.#sent) {
|
||||
if (this.sent) {
|
||||
return;
|
||||
}
|
||||
this.#sent = true;
|
||||
this.sent = true;
|
||||
|
||||
handler.send("commonobj", [
|
||||
this.loadedName,
|
||||
@ -4641,12 +4645,12 @@ class TranslatedFont {
|
||||
}
|
||||
|
||||
loadType3Data(evaluator, resources, task) {
|
||||
if (this.#type3Loaded) {
|
||||
return this.#type3Loaded;
|
||||
if (this.type3Loaded) {
|
||||
return this.type3Loaded;
|
||||
}
|
||||
if (!this.font.isType3Font) {
|
||||
throw new Error("Must be a Type3 font.");
|
||||
}
|
||||
const { font, type3Dependencies } = this;
|
||||
assert(font.isType3Font, "Must be a Type3 font.");
|
||||
|
||||
// When parsing Type3 glyphs, always ignore them if there are errors.
|
||||
// Compared to the parsing of e.g. an entire page, it doesn't really
|
||||
// make sense to only be able to render a Type3 glyph partially.
|
||||
@ -4658,12 +4662,14 @@ class TranslatedFont {
|
||||
}
|
||||
type3Evaluator.type3FontRefs = type3FontRefs;
|
||||
|
||||
const translatedFont = this.font,
|
||||
type3Dependencies = this.type3Dependencies;
|
||||
let loadCharProcsPromise = Promise.resolve();
|
||||
const charProcs = this.dict.get("CharProcs");
|
||||
const fontResources = this.dict.get("Resources") || resources;
|
||||
const charProcOperatorList = Object.create(null);
|
||||
|
||||
const fontBBox = Util.normalizeRect(font.bbox || [0, 0, 0, 0]),
|
||||
const fontBBox = Util.normalizeRect(translatedFont.bbox || [0, 0, 0, 0]),
|
||||
width = fontBBox[2] - fontBBox[0],
|
||||
height = fontBBox[3] - fontBBox[1];
|
||||
const fontBBoxSize = Math.hypot(width, height);
|
||||
@ -4687,7 +4693,7 @@ class TranslatedFont {
|
||||
// colour-related parameters) in the graphics state;
|
||||
// any use of such operators shall be ignored."
|
||||
if (operatorList.fnArray[0] === OPS.setCharWidthAndBounds) {
|
||||
this.#removeType3ColorOperators(operatorList, fontBBoxSize);
|
||||
this._removeType3ColorOperators(operatorList, fontBBoxSize);
|
||||
}
|
||||
charProcOperatorList[key] = operatorList.getIR();
|
||||
|
||||
@ -4702,17 +4708,20 @@ class TranslatedFont {
|
||||
});
|
||||
});
|
||||
}
|
||||
this.#type3Loaded = loadCharProcsPromise.then(() => {
|
||||
font.charProcOperatorList = charProcOperatorList;
|
||||
this.type3Loaded = loadCharProcsPromise.then(() => {
|
||||
translatedFont.charProcOperatorList = charProcOperatorList;
|
||||
if (this._bbox) {
|
||||
font.isCharBBox = true;
|
||||
font.bbox = this._bbox;
|
||||
translatedFont.isCharBBox = true;
|
||||
translatedFont.bbox = this._bbox;
|
||||
}
|
||||
});
|
||||
return this.#type3Loaded;
|
||||
return this.type3Loaded;
|
||||
}
|
||||
|
||||
#removeType3ColorOperators(operatorList, fontBBoxSize = NaN) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_removeType3ColorOperators(operatorList, fontBBoxSize = NaN) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
assert(
|
||||
operatorList.fnArray[0] === OPS.setCharWidthAndBounds,
|
||||
|
||||
@ -82,6 +82,7 @@ const EXPORT_DATA_PROPERTIES = [
|
||||
"black",
|
||||
"bold",
|
||||
"charProcOperatorList",
|
||||
"composite",
|
||||
"cssFontInfo",
|
||||
"data",
|
||||
"defaultVMetrics",
|
||||
@ -99,23 +100,22 @@ const EXPORT_DATA_PROPERTIES = [
|
||||
"missingFile",
|
||||
"name",
|
||||
"remeasure",
|
||||
"subtype",
|
||||
"systemFontInfo",
|
||||
"type",
|
||||
"vertical",
|
||||
];
|
||||
|
||||
const EXPORT_DATA_EXTRA_PROPERTIES = [
|
||||
"cMap",
|
||||
"composite",
|
||||
"defaultEncoding",
|
||||
"differences",
|
||||
"isMonospace",
|
||||
"isSerifFont",
|
||||
"isSymbolicFont",
|
||||
"seacMap",
|
||||
"subtype",
|
||||
"toFontChar",
|
||||
"toUnicode",
|
||||
"type",
|
||||
"vmetrics",
|
||||
"widths",
|
||||
];
|
||||
|
||||
@ -543,37 +543,6 @@ const getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
|
||||
t[337] = 9552;
|
||||
t[493] = 1039;
|
||||
t[494] = 1040;
|
||||
t[570] = 1040;
|
||||
t[571] = 1041;
|
||||
t[572] = 1042;
|
||||
t[573] = 1043;
|
||||
t[574] = 1044;
|
||||
t[575] = 1045;
|
||||
t[576] = 1046;
|
||||
t[577] = 1047;
|
||||
t[578] = 1048;
|
||||
t[579] = 1049;
|
||||
t[580] = 1050;
|
||||
t[581] = 1051;
|
||||
t[582] = 1052;
|
||||
t[583] = 1053;
|
||||
t[584] = 1054;
|
||||
t[585] = 1055;
|
||||
t[586] = 1056;
|
||||
t[587] = 1057;
|
||||
t[588] = 1058;
|
||||
t[589] = 1059;
|
||||
t[590] = 1060;
|
||||
t[591] = 1061;
|
||||
t[592] = 1062;
|
||||
t[593] = 1063;
|
||||
t[594] = 1064;
|
||||
t[595] = 1065;
|
||||
t[596] = 1066;
|
||||
t[597] = 1067;
|
||||
t[598] = 1068;
|
||||
t[599] = 1069;
|
||||
t[600] = 1070;
|
||||
t[672] = 1488;
|
||||
t[673] = 1489;
|
||||
t[674] = 1490;
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -661,7 +661,6 @@
|
||||
!bug1868759.pdf
|
||||
!issue17730.pdf
|
||||
!bug1883609.pdf
|
||||
!issue19550.pdf
|
||||
!issue17808.pdf
|
||||
!issue17871_bottom_right.pdf
|
||||
!issue17871_top_right.pdf
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -3906,13 +3906,6 @@
|
||||
"7R": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "issue19550",
|
||||
"file": "pdfs/issue19550.pdf",
|
||||
"md5": "4c978bd99348789e05dad1d2a919ddf0",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue1127-text",
|
||||
"file": "pdfs/issue1127.pdf",
|
||||
|
||||
23
web/app.js
23
web/app.js
@ -380,8 +380,7 @@ const PDFViewerApplication = {
|
||||
* @private
|
||||
*/
|
||||
async _initializeViewerComponents() {
|
||||
const { appConfig, externalServices, l10n, mlManager } = this;
|
||||
const abortSignal = this._globalAbortController.signal;
|
||||
const { appConfig, externalServices, l10n } = this;
|
||||
|
||||
const eventBus =
|
||||
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
|
||||
@ -392,7 +391,7 @@ const PDFViewerApplication = {
|
||||
)
|
||||
: new EventBus();
|
||||
this.eventBus = AppOptions.eventBus = eventBus;
|
||||
mlManager?.setEventBus(eventBus, abortSignal);
|
||||
this.mlManager?.setEventBus(eventBus, this._globalAbortController.signal);
|
||||
|
||||
this.overlayManager = new OverlayManager();
|
||||
|
||||
@ -471,7 +470,10 @@ const PDFViewerApplication = {
|
||||
null,
|
||||
this.overlayManager,
|
||||
l10n,
|
||||
externalServices.createSignatureStorage(eventBus, abortSignal),
|
||||
externalServices.createSignatureStorage(
|
||||
eventBus,
|
||||
this._globalAbortController.signal
|
||||
),
|
||||
eventBus
|
||||
)
|
||||
: null;
|
||||
@ -508,8 +510,8 @@ const PDFViewerApplication = {
|
||||
enableDetailCanvas: AppOptions.get("enableDetailCanvas"),
|
||||
enablePermissions: AppOptions.get("enablePermissions"),
|
||||
pageColors,
|
||||
mlManager,
|
||||
abortSignal,
|
||||
mlManager: this.mlManager,
|
||||
abortSignal: this._globalAbortController.signal,
|
||||
enableHWA,
|
||||
supportsPinchToZoom: this.supportsPinchToZoom,
|
||||
enableAutoLinking: AppOptions.get("enableAutoLinking"),
|
||||
@ -527,7 +529,7 @@ const PDFViewerApplication = {
|
||||
renderingQueue: pdfRenderingQueue,
|
||||
linkService: pdfLinkService,
|
||||
pageColors,
|
||||
abortSignal,
|
||||
abortSignal: this._globalAbortController.signal,
|
||||
enableHWA,
|
||||
});
|
||||
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
||||
@ -572,12 +574,15 @@ const PDFViewerApplication = {
|
||||
}
|
||||
}
|
||||
|
||||
if (mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) {
|
||||
if (
|
||||
this.mlManager &&
|
||||
appConfig.secondaryToolbar?.imageAltTextSettingsButton
|
||||
) {
|
||||
this.imageAltTextSettings = new ImageAltTextSettings(
|
||||
appConfig.altTextSettingsDialog,
|
||||
this.overlayManager,
|
||||
eventBus,
|
||||
mlManager
|
||||
this.mlManager
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1173,7 +1173,6 @@ class PDFViewer {
|
||||
this.#hiddenCopyElement?.remove();
|
||||
this.#hiddenCopyElement = null;
|
||||
|
||||
this.#cleanupTimeouts();
|
||||
this.#cleanupSwitchAnnotationEditorMode();
|
||||
}
|
||||
|
||||
@ -2341,17 +2340,6 @@ class PDFViewer {
|
||||
]);
|
||||
}
|
||||
|
||||
#cleanupTimeouts() {
|
||||
if (this.#scaleTimeoutId !== null) {
|
||||
clearTimeout(this.#scaleTimeoutId);
|
||||
this.#scaleTimeoutId = null;
|
||||
}
|
||||
if (this.#scrollTimeoutId !== null) {
|
||||
clearTimeout(this.#scrollTimeoutId);
|
||||
this.#scrollTimeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
#cleanupSwitchAnnotationEditorMode() {
|
||||
this.#switchAnnotationEditorModeAC?.abort();
|
||||
this.#switchAnnotationEditorModeAC = null;
|
||||
@ -2478,8 +2466,14 @@ class PDFViewer {
|
||||
for (const pageView of this._pages) {
|
||||
pageView.update(updateArgs);
|
||||
}
|
||||
this.#cleanupTimeouts();
|
||||
|
||||
if (this.#scaleTimeoutId !== null) {
|
||||
clearTimeout(this.#scaleTimeoutId);
|
||||
this.#scaleTimeoutId = null;
|
||||
}
|
||||
if (this.#scrollTimeoutId !== null) {
|
||||
clearTimeout(this.#scrollTimeoutId);
|
||||
this.#scrollTimeoutId = null;
|
||||
}
|
||||
if (!noUpdate) {
|
||||
this.update();
|
||||
}
|
||||
|
||||
@ -177,7 +177,6 @@ class SignatureManager {
|
||||
"click",
|
||||
() => {
|
||||
this.#reportTelemetry({
|
||||
type: "signature",
|
||||
action: "pdfjs.signature.clear",
|
||||
data: {
|
||||
type: this.#currentTab,
|
||||
@ -739,7 +738,6 @@ class SignatureManager {
|
||||
if (await this.#signatureStorage.delete(uuid)) {
|
||||
div.remove();
|
||||
this.#reportTelemetry({
|
||||
type: "signature",
|
||||
action: "pdfjs.signature.delete_saved",
|
||||
data: {
|
||||
savedCount: await this.#signatureStorage.size(),
|
||||
@ -926,7 +924,6 @@ class SignatureManager {
|
||||
|
||||
const altText = this.#tabsToAltText.get(type);
|
||||
this.#reportTelemetry({
|
||||
type: "signature",
|
||||
action: "pdfjs.signature.created",
|
||||
data: {
|
||||
type,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user