Compare commits

...

6 Commits

Author SHA1 Message Date
Tim van der Meij
11e89b74d9
Merge pull request #19696 from Snuffleupagus/issue-19695
Extend `getSupplementalGlyphMapForCalibri` with Pound-sign (issue 19695)
2025-03-22 13:21:07 +01:00
Tim van der Meij
9023395550
Merge pull request #19681 from Snuffleupagus/AbortSignal-any-basic-polyfill
[api-minor] Add a basic `AbortSignal.any` polyfill in PDF.js `legacy` builds
2025-03-22 13:20:18 +01:00
Tim van der Meij
7f70835830
Merge pull request #19703 from Snuffleupagus/bidi-rm-setValues
Replace the `setValues` function with `Array.prototype.fill()` in the `src/core/bidi.js` file
2025-03-22 13:13:42 +01:00
Jonas Jenwald
fe19d9666f Replace the setValues function with Array.prototype.fill() in the src/core/bidi.js file
This code is originally from 2012, see PR 1218, and the Array-method wasn't available until Firefox 31 (released on 2014-07-22).
2025-03-21 23:00:38 +01:00
Jonas Jenwald
f90732e4c3 Extend getSupplementalGlyphMapForCalibri with Pound-sign (issue 19695) 2025-03-20 20:12:24 +01:00
Jonas Jenwald
028e4f7ea8 [api-minor] Add a basic AbortSignal.any polyfill in PDF.js legacy builds
This is an admittedly very basic polyfill, to allow us to remove a bunch of inline feature testing, that I've thrown together based on reading https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static and related MDN articles.

Compared to PR 19218 it's obviously much more "primitive", however the implementation is simple and it doesn't suffer from any licensing issues (since I wrote the code myself).
2025-03-18 10:54:49 +01:00
8 changed files with 154 additions and 37 deletions

View File

@ -91,12 +91,6 @@ function findUnequal(arr, start, value) {
return j;
}
function setValues(arr, start, end, value) {
for (let j = start; j < end; ++j) {
arr[j] = value;
}
}
function reverseValues(arr, start, end) {
for (let i = start, j = end - 1; i < j; ++i, --j) {
const temp = arr[i];
@ -323,7 +317,7 @@ function bidi(str, startLevel = -1, vertical = false) {
after = "R";
}
if (before === after) {
setValues(types, i, end, before);
types.fill(before, i, end);
}
i = end - 1; // reset to end (-1 so next iteration is ok)
}

View File

@ -906,6 +906,7 @@ const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) {
t[896] = 91;
t[897] = 93;
t[923] = 64;
t[940] = 163;
t[1004] = 48;
t[1005] = 49;
t[1006] = 50;

View File

@ -1172,6 +1172,37 @@ if (
};
}
if (
typeof PDFJSDev !== "undefined" &&
!PDFJSDev.test("SKIP_BABEL") &&
typeof AbortSignal.any !== "function"
) {
AbortSignal.any = function (iterable) {
const ac = new AbortController();
const { signal } = ac;
// Return immediately if any of the signals are already aborted.
for (const s of iterable) {
if (s.aborted) {
ac.abort(s.reason);
return signal;
}
}
// Register "abort" listeners for all signals.
for (const s of iterable) {
s.addEventListener(
"abort",
() => {
ac.abort(s.reason);
},
{ signal } // Automatically remove the listener.
);
}
return signal;
};
}
export {
_isValidExplicitDest,
AbortException,

View File

@ -260,6 +260,7 @@
!bug860632.pdf
!bug894572.pdf
!bug911034.pdf
!issue19695.pdf
!bug1108301.pdf
!issue10301.pdf
!bug1157493.pdf

102
test/pdfs/issue19695.pdf Normal file
View File

@ -0,0 +1,102 @@
%PDF-1.7
34 0 obj
<<
/Type /Catalog
/Pages 35 0 R
>>
endobj
35 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 50 ]
/Count 1
/Kids [ 36 0 R ]
>>
endobj
36 0 obj
<<
/Type /Page
/Parent 35 0 R
/Resources <<
/Font <<
/F1 37 0 R
>>
>>
/Contents 38 0 R
>>
endobj
37 0 obj
<<
/BaseFont /Calibri
/DescendantFonts [ 12 0 R ]
/Encoding /Identity-H
/Subtype /Type0
/Type /Font
>>
endobj
38 0 obj
<<
/Length 54
>>
stream
BT
10 20 TD
/F1 20 Tf
<03AC03ED03F0035803EC03EC>Tj
ET
endstream
endobj
12 0 obj
<<
/BaseFont /Calibri
/CIDSystemInfo <<
/Ordering (Identity)
/Registry (Adobe)
/Supplement 0
>>
/FontDescriptor 13 0 R
/Subtype /CIDFontType2
/Type /Font
/W [ 3 [ 226.074 ] 47 [ 251.953 ] 87 [ 516.602 ] 258 [ 479.004 ] 288 [ 497.559 ] 349 [ 229.492 ] 374 [ 525.391 ] 396 [ 348.633 ] 400 [ 391.113 ] 853 [ 249.512 ] 856 [ 252.441 ] 859 [ 249.512 ] 940 [ 506.836 ] 1004 [ 506.836 ] 1005 [ 506.836 ] 1007 [ 506.836 ] 1008 [ 506.836 ] 1009 [ 506.836 ] 1010 [ 506.836 ] 1011 [ 506.836 ] 1012 [ 506.836 ] 1013 [ 506.836 ] 1085 [ 498.047 ] 3423 [ 500 ] ]
>>
endobj
13 0 obj
<<
/Ascent 750
/CapHeight 0
/Descent -250
/Flags 32
/FontBBox [ -503 -312 1240 1026 ]
/FontName /Calibri
/ItalicAngle 0
/StemV 0
/Type /FontDescriptor
>>
endobj
xref
0 1
0000000000 65535 f
12 1
0000000477 00000 n
13 1
0000001044 00000 n
34 1
0000000009 00000 n
35 1
0000000060 00000 n
36 1
0000000146 00000 n
37 1
0000000252 00000 n
38 1
0000000371 00000 n
trailer
<<
/Size 7
/Root 34 0 R
>>
startxref
1214
%%EOF

View File

@ -706,6 +706,13 @@
"rounds": 1,
"type": "load"
},
{
"id": "issue19695",
"file": "pdfs/issue19695.pdf",
"md5": "963474b8847afc9eeda4ff4635f7a523",
"rounds": 1,
"type": "eq"
},
{
"id": "openofficearabiccidtruetype-pdf",
"file": "pdfs/arial_unicode_ab_cidfont.pdf",

View File

@ -559,11 +559,7 @@ const PDFViewerApplication = {
}
if (appConfig.annotationEditorParams) {
if (
((typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
typeof AbortSignal.any === "function") &&
annotationEditorMode !== AnnotationEditorType.DISABLE
) {
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
const editorSignatureButton = appConfig.toolbar?.editorSignatureButton;
if (editorSignatureButton && AppOptions.get("enableSignatureEditor")) {
editorSignatureButton.parentElement.hidden = false;
@ -2075,19 +2071,14 @@ const PDFViewerApplication = {
_windowAbortController: { signal },
} = this;
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
typeof AbortSignal.any === "function"
) {
this._touchManager = new TouchManager({
container: window,
isPinchingDisabled: () => pdfViewer.isInPresentationMode,
isPinchingStopped: () => this.overlayManager?.active,
onPinching: this.touchPinchCallback.bind(this),
onPinchEnd: this.touchPinchEndCallback.bind(this),
signal,
});
}
this._touchManager = new TouchManager({
container: window,
isPinchingDisabled: () => pdfViewer.isInPresentationMode,
isPinchingStopped: () => this.overlayManager?.active,
onPinching: this.touchPinchCallback.bind(this),
onPinchEnd: this.touchPinchEndCallback.bind(this),
signal,
});
function addWindowResolutionChange(evt = null) {
if (evt) {

View File

@ -711,13 +711,7 @@ class PDFViewer {
hiddenCapability.resolve();
}
},
{
signal:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
typeof AbortSignal.any === "function"
? AbortSignal.any([signal, ac.signal])
: signal,
}
{ signal: AbortSignal.any([signal, ac.signal]) }
);
await Promise.race([
@ -914,11 +908,7 @@ class PDFViewer {
viewer.before(element);
}
if (
((typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
typeof AbortSignal.any === "function") &&
annotationEditorMode !== AnnotationEditorType.DISABLE
) {
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
const mode = annotationEditorMode;
if (pdfDocument.isPureXfa) {