Commit Graph

17250 Commits

Author SHA1 Message Date
Jonas Jenwald
bfb374dbf6 Attempt to fallback to a default font, for non-available ones, in more cases (issue 16432)
This essentially extends PR 11218 to also apply when looking up the final font-reference, via the XRef-table, fails because the font isn't available.

This patch also changes `PartialEvaluator.fallbackFontDict` to simply use "Helvetica" as the default font-name, since that seems generally reasonable given the now existing font-substitution code.
2023-05-17 11:41:08 +02:00
calixteman
5ae353cf4d
Merge pull request #16431 from calixteman/warn_missing_os_font
Warn when pdf.js can't load an OS font
2023-05-16 15:25:16 +02:00
Calixte Denizet
385f275ad9 Warn when pdf.js can't load an OS font 2023-05-16 14:58:38 +02:00
Jonas Jenwald
95ab2b8b17
Merge pull request #16430 from Snuffleupagus/npm-lockfile-version-3
Update `package-lock.json` to lockfileVersion=3
2023-05-16 10:14:00 +02:00
Jonas Jenwald
cc46d303e9 Update package-lock.json to lockfileVersion=3
This reduces the size of the `package-lock.json` file a lot, and given that we recently updated the minimum supported Node.js version to 18 this shouldn't be a problem; please also see
 - https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json#lockfileversion
 - https://docs.npmjs.com/cli/v9/using-npm/config?v=true#lockfile-version
2023-05-16 09:50:57 +02:00
calixteman
2c0478ecb2
Merge pull request #16426 from calixteman/generate_fallback_one_time
For non-embedded fonts, don't generate the fallback several times
2023-05-15 21:25:29 +02:00
Calixte Denizet
4e8dd54e8e For non-embedded fonts, don't generate the fallback several times 2023-05-15 20:02:45 +02:00
calixteman
107874fcd4
Merge pull request #16420 from calixteman/simplify_subst
Simplify the code to generate font substitution information
2023-05-15 19:58:53 +02:00
Calixte Denizet
b264e0301a Simplify the code to generate font substitution information 2023-05-15 19:17:52 +02:00
calixteman
5f91d39f13
Merge pull request #16425 from calixteman/gv_nimbus
[GeckoView] Add a Nimbus experiment for the toolbar (bug 1833093)
2023-05-15 18:26:28 +02:00
Calixte Denizet
4ed512ab2c [GeckoView] Add a Nimbus experiment for the toolbar (bug 1833093) 2023-05-15 17:18:14 +02:00
Jonas Jenwald
c20c1b3362
Merge pull request #16422 from Snuffleupagus/getFontSubstitution-css-tests
Check the `css` property in the `getFontSubstitution` unit-tests
2023-05-15 10:09:17 +02:00
Jonas Jenwald
cb1a10e358 Check the css property in the getFontSubstitution unit-tests
Given that the `css` property isn't constant, since it contains document/font ids, we cannot just check it directly. However, we can make use of regular expressions to ensure that the format is generally correct.
2023-05-14 19:11:35 +02:00
calixteman
4101128c09
Merge pull request #16421 from calixteman/font_subst_test
Add tests for the font substitution
2023-05-14 18:23:12 +02:00
Calixte Denizet
89140fcd98 Add tests for the font substitution 2023-05-14 18:07:03 +02:00
Jonas Jenwald
9cbc2c389f
Merge pull request #16418 from Snuffleupagus/jasmine-5
Update `jasmine` to version 5
2023-05-14 14:03:46 +02:00
Jonas Jenwald
95ac708fbd Update jasmine to version 5
Despite this being a *major* version increase, it doesn't appear to require any updates in our test-suites.
Note in particular that the minimum supported browsers/environments were updated, however this isn't a problem given our recent support-changes in the PDF.js library.

Please find additional details at https://github.com/jasmine/jasmine/blob/main/release_notes/5.0.0.md
2023-05-14 13:04:08 +02:00
Tim van der Meij
693092c980
Merge pull request #16415 from Snuffleupagus/no-useless-promise-resolve-reject
Enable the `unicorn/no-useless-promise-resolve-reject` ESLint plugin rule
2023-05-14 12:41:11 +02:00
Tim van der Meij
521bea4f8f
Merge pull request #16417 from Snuffleupagus/update-packages
Update packages and translations
2023-05-14 12:40:22 +02:00
calixteman
202496a7ca
Merge pull request #16416 from calixteman/use_local_font_2
For missing font, use a local font if it exists even if there's no standard substitution
2023-05-14 12:27:55 +02:00
Jonas Jenwald
62f47588b4 Update l10n files 2023-05-14 10:15:01 +02:00
Jonas Jenwald
d25994e85d Update npm packages 2023-05-14 10:12:06 +02:00
Calixte Denizet
d4b70ec306 For missing font, use a local font if it exists even if there's no standard substitution
If the font foo is missing we just try lo load local(foo) and maybe
we'll be lucky.
2023-05-13 21:54:27 +02:00
Jonas Jenwald
8fbd6755eb Enable the unicorn/no-useless-promise-resolve-reject ESLint plugin rule
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md

Note that this patch also re-sorts the existing `unicorn`-rules in proper alphabetical order.
2023-05-13 11:30:25 +02:00
Tim van der Meij
e738e15aa3
Merge pull request #16413 from Snuffleupagus/PDFSidebar-inline-resizing
Move the sidebar-resizing handling into the `PDFSidebar` class
2023-05-12 10:15:35 +02:00
Tim van der Meij
a5336d9d79
Merge pull request #16401 from Snuffleupagus/Safari-15.4
[api-minor] Update the minimum supported Safari version to 15.4
2023-05-12 10:11:53 +02:00
Jonas Jenwald
8f3940fbf3 Move the sidebar-resizing handling into the PDFSidebar class
Originally the `PDFSidebarResizer` class was slightly larger, since the code used to contain e.g. feature testing for older (and no longer supported) browsers.
Given that there's some amount of overlap, when it comes to what DOM-elements and state that these classes need, it now seems reasonable to simply move the sidebar-resizing into the `PDFSidebar` class.

For the MOZCENTRAL build-target this patch reduces the size of the *built* `web/viewer.js` file by just over `1.1` kilobytes.
2023-05-12 10:00:12 +02:00
Jonas Jenwald
9417a37c71
Merge pull request #16410 from Snuffleupagus/toggleExpandedBtn
Reduce some duplication when toggling "expanded" buttons in the viewer toolbars
2023-05-11 13:10:39 +02:00
Jonas Jenwald
0305b04e26 Add the "aria-controls" attribute to the editor-toolbar buttons
Similar to other toolbar/secondaryToolbar buttons that open toolbars or dialogs, it seems reasonable to use "aria-controls" for the editor-toolbar buttons as well.
2023-05-11 12:04:16 +02:00
Jonas Jenwald
362be760e3 Reduce some duplication when toggling "expanded" buttons in the viewer toolbars
This is very similar to PR 16281, but for buttons that use the "aria-expanded" attribute.
2023-05-11 12:04:14 +02:00
calixteman
d520754bcf
Merge pull request #16408 from calixteman/local_font_cache
Add a cache to avoid to load several times a local font
2023-05-10 20:41:51 +02:00
Calixte Denizet
cfb908c999 Add a cache to avoid to load several times a local font
On my computer, it takes few tenths of a second to load a local font.
Since a font can be used several times in a document, the cache will
improve performances.
2023-05-10 20:01:21 +02:00
calixteman
2d2f7b315e
Merge pull request #16363 from calixteman/use_local_font
[api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039)
2023-05-10 14:19:05 +02:00
Calixte Denizet
53134c0c0b [api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039)
- Replace FoxitSans with LiberationSans: LiberationSans is already there (for XFA) and we can use
it as a good replacement of FoxitSans.
- For now we just try to substitue standard fonts, the strategy is the following:
  * we try to find a font locally from a hardcoded list;
  * if it fails then we use Liberation as fallback (only for Helvetica for the moment);
  * else we just fallback on the system serif/sansserif/monospace font.
2023-05-10 14:10:23 +02:00
calixteman
1a2e787e47
Merge pull request #16392 from calixteman/compress
Compress the data when saving annotions
2023-05-09 17:26:46 +02:00
Calixte Denizet
2486536843 Compress the data when saving annotions
CompressionStream API has been added in Firefox 113
(see https://bugzilla.mozilla.org/show_bug.cgi?id=1823619)
hence we can use it to compress the streams with added/modified
annotations.
2023-05-09 14:46:50 +02:00
calixteman
8f2d8f62f3
Merge pull request #16397 from calixteman/issue14565
Make something similar to Acrobat when Underline annotation has no appearance
2023-05-08 21:16:49 +02:00
Jonas Jenwald
d1adab8c7b [api-minor] Update the minimum supported Safari version to 15.4
This patch updates the minimum supported browsers as follows:
 - Safari 15.4, which was released on 2022-03-15; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_15

Nowadays we usually we try, where feasible and possible, to support browsers that are about two years old. The reasons for limiting support to a *somewhat* more recent Safari version include:
 - Throughout the history of the PDF.js project, Safari has always been the worst browser to attempt to support. Compared to other browsers there's a disproportionate number of bugs affecting Safari, especially on iOS, and in most cases those are browser-specific issues that we simply cannot address.[1]
 - Safari has often been a lot slower, compared to other browsers, at implementing new web-platform features. Historically this has sometimes blocked usage of new features, for the benefit of the Firefox PDF Viewer, and it's very often meant having to include and maintain polyfills *only* for Safari.
 - The current (minimum) supported Safari version lack enough functionality that polyfills placed in the `src/shared/compatibility.js` file are unfortunately not sufficient, but it also requires a bunch of special-cases in both the `gulpfile` and in the `web/`-code.
 - Given that the *built-in* Firefox PDF Viewer is the primary development target for the PDF.js library, and the general development pace these days, we need to limit the maintenance "overhead" caused by other browsers.

 ---
 [1] In a few cases a work-around might be possible, however it'd negatively affect e.g. performance, readability, and/or maintainability of the code.
2023-05-07 15:01:15 +02:00
Jonas Jenwald
2c2acdfd1c Revert "Add a <dialog> polyfill for the generic-legacy build"
This reverts commit c9f262c480 now that Safari-compatibility is updated.
2023-05-07 15:00:42 +02:00
Jonas Jenwald
c5eb79577a Revert "Bundle the <dialog> polyfill-CSS in the GENERIC legacy/-viewer (PR 14710 follow-up)"
This reverts commit bb8f5ec20b now that Safari-compatibility is updated.
2023-05-07 15:00:42 +02:00
Jonas Jenwald
cfa15bbf59 Revert "Compatible with ResizeObserver borderBoxSize in legacy safari"
This reverts commit 6ca702d680 now that Safari-compatibility is updated.
2023-05-07 15:00:42 +02:00
Tim van der Meij
bfb664b9a1
Merge pull request #16398 from Snuffleupagus/xfa-optional-chaining
Introduce some optional chaining in the `src/core/xfa/` folder
2023-05-07 14:54:05 +02:00
Tim van der Meij
7ecb3236f0
Merge pull request #16293 from Snuffleupagus/Node-18
[api-minor] Update the minimum supported Node.js version to 18
2023-05-07 14:48:26 +02:00
Jonas Jenwald
dcd55a7164 Enable unicorn/prefer-at unconditionally (PR 15014 follow-up)
Now that Node.js version 18 is required, we should be able to use `Array.prototype.at()` everywhere in the code-base.
2023-05-07 13:43:19 +02:00
Jonas Jenwald
f79f48c2b4 Remove the IMAGE_DECODERS special-case when polyfilling structuredClone
Originally we only used the `structuredClone` polyfill in the `LoopbackPort`-implementation, and that obviously isn't used anywhere within the various image decoders.
At this point in time we've started to use `structuredClone` a little bit more, hence it seems overall simpler to just bundle the polyfill even in the `legacy`-version of the IMAGE_DECODERS built-target.
2023-05-07 13:43:19 +02:00
Jonas Jenwald
1753e321cd Remove the compatibility checks in WorkerMessageHandler.createDocumentHandler
For some time these checks have only targeted Node.js environments, since the features in question exist in all supported browsers (even when a `legacy`-build is used).

Now that we've updated the minimum supported Node.js version to 18, a number of polyfills are thus (finally) no longer necessary in that environment. Hence for certain *basic* functionality, such as e.g. text-extraction, it's now possible to use either a modern- or a `legacy`-build of the PDF.js library in Node.js environments.

*Please note:* For e.g. canvas-rendering in Node.js environments it's still necessary to use a `legacy`-build, since that functionality requires various polyfills.
2023-05-07 13:43:19 +02:00
Jonas Jenwald
ed8be6f882 [api-minor] Update the minimum supported Node.js version to 18
This patch updates the minimum supported environments as follows:
 - Node.js 18, which was released on 2022-04-19; see https://en.wikipedia.org/wiki/Node.js#Releases

Note also that Node.js 16 will soon reach EOL, and thus no longer receive any security updates.
2023-05-07 13:43:19 +02:00
Tim van der Meij
eca40773b8
Merge pull request #16399 from timvandermeij/bump
Bump versions in `pdfjs.config`
2023-05-07 13:33:09 +02:00
Tim van der Meij
594ce65a47
Bump versions in pdfjs.config 2023-05-07 13:22:16 +02:00
Jonas Jenwald
89f768322d Introduce some optional chaining in the src/core/xfa/ folder
After PR 12563 we're now free to use optional chaining in the worker-thread as well.
2023-05-07 12:49:07 +02:00