2012-09-01 07:48:21 +09:00
|
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
2011-10-26 10:18:22 +09:00
|
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
AbortException,
|
|
|
|
|
assert,
|
|
|
|
|
CMapCompressionType,
|
|
|
|
|
createPromiseCapability,
|
|
|
|
|
FONT_IDENTITY_MATRIX,
|
|
|
|
|
FormatError,
|
|
|
|
|
IDENTITY_MATRIX,
|
|
|
|
|
info,
|
|
|
|
|
isArrayEqual,
|
|
|
|
|
isNum,
|
|
|
|
|
isString,
|
|
|
|
|
NativeImageDecoding,
|
|
|
|
|
OPS,
|
|
|
|
|
stringToPDFString,
|
|
|
|
|
TextRenderingMode,
|
|
|
|
|
UNSUPPORTED_FEATURES,
|
|
|
|
|
Util,
|
|
|
|
|
warn,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "../shared/util.js";
|
|
|
|
|
import { CMapFactory, IdentityCMap } from "./cmap.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
Cmd,
|
|
|
|
|
Dict,
|
|
|
|
|
EOF,
|
|
|
|
|
isDict,
|
|
|
|
|
isName,
|
|
|
|
|
isRef,
|
|
|
|
|
isStream,
|
|
|
|
|
Name,
|
|
|
|
|
Ref,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "./primitives.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
ErrorFont,
|
|
|
|
|
Font,
|
|
|
|
|
FontFlags,
|
|
|
|
|
getFontType,
|
|
|
|
|
IdentityToUnicodeMap,
|
|
|
|
|
ToUnicodeMap,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "./fonts.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
getEncoding,
|
|
|
|
|
MacRomanEncoding,
|
|
|
|
|
StandardEncoding,
|
|
|
|
|
SymbolSetEncoding,
|
|
|
|
|
WinAnsiEncoding,
|
|
|
|
|
ZapfDingbatsEncoding,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "./encodings.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
getNormalizedUnicodes,
|
|
|
|
|
getUnicodeForGlyph,
|
|
|
|
|
reverseIfRtl,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "./unicode.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
getSerifFonts,
|
|
|
|
|
getStdFontMap,
|
|
|
|
|
getSymbolsFonts,
|
2020-01-02 20:00:16 +09:00
|
|
|
|
} from "./standard_fonts.js";
|
|
|
|
|
import { getTilingPatternIR, Pattern } from "./pattern.js";
|
|
|
|
|
import { Lexer, Parser } from "./parser.js";
|
|
|
|
|
import { bidi } from "./bidi.js";
|
|
|
|
|
import { ColorSpace } from "./colorspace.js";
|
|
|
|
|
import { DecodeStream } from "./stream.js";
|
|
|
|
|
import { getGlyphsUnicode } from "./glyphlist.js";
|
|
|
|
|
import { getLookupTableFactory } from "./core_utils.js";
|
|
|
|
|
import { getMetrics } from "./metrics.js";
|
|
|
|
|
import { isPDFFunction } from "./function.js";
|
|
|
|
|
import { JpegStream } from "./jpeg_stream.js";
|
|
|
|
|
import { MurmurHash3_64 } from "./murmurhash3.js";
|
|
|
|
|
import { NativeImageDecoder } from "./image_utils.js";
|
|
|
|
|
import { OperatorList } from "./operator_list.js";
|
|
|
|
|
import { PDFImage } from "./image.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
|
var PartialEvaluator = (function PartialEvaluatorClosure() {
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
const DefaultPartialEvaluatorOptions = {
|
2016-03-03 09:48:21 +09:00
|
|
|
|
forceDataSchema: false,
|
|
|
|
|
maxImageSize: -1,
|
|
|
|
|
disableFontFace: false,
|
2017-05-08 12:32:44 +09:00
|
|
|
|
nativeImageDecoderSupport: NativeImageDecoding.DECODE,
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
ignoreErrors: false,
|
Check `isEvalSupported`, and test that `eval` is actually supported, before attempting to use the `PostScriptCompiler` (issue 5573)
Currently `PDFFunction` is implemented (basically) like a class with only `static` methods. Since it's used directly in a number of different `src/core/` files, attempting to pass in `isEvalSupported` would result in code that's *very* messy, not to mention difficult to maintain (since *every* single `PDFFunction` method call would need to include a `isEvalSupported` argument).
Rather than having to wait for a possible re-factoring of `PDFFunction` that would avoid the above problems by design, it probably makes sense to at least set `isEvalSupported` globally for `PDFFunction`.
Please note that there's one caveat with this solution: If `PDFJS.getDocument` is used to open multiple files simultaneously, with *different* `PDFJS.isEvalSupported` values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that `eval` is actually supported, it should be fine.
Fixes 5573.
2017-09-14 22:38:57 +09:00
|
|
|
|
isEvalSupported: true,
|
2016-03-03 09:48:21 +09:00
|
|
|
|
};
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
function PartialEvaluator({
|
|
|
|
|
xref,
|
|
|
|
|
handler,
|
|
|
|
|
pageIndex,
|
|
|
|
|
idFactory,
|
|
|
|
|
fontCache,
|
|
|
|
|
builtInCMapCache,
|
|
|
|
|
options = null,
|
|
|
|
|
pdfFunctionFactory,
|
|
|
|
|
}) {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
this.xref = xref;
|
|
|
|
|
this.handler = handler;
|
2012-10-29 05:10:34 +09:00
|
|
|
|
this.pageIndex = pageIndex;
|
2017-01-09 00:51:30 +09:00
|
|
|
|
this.idFactory = idFactory;
|
2013-11-15 06:43:38 +09:00
|
|
|
|
this.fontCache = fontCache;
|
2017-02-14 22:28:31 +09:00
|
|
|
|
this.builtInCMapCache = builtInCMapCache;
|
2016-03-03 09:48:21 +09:00
|
|
|
|
this.options = options || DefaultPartialEvaluatorOptions;
|
2017-09-19 20:49:30 +09:00
|
|
|
|
this.pdfFunctionFactory = pdfFunctionFactory;
|
2019-04-11 19:26:15 +09:00
|
|
|
|
this.parsingType3Font = false;
|
2017-02-12 23:54:41 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.fetchBuiltInCMap = async name => {
|
2018-07-25 23:11:48 +09:00
|
|
|
|
if (this.builtInCMapCache.has(name)) {
|
2018-07-30 20:58:09 +09:00
|
|
|
|
return this.builtInCMapCache.get(name);
|
2017-02-14 22:28:31 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const readableStream = this.handler.sendWithStream("FetchBuiltInCMap", {
|
Transfer, rather than copy, CMap data to the worker-thread
It recently occurred to me that the CMap data should be an excellent candidate for transfering.
This will help reduce peak memory usage for PDF documents using CMaps, since transfering of data avoids duplicating it on both the main- and worker-threads.
Unfortunately it's not possible to actually transfer data when *returning* data through `sendWithPromise`, and another solution had to be used.
Initially I looked at using one message for requesting the data, and another message for returning the actual CMap data. While that should have worked, it would have meant adding a lot more complexity particularly on the worker-thread.
Hence the simplest solution, at least in my opinion, is to utilize `sendWithStream` since that makes it *really* easy to transfer the CMap data. (This required PR 11115 to land first, since otherwise CMap fetch errors won't propagate correctly to the worker-thread.)
Please note that the patch *purposely* only changes the API to Worker communication, and not the API *itself* since changing the interface of `CMapReaderFactory` would be a breaking change.
Furthermore, given the relatively small size of the `.bcmap` files (the largest one is smaller than the default range-request size) streaming doesn't really seem necessary either.
2019-09-04 18:20:14 +09:00
|
|
|
|
name,
|
|
|
|
|
});
|
|
|
|
|
const reader = readableStream.getReader();
|
|
|
|
|
|
|
|
|
|
const data = await new Promise(function(resolve, reject) {
|
|
|
|
|
function pump() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
reader.read().then(function({ value, done }) {
|
Transfer, rather than copy, CMap data to the worker-thread
It recently occurred to me that the CMap data should be an excellent candidate for transfering.
This will help reduce peak memory usage for PDF documents using CMaps, since transfering of data avoids duplicating it on both the main- and worker-threads.
Unfortunately it's not possible to actually transfer data when *returning* data through `sendWithPromise`, and another solution had to be used.
Initially I looked at using one message for requesting the data, and another message for returning the actual CMap data. While that should have worked, it would have meant adding a lot more complexity particularly on the worker-thread.
Hence the simplest solution, at least in my opinion, is to utilize `sendWithStream` since that makes it *really* easy to transfer the CMap data. (This required PR 11115 to land first, since otherwise CMap fetch errors won't propagate correctly to the worker-thread.)
Please note that the patch *purposely* only changes the API to Worker communication, and not the API *itself* since changing the interface of `CMapReaderFactory` would be a breaking change.
Furthermore, given the relatively small size of the `.bcmap` files (the largest one is smaller than the default range-request size) streaming doesn't really seem necessary either.
2019-09-04 18:20:14 +09:00
|
|
|
|
if (done) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
resolve(value);
|
|
|
|
|
pump();
|
|
|
|
|
}, reject);
|
|
|
|
|
}
|
|
|
|
|
pump();
|
|
|
|
|
});
|
|
|
|
|
|
2018-07-30 20:58:09 +09:00
|
|
|
|
if (data.compressionType !== CMapCompressionType.NONE) {
|
|
|
|
|
// Given the size of uncompressed CMaps, only cache compressed ones.
|
|
|
|
|
this.builtInCMapCache.set(name, data);
|
|
|
|
|
}
|
|
|
|
|
return data;
|
2017-02-12 23:54:41 +09:00
|
|
|
|
};
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-10 10:41:03 +09:00
|
|
|
|
// Trying to minimize Date.now() usage and check every 100 time
|
|
|
|
|
var TIME_SLOT_DURATION_MS = 20;
|
|
|
|
|
var CHECK_TIME_EVERY = 100;
|
|
|
|
|
function TimeSlotManager() {
|
|
|
|
|
this.reset();
|
|
|
|
|
}
|
|
|
|
|
TimeSlotManager.prototype = {
|
|
|
|
|
check: function TimeSlotManager_check() {
|
|
|
|
|
if (++this.checked < CHECK_TIME_EVERY) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
this.checked = 0;
|
|
|
|
|
return this.endTime <= Date.now();
|
|
|
|
|
},
|
|
|
|
|
reset: function TimeSlotManager_reset() {
|
|
|
|
|
this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
|
|
|
|
|
this.checked = 0;
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2014-05-10 10:41:03 +09:00
|
|
|
|
};
|
|
|
|
|
|
2017-04-11 03:58:02 +09:00
|
|
|
|
// Convert PDF blend mode names to HTML5 blend mode names.
|
2019-10-26 18:57:56 +09:00
|
|
|
|
function normalizeBlendMode(value, parsingArray = false) {
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
// Use the first *supported* BM value in the Array (fixes issue11279.pdf).
|
|
|
|
|
for (let i = 0, ii = value.length; i < ii; i++) {
|
|
|
|
|
const maybeBM = normalizeBlendMode(value[i], /* parsingArray = */ true);
|
|
|
|
|
if (maybeBM) {
|
|
|
|
|
return maybeBM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
warn(`Unsupported blend mode Array: ${value}`);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return "source-over";
|
2019-10-26 18:57:56 +09:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-11 03:58:02 +09:00
|
|
|
|
if (!isName(value)) {
|
2019-10-26 18:57:56 +09:00
|
|
|
|
if (parsingArray) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return "source-over";
|
2017-04-11 03:58:02 +09:00
|
|
|
|
}
|
|
|
|
|
switch (value.name) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "Normal":
|
|
|
|
|
case "Compatible":
|
|
|
|
|
return "source-over";
|
|
|
|
|
case "Multiply":
|
|
|
|
|
return "multiply";
|
|
|
|
|
case "Screen":
|
|
|
|
|
return "screen";
|
|
|
|
|
case "Overlay":
|
|
|
|
|
return "overlay";
|
|
|
|
|
case "Darken":
|
|
|
|
|
return "darken";
|
|
|
|
|
case "Lighten":
|
|
|
|
|
return "lighten";
|
|
|
|
|
case "ColorDodge":
|
|
|
|
|
return "color-dodge";
|
|
|
|
|
case "ColorBurn":
|
|
|
|
|
return "color-burn";
|
|
|
|
|
case "HardLight":
|
|
|
|
|
return "hard-light";
|
|
|
|
|
case "SoftLight":
|
|
|
|
|
return "soft-light";
|
|
|
|
|
case "Difference":
|
|
|
|
|
return "difference";
|
|
|
|
|
case "Exclusion":
|
|
|
|
|
return "exclusion";
|
|
|
|
|
case "Hue":
|
|
|
|
|
return "hue";
|
|
|
|
|
case "Saturation":
|
|
|
|
|
return "saturation";
|
|
|
|
|
case "Color":
|
|
|
|
|
return "color";
|
|
|
|
|
case "Luminosity":
|
|
|
|
|
return "luminosity";
|
2017-04-11 03:58:02 +09:00
|
|
|
|
}
|
2019-10-26 18:57:56 +09:00
|
|
|
|
if (parsingArray) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
warn(`Unsupported blend mode: ${value.name}`);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return "source-over";
|
2017-04-11 03:58:02 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-10 10:41:03 +09:00
|
|
|
|
var deferred = Promise.resolve();
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var TILING_PATTERN = 1,
|
|
|
|
|
SHADING_PATTERN = 2;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
|
PartialEvaluator.prototype = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
clone(newOptions = DefaultPartialEvaluatorOptions) {
|
2017-04-05 20:32:36 +09:00
|
|
|
|
var newEvaluator = Object.create(this);
|
|
|
|
|
newEvaluator.options = newOptions;
|
|
|
|
|
return newEvaluator;
|
|
|
|
|
},
|
|
|
|
|
|
2013-08-01 03:17:36 +09:00
|
|
|
|
hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
|
2019-10-12 18:24:37 +09:00
|
|
|
|
if (!(resources instanceof Dict)) {
|
2013-08-01 03:17:36 +09:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 23:07:38 +09:00
|
|
|
|
var processed = Object.create(null);
|
|
|
|
|
if (resources.objId) {
|
|
|
|
|
processed[resources.objId] = true;
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var nodes = [resources],
|
|
|
|
|
xref = this.xref;
|
2013-08-01 03:17:36 +09:00
|
|
|
|
while (nodes.length) {
|
|
|
|
|
var node = nodes.shift();
|
|
|
|
|
// First check the current resources for blend modes.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var graphicStates = node.get("ExtGState");
|
2019-10-12 18:24:37 +09:00
|
|
|
|
if (graphicStates instanceof Dict) {
|
2016-02-10 01:09:17 +09:00
|
|
|
|
var graphicStatesKeys = graphicStates.getKeys();
|
2019-10-12 18:24:37 +09:00
|
|
|
|
for (let i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
|
|
|
|
|
const key = graphicStatesKeys[i];
|
2016-02-10 01:09:17 +09:00
|
|
|
|
|
2019-10-12 18:44:07 +09:00
|
|
|
|
let graphicState = graphicStates.getRaw(key);
|
|
|
|
|
if (graphicState instanceof Ref) {
|
|
|
|
|
if (processed[graphicState.toString()]) {
|
|
|
|
|
continue; // The ExtGState has already been processed.
|
|
|
|
|
}
|
|
|
|
|
graphicState = xref.fetch(graphicState);
|
|
|
|
|
}
|
|
|
|
|
if (!(graphicState instanceof Dict)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (graphicState.objId) {
|
|
|
|
|
processed[graphicState.objId] = true;
|
|
|
|
|
}
|
2019-10-28 19:28:13 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const bm = graphicState.get("BM");
|
2019-10-28 19:28:13 +09:00
|
|
|
|
if (bm instanceof Name) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (bm.name !== "Normal") {
|
2019-10-28 19:28:13 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bm !== undefined && Array.isArray(bm)) {
|
|
|
|
|
for (let j = 0, jj = bm.length; j < jj; j++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (bm[j] instanceof Name && bm[j].name !== "Normal") {
|
2019-10-28 19:28:13 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-01 03:17:36 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Descend into the XObjects to look for more resources and blend modes.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var xObjects = node.get("XObject");
|
2019-10-12 18:24:37 +09:00
|
|
|
|
if (!(xObjects instanceof Dict)) {
|
2013-08-01 03:17:36 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2016-02-10 01:09:17 +09:00
|
|
|
|
var xObjectsKeys = xObjects.getKeys();
|
2019-10-12 18:24:37 +09:00
|
|
|
|
for (let i = 0, ii = xObjectsKeys.length; i < ii; i++) {
|
|
|
|
|
const key = xObjectsKeys[i];
|
2016-02-10 01:09:17 +09:00
|
|
|
|
|
|
|
|
|
var xObject = xObjects.getRaw(key);
|
2019-10-12 18:24:37 +09:00
|
|
|
|
if (xObject instanceof Ref) {
|
2016-02-10 01:09:17 +09:00
|
|
|
|
if (processed[xObject.toString()]) {
|
|
|
|
|
// The XObject has already been processed, and by avoiding a
|
|
|
|
|
// redundant `xref.fetch` we can *significantly* reduce the load
|
|
|
|
|
// time for badly generated PDF files (fixes issue6961.pdf).
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
xObject = xref.fetch(xObject);
|
|
|
|
|
}
|
2013-08-01 03:17:36 +09:00
|
|
|
|
if (!isStream(xObject)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-06-10 18:29:25 +09:00
|
|
|
|
if (xObject.dict.objId) {
|
|
|
|
|
if (processed[xObject.dict.objId]) {
|
2019-10-12 18:24:37 +09:00
|
|
|
|
continue; // Stream has objId and was processed already.
|
2014-06-10 18:29:25 +09:00
|
|
|
|
}
|
|
|
|
|
processed[xObject.dict.objId] = true;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var xResources = xObject.dict.get("Resources");
|
2014-03-26 23:07:38 +09:00
|
|
|
|
// Checking objId to detect an infinite loop.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
xResources instanceof Dict &&
|
|
|
|
|
(!xResources.objId || !processed[xResources.objId])
|
|
|
|
|
) {
|
2013-08-01 03:17:36 +09:00
|
|
|
|
nodes.push(xResources);
|
2014-03-26 23:07:38 +09:00
|
|
|
|
if (xResources.objId) {
|
|
|
|
|
processed[xResources.objId] = true;
|
|
|
|
|
}
|
2013-08-01 03:17:36 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2012-09-14 00:09:46 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
async buildFormXObject(
|
|
|
|
|
resources,
|
|
|
|
|
xobj,
|
|
|
|
|
smask,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
initialState
|
|
|
|
|
) {
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
var dict = xobj.dict;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var matrix = dict.getArray("Matrix");
|
|
|
|
|
var bbox = dict.getArray("BBox");
|
2018-10-16 22:23:14 +09:00
|
|
|
|
if (Array.isArray(bbox) && bbox.length === 4) {
|
|
|
|
|
bbox = Util.normalizeRect(bbox);
|
|
|
|
|
} else {
|
|
|
|
|
bbox = null;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var group = dict.get("Group");
|
2013-04-09 07:14:56 +09:00
|
|
|
|
if (group) {
|
|
|
|
|
var groupOptions = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
matrix,
|
|
|
|
|
bbox,
|
|
|
|
|
smask,
|
2013-04-09 07:14:56 +09:00
|
|
|
|
isolated: false,
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
knockout: false,
|
2012-10-16 01:48:45 +09:00
|
|
|
|
};
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var groupSubtype = group.get("S");
|
2017-09-19 20:49:30 +09:00
|
|
|
|
var colorSpace = null;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (isName(groupSubtype, "Transparency")) {
|
|
|
|
|
groupOptions.isolated = group.get("I") || false;
|
|
|
|
|
groupOptions.knockout = group.get("K") || false;
|
|
|
|
|
if (group.has("CS")) {
|
2019-10-31 23:53:51 +09:00
|
|
|
|
colorSpace = await this.parseColorSpace({
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
cs: group.get("CS"),
|
2019-10-31 23:53:51 +09:00
|
|
|
|
resources,
|
|
|
|
|
});
|
2017-09-19 20:49:30 +09:00
|
|
|
|
}
|
2013-04-09 07:14:56 +09:00
|
|
|
|
}
|
2014-05-22 02:47:42 +09:00
|
|
|
|
|
|
|
|
|
if (smask && smask.backdrop) {
|
|
|
|
|
colorSpace = colorSpace || ColorSpace.singletons.rgb;
|
|
|
|
|
smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
|
operatorList.addOp(OPS.beginGroup, [groupOptions]);
|
2012-10-16 01:48:45 +09:00
|
|
|
|
}
|
2012-09-14 00:09:46 +09:00
|
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
|
operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]);
|
2012-09-14 00:09:46 +09:00
|
|
|
|
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
return this.getOperatorList({
|
|
|
|
|
stream: xobj,
|
|
|
|
|
task,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
resources: dict.get("Resources") || resources,
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
operatorList,
|
|
|
|
|
initialState,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).then(function() {
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
operatorList.addOp(OPS.paintFormXObjectEnd, []);
|
|
|
|
|
|
|
|
|
|
if (group) {
|
|
|
|
|
operatorList.addOp(OPS.endGroup, [groupOptions]);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
async buildPaintImageXObject({
|
|
|
|
|
resources,
|
|
|
|
|
image,
|
|
|
|
|
isInline = false,
|
|
|
|
|
operatorList,
|
|
|
|
|
cacheKey,
|
|
|
|
|
imageCache,
|
|
|
|
|
forceDisableNativeImageDecoder = false,
|
|
|
|
|
}) {
|
2013-04-09 07:14:56 +09:00
|
|
|
|
var dict = image.dict;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var w = dict.get("Width", "W");
|
|
|
|
|
var h = dict.get("Height", "H");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
2014-04-09 20:04:27 +09:00
|
|
|
|
if (!(w && isNum(w)) || !(h && isNum(h))) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
warn("Image dimensions are missing, or not numbers.");
|
2019-05-10 19:54:06 +09:00
|
|
|
|
return undefined;
|
2014-04-09 20:04:27 +09:00
|
|
|
|
}
|
2016-03-03 09:48:21 +09:00
|
|
|
|
var maxImageSize = this.options.maxImageSize;
|
|
|
|
|
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
warn("Image exceeded maximum allowed size and was removed.");
|
2019-05-10 19:54:06 +09:00
|
|
|
|
return undefined;
|
2013-07-11 01:52:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var imageMask = dict.get("ImageMask", "IM") || false;
|
2014-04-08 06:42:54 +09:00
|
|
|
|
var imgData, args;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
if (imageMask) {
|
2014-03-23 03:15:51 +09:00
|
|
|
|
// This depends on a tmpCanvas being filled with the
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// current fillStyle, such that processing the pixel
|
|
|
|
|
// data can't be done here. Instead of creating a
|
|
|
|
|
// complete PDFImage, only read the information needed
|
|
|
|
|
// for later.
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var width = dict.get("Width", "W");
|
|
|
|
|
var height = dict.get("Height", "H");
|
2013-04-09 07:14:56 +09:00
|
|
|
|
var bitStrideLength = (width + 7) >> 3;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var imgArray = image.getBytes(
|
|
|
|
|
bitStrideLength * height,
|
|
|
|
|
/* forceClamped = */ true
|
|
|
|
|
);
|
|
|
|
|
var decode = dict.getArray("Decode", "D");
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
2017-09-21 19:14:05 +09:00
|
|
|
|
imgData = PDFImage.createMask({
|
|
|
|
|
imgArray,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
imageIsFromDecodeStream: image instanceof DecodeStream,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
inverseDecode: !!decode && decode[0] > 0,
|
2017-09-21 19:14:05 +09:00
|
|
|
|
});
|
2019-03-16 20:09:14 +09:00
|
|
|
|
imgData.cached = !!cacheKey;
|
2014-04-08 06:42:54 +09:00
|
|
|
|
args = [imgData];
|
2019-03-16 20:09:14 +09:00
|
|
|
|
|
2014-02-25 00:59:02 +09:00
|
|
|
|
operatorList.addOp(OPS.paintImageMaskXObject, args);
|
|
|
|
|
if (cacheKey) {
|
2014-10-27 01:03:44 +09:00
|
|
|
|
imageCache[cacheKey] = {
|
|
|
|
|
fn: OPS.paintImageMaskXObject,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
args,
|
2014-10-27 01:03:44 +09:00
|
|
|
|
};
|
2014-02-25 00:59:02 +09:00
|
|
|
|
}
|
2019-05-10 19:54:06 +09:00
|
|
|
|
return undefined;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var softMask = dict.get("SMask", "SM") || false;
|
|
|
|
|
var mask = dict.get("Mask") || false;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
|
|
|
|
var SMALL_IMAGE_DIMENSIONS = 200;
|
|
|
|
|
// Inlining small images into the queue as RGB data
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
isInline &&
|
|
|
|
|
!softMask &&
|
|
|
|
|
!mask &&
|
|
|
|
|
!(image instanceof JpegStream) &&
|
|
|
|
|
w + h < SMALL_IMAGE_DIMENSIONS
|
|
|
|
|
) {
|
2017-09-21 19:14:05 +09:00
|
|
|
|
let imageObj = new PDFImage({
|
|
|
|
|
xref: this.xref,
|
|
|
|
|
res: resources,
|
|
|
|
|
image,
|
2018-02-01 23:44:49 +09:00
|
|
|
|
isInline,
|
2017-09-19 20:49:30 +09:00
|
|
|
|
pdfFunctionFactory: this.pdfFunctionFactory,
|
2017-09-21 19:14:05 +09:00
|
|
|
|
});
|
2014-02-26 08:11:15 +09:00
|
|
|
|
// We force the use of RGBA_32BPP images here, because we can't handle
|
|
|
|
|
// any other kind.
|
2014-04-08 06:42:54 +09:00
|
|
|
|
imgData = imageObj.createImageData(/* forceRGBA = */ true);
|
2013-11-14 04:43:38 +09:00
|
|
|
|
operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
|
2019-05-10 19:54:06 +09:00
|
|
|
|
return undefined;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const nativeImageDecoderSupport = forceDisableNativeImageDecoder
|
|
|
|
|
? NativeImageDecoding.NONE
|
|
|
|
|
: this.options.nativeImageDecoderSupport;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// If there is no imageMask, create the PDFImage and a lot
|
|
|
|
|
// of image processing can be done here.
|
2019-04-20 19:36:49 +09:00
|
|
|
|
let objId = `img_${this.idFactory.createObjId()}`;
|
2019-04-11 19:26:15 +09:00
|
|
|
|
|
|
|
|
|
if (this.parsingType3Font) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
assert(
|
|
|
|
|
nativeImageDecoderSupport === NativeImageDecoding.NONE,
|
|
|
|
|
"Type3 image resources should be completely decoded in the worker."
|
|
|
|
|
);
|
2019-04-11 19:26:15 +09:00
|
|
|
|
|
2019-04-20 19:36:49 +09:00
|
|
|
|
objId = `${this.idFactory.getDocId()}_type3res_${objId}`;
|
2019-04-11 19:26:15 +09:00
|
|
|
|
}
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
nativeImageDecoderSupport !== NativeImageDecoding.NONE &&
|
|
|
|
|
!softMask &&
|
|
|
|
|
!mask &&
|
|
|
|
|
image instanceof JpegStream &&
|
|
|
|
|
NativeImageDecoder.isSupported(
|
|
|
|
|
image,
|
|
|
|
|
this.xref,
|
|
|
|
|
resources,
|
|
|
|
|
this.pdfFunctionFactory
|
|
|
|
|
)
|
|
|
|
|
) {
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// These JPEGs don't need any more processing so we can just send it.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.handler
|
|
|
|
|
.sendWithPromise("obj", [
|
|
|
|
|
objId,
|
|
|
|
|
this.pageIndex,
|
|
|
|
|
"JpegStream",
|
|
|
|
|
image.getIR(this.options.forceDataSchema),
|
|
|
|
|
])
|
|
|
|
|
.then(
|
|
|
|
|
function() {
|
2019-12-26 04:03:46 +09:00
|
|
|
|
// Only add the dependency once we know that the native JPEG
|
|
|
|
|
// decoding succeeded, to ensure that rendering will always
|
|
|
|
|
// complete.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
operatorList.addDependency(objId);
|
|
|
|
|
args = [objId, w, h];
|
|
|
|
|
|
|
|
|
|
operatorList.addOp(OPS.paintJpegXObject, args);
|
|
|
|
|
if (cacheKey) {
|
|
|
|
|
imageCache[cacheKey] = {
|
|
|
|
|
fn: OPS.paintJpegXObject,
|
|
|
|
|
args,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
reason => {
|
|
|
|
|
warn(
|
|
|
|
|
"Native JPEG decoding failed -- trying to recover: " +
|
|
|
|
|
(reason && reason.message)
|
|
|
|
|
);
|
|
|
|
|
// Try to decode the JPEG image with the built-in decoder instead.
|
|
|
|
|
return this.buildPaintImageXObject({
|
|
|
|
|
resources,
|
|
|
|
|
image,
|
|
|
|
|
isInline,
|
|
|
|
|
operatorList,
|
|
|
|
|
cacheKey,
|
|
|
|
|
imageCache,
|
|
|
|
|
forceDisableNativeImageDecoder: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-01 21:36:16 +09:00
|
|
|
|
// Creates native image decoder only if a JPEG image or mask is present.
|
|
|
|
|
var nativeImageDecoder = null;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
nativeImageDecoderSupport === NativeImageDecoding.DECODE &&
|
|
|
|
|
(image instanceof JpegStream ||
|
|
|
|
|
mask instanceof JpegStream ||
|
|
|
|
|
softMask instanceof JpegStream)
|
|
|
|
|
) {
|
2017-09-21 19:14:05 +09:00
|
|
|
|
nativeImageDecoder = new NativeImageDecoder({
|
|
|
|
|
xref: this.xref,
|
|
|
|
|
resources,
|
|
|
|
|
handler: this.handler,
|
|
|
|
|
forceDataSchema: this.options.forceDataSchema,
|
2017-09-19 20:49:30 +09:00
|
|
|
|
pdfFunctionFactory: this.pdfFunctionFactory,
|
2017-09-21 19:14:05 +09:00
|
|
|
|
});
|
2016-04-01 21:36:16 +09:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 00:43:10 +09:00
|
|
|
|
// Ensure that the dependency is added before the image is decoded.
|
|
|
|
|
operatorList.addDependency(objId);
|
|
|
|
|
args = [objId, w, h];
|
|
|
|
|
|
2019-04-11 19:26:15 +09:00
|
|
|
|
const imgPromise = PDFImage.buildImage({
|
2017-09-21 19:14:05 +09:00
|
|
|
|
handler: this.handler,
|
|
|
|
|
xref: this.xref,
|
|
|
|
|
res: resources,
|
|
|
|
|
image,
|
2018-02-01 23:44:49 +09:00
|
|
|
|
isInline,
|
2017-09-21 19:14:05 +09:00
|
|
|
|
nativeDecoder: nativeImageDecoder,
|
2017-09-19 20:49:30 +09:00
|
|
|
|
pdfFunctionFactory: this.pdfFunctionFactory,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
})
|
|
|
|
|
.then(imageObj => {
|
|
|
|
|
var imgData = imageObj.createImageData(/* forceRGBA = */ false);
|
|
|
|
|
|
|
|
|
|
if (this.parsingType3Font) {
|
|
|
|
|
return this.handler.sendWithPromise(
|
|
|
|
|
"commonobj",
|
|
|
|
|
[objId, "FontType3Res", imgData],
|
|
|
|
|
[imgData.data.buffer]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.handler.send(
|
|
|
|
|
"obj",
|
|
|
|
|
[objId, this.pageIndex, "Image", imgData],
|
|
|
|
|
[imgData.data.buffer]
|
|
|
|
|
);
|
|
|
|
|
return undefined;
|
|
|
|
|
})
|
|
|
|
|
.catch(reason => {
|
|
|
|
|
warn("Unable to decode image: " + reason);
|
|
|
|
|
|
|
|
|
|
if (this.parsingType3Font) {
|
|
|
|
|
return this.handler.sendWithPromise("commonobj", [
|
|
|
|
|
objId,
|
|
|
|
|
"FontType3Res",
|
|
|
|
|
null,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
this.handler.send("obj", [objId, this.pageIndex, "Image", null]);
|
|
|
|
|
return undefined;
|
|
|
|
|
});
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2019-04-11 19:26:15 +09:00
|
|
|
|
if (this.parsingType3Font) {
|
|
|
|
|
// In the very rare case where a Type3 image resource is being parsed,
|
|
|
|
|
// wait for the image to be both decoded *and* sent to simplify the
|
|
|
|
|
// rendering code on the main-thread (see issue10717.pdf).
|
|
|
|
|
await imgPromise;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
|
operatorList.addOp(OPS.paintImageXObject, args);
|
2014-02-24 23:00:08 +09:00
|
|
|
|
if (cacheKey) {
|
2014-10-27 01:03:44 +09:00
|
|
|
|
imageCache[cacheKey] = {
|
|
|
|
|
fn: OPS.paintImageXObject,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
args,
|
2014-10-27 01:03:44 +09:00
|
|
|
|
};
|
2014-02-24 23:00:08 +09:00
|
|
|
|
}
|
2019-05-10 19:54:06 +09:00
|
|
|
|
return undefined;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
handleSMask: function PartialEvaluator_handleSmask(
|
|
|
|
|
smask,
|
|
|
|
|
resources,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager
|
|
|
|
|
) {
|
|
|
|
|
var smaskContent = smask.get("G");
|
2014-01-24 02:13:32 +09:00
|
|
|
|
var smaskOptions = {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
subtype: smask.get("S").name,
|
|
|
|
|
backdrop: smask.get("BC"),
|
2014-01-24 02:13:32 +09:00
|
|
|
|
};
|
2015-12-05 03:52:45 +09:00
|
|
|
|
|
|
|
|
|
// The SMask might have a alpha/luminosity value transfer function --
|
|
|
|
|
// we will build a map of integer values in range 0..255 to be fast.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var transferObj = smask.get("TR");
|
2015-12-05 03:52:45 +09:00
|
|
|
|
if (isPDFFunction(transferObj)) {
|
2017-09-19 20:49:30 +09:00
|
|
|
|
let transferFn = this.pdfFunctionFactory.create(transferObj);
|
2015-12-05 03:52:45 +09:00
|
|
|
|
var transferMap = new Uint8Array(256);
|
|
|
|
|
var tmp = new Float32Array(1);
|
2016-02-03 21:31:48 +09:00
|
|
|
|
for (var i = 0; i < 256; i++) {
|
2015-12-05 03:52:45 +09:00
|
|
|
|
tmp[0] = i / 255;
|
|
|
|
|
transferFn(tmp, 0, tmp, 0);
|
|
|
|
|
transferMap[i] = (tmp[0] * 255) | 0;
|
|
|
|
|
}
|
|
|
|
|
smaskOptions.transferMap = transferMap;
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.buildFormXObject(
|
|
|
|
|
resources,
|
|
|
|
|
smaskContent,
|
|
|
|
|
smaskOptions,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager.state.clone()
|
|
|
|
|
);
|
2014-01-24 02:13:32 +09:00
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
handleTilingType(
|
|
|
|
|
fn,
|
|
|
|
|
args,
|
|
|
|
|
resources,
|
|
|
|
|
pattern,
|
|
|
|
|
patternDict,
|
|
|
|
|
operatorList,
|
|
|
|
|
task
|
|
|
|
|
) {
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// Create an IR of the pattern code.
|
2017-05-24 19:12:14 +09:00
|
|
|
|
let tilingOpList = new OperatorList();
|
2015-10-21 03:22:06 +09:00
|
|
|
|
// Merge the available resources, to prevent issues when the patternDict
|
|
|
|
|
// is missing some /Resources entries (fixes issue6541.pdf).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let resourcesArray = [patternDict.get("Resources"), resources];
|
2017-05-24 19:12:14 +09:00
|
|
|
|
let patternResources = Dict.merge(this.xref, resourcesArray);
|
2015-10-21 03:22:06 +09:00
|
|
|
|
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
return this.getOperatorList({
|
|
|
|
|
stream: pattern,
|
|
|
|
|
task,
|
|
|
|
|
resources: patternResources,
|
|
|
|
|
operatorList: tilingOpList,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
})
|
|
|
|
|
.then(function() {
|
|
|
|
|
return getTilingPatternIR(
|
|
|
|
|
{
|
|
|
|
|
fnArray: tilingOpList.fnArray,
|
|
|
|
|
argsArray: tilingOpList.argsArray,
|
|
|
|
|
},
|
|
|
|
|
patternDict,
|
|
|
|
|
args
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.then(
|
|
|
|
|
function(tilingPatternIR) {
|
|
|
|
|
// Add the dependencies to the parent operator list so they are
|
|
|
|
|
// resolved before the sub operator list is executed synchronously.
|
|
|
|
|
operatorList.addDependencies(tilingOpList.dependencies);
|
|
|
|
|
operatorList.addOp(fn, tilingPatternIR);
|
|
|
|
|
},
|
|
|
|
|
reason => {
|
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the TilingPattern -- sending unsupported feature
|
|
|
|
|
// notification and allow rendering to continue.
|
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.unknown,
|
|
|
|
|
});
|
|
|
|
|
warn(`handleTilingType - ignoring pattern: "${reason}".`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw reason;
|
|
|
|
|
}
|
|
|
|
|
);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
2012-09-14 00:09:46 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
handleSetFont: function PartialEvaluator_handleSetFont(
|
|
|
|
|
resources,
|
|
|
|
|
fontArgs,
|
|
|
|
|
fontRef,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
state
|
|
|
|
|
) {
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// TODO(mack): Not needed?
|
|
|
|
|
var fontName;
|
|
|
|
|
if (fontArgs) {
|
|
|
|
|
fontArgs = fontArgs.slice();
|
|
|
|
|
fontName = fontArgs[0].name;
|
|
|
|
|
}
|
2013-08-01 03:17:36 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.loadFont(fontName, fontRef, resources)
|
|
|
|
|
.then(translated => {
|
|
|
|
|
if (!translated.font.isType3Font) {
|
|
|
|
|
return translated;
|
|
|
|
|
}
|
|
|
|
|
return translated
|
|
|
|
|
.loadType3Data(this, resources, operatorList, task)
|
|
|
|
|
.then(function() {
|
|
|
|
|
return translated;
|
|
|
|
|
})
|
|
|
|
|
.catch(reason => {
|
2019-12-26 04:03:46 +09:00
|
|
|
|
// Error in the font data -- sending unsupported feature
|
|
|
|
|
// notification.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.font,
|
|
|
|
|
});
|
|
|
|
|
return new TranslatedFont(
|
|
|
|
|
"g_font_error",
|
|
|
|
|
new ErrorFont("Type3 font load error: " + reason),
|
|
|
|
|
translated.font
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.then(translated => {
|
|
|
|
|
state.font = translated.font;
|
|
|
|
|
translated.send(this.handler);
|
|
|
|
|
return translated.loadedName;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
});
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
2013-03-13 09:20:38 +09:00
|
|
|
|
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
handleText(chars, state) {
|
|
|
|
|
const font = state.font;
|
|
|
|
|
const glyphs = font.charsToGlyphs(chars);
|
2014-05-04 00:28:30 +09:00
|
|
|
|
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
if (font.data) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const isAddToPathSet = !!(
|
|
|
|
|
state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
|
|
|
|
|
);
|
|
|
|
|
if (
|
|
|
|
|
isAddToPathSet ||
|
|
|
|
|
state.fillColorSpace.name === "Pattern" ||
|
|
|
|
|
font.disableFontFace ||
|
|
|
|
|
this.options.disableFontFace
|
|
|
|
|
) {
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
PartialEvaluator.buildFontPaths(font, glyphs, this.handler);
|
2013-08-20 08:33:20 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return glyphs;
|
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
setGState: function PartialEvaluator_setGState(
|
|
|
|
|
resources,
|
|
|
|
|
gState,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager
|
|
|
|
|
) {
|
2014-08-18 14:21:45 +09:00
|
|
|
|
// This array holds the converted/processed state data.
|
|
|
|
|
var gStateObj = [];
|
2016-02-04 00:53:18 +09:00
|
|
|
|
var gStateKeys = gState.getKeys();
|
2014-08-18 14:21:45 +09:00
|
|
|
|
var promise = Promise.resolve();
|
2016-02-04 00:53:18 +09:00
|
|
|
|
for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
|
2017-04-30 06:36:43 +09:00
|
|
|
|
let key = gStateKeys[i];
|
|
|
|
|
let value = gState.get(key);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
switch (key) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "Type":
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "LW":
|
|
|
|
|
case "LC":
|
|
|
|
|
case "LJ":
|
|
|
|
|
case "ML":
|
|
|
|
|
case "D":
|
|
|
|
|
case "RI":
|
|
|
|
|
case "FL":
|
|
|
|
|
case "CA":
|
|
|
|
|
case "ca":
|
2013-04-09 07:14:56 +09:00
|
|
|
|
gStateObj.push([key, value]);
|
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "Font":
|
2017-04-30 06:36:43 +09:00
|
|
|
|
promise = promise.then(() => {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.handleSetFont(
|
|
|
|
|
resources,
|
|
|
|
|
null,
|
|
|
|
|
value[0],
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager.state
|
|
|
|
|
).then(function(loadedName) {
|
|
|
|
|
operatorList.addDependency(loadedName);
|
|
|
|
|
gStateObj.push([key, [loadedName, value[1]]]);
|
|
|
|
|
});
|
2014-05-10 10:21:15 +09:00
|
|
|
|
});
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "BM":
|
2017-04-11 03:58:02 +09:00
|
|
|
|
gStateObj.push([key, normalizeBlendMode(value)]);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "SMask":
|
|
|
|
|
if (isName(value, "None")) {
|
2014-01-24 02:13:32 +09:00
|
|
|
|
gStateObj.push([key, false]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-02-04 00:53:18 +09:00
|
|
|
|
if (isDict(value)) {
|
2017-04-30 06:36:43 +09:00
|
|
|
|
promise = promise.then(() => {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.handleSMask(
|
|
|
|
|
value,
|
|
|
|
|
resources,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager
|
|
|
|
|
);
|
2017-04-30 06:36:43 +09:00
|
|
|
|
});
|
2014-01-24 02:13:32 +09:00
|
|
|
|
gStateObj.push([key, true]);
|
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
warn("Unsupported SMask type");
|
2014-01-24 02:13:32 +09:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
|
|
|
|
// Only generate info log messages for the following since
|
2014-08-15 12:34:53 +09:00
|
|
|
|
// they are unlikely to have a big impact on the rendering.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "OP":
|
|
|
|
|
case "op":
|
|
|
|
|
case "OPM":
|
|
|
|
|
case "BG":
|
|
|
|
|
case "BG2":
|
|
|
|
|
case "UCR":
|
|
|
|
|
case "UCR2":
|
|
|
|
|
case "TR":
|
|
|
|
|
case "TR2":
|
|
|
|
|
case "HT":
|
|
|
|
|
case "SM":
|
|
|
|
|
case "SA":
|
|
|
|
|
case "AIS":
|
|
|
|
|
case "TK":
|
2013-04-09 07:14:56 +09:00
|
|
|
|
// TODO implement these operators.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
info("graphic state operator " + key);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
info("Unknown graphic state operator " + key);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return promise.then(function() {
|
2016-02-03 22:29:20 +09:00
|
|
|
|
if (gStateObj.length > 0) {
|
2014-08-15 12:34:53 +09:00
|
|
|
|
operatorList.addOp(OPS.setGState, [gStateObj]);
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
});
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
2012-12-08 03:19:43 +09:00
|
|
|
|
|
2017-03-26 21:12:53 +09:00
|
|
|
|
loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
|
2013-08-01 03:17:36 +09:00
|
|
|
|
function errorFont() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return Promise.resolve(
|
|
|
|
|
new TranslatedFont(
|
|
|
|
|
"g_font_error",
|
|
|
|
|
new ErrorFont("Font " + fontName + " is not available"),
|
|
|
|
|
font
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fontRef,
|
|
|
|
|
xref = this.xref;
|
|
|
|
|
if (font) {
|
|
|
|
|
// Loading by ref.
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!isRef(font)) {
|
2019-10-02 21:13:49 +09:00
|
|
|
|
throw new FormatError('The "font" object should be a reference.');
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2013-06-26 02:33:53 +09:00
|
|
|
|
fontRef = font;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
} else {
|
|
|
|
|
// Loading by name.
|
|
|
|
|
var fontRes = resources.get("Font");
|
2013-06-26 02:33:53 +09:00
|
|
|
|
if (fontRes) {
|
|
|
|
|
fontRef = fontRes.getRaw(fontName);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-12 19:46:39 +09:00
|
|
|
|
if (!fontRef) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const partialMsg = `Font "${fontName ||
|
|
|
|
|
(font && font.toString())}" is not available`;
|
2019-10-02 21:13:49 +09:00
|
|
|
|
|
|
|
|
|
if (!this.options.ignoreErrors && !this.parsingType3Font) {
|
|
|
|
|
warn(`${partialMsg}.`);
|
|
|
|
|
return errorFont();
|
|
|
|
|
}
|
|
|
|
|
// Font not found -- sending unsupported feature notification.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.font,
|
|
|
|
|
});
|
2019-10-02 21:13:49 +09:00
|
|
|
|
warn(`${partialMsg} -- attempting to fallback to a default font.`);
|
|
|
|
|
|
|
|
|
|
// Falling back to a default font to avoid completely broken rendering,
|
|
|
|
|
// but note that there're no guarantees that things will look "correct".
|
|
|
|
|
fontRef = new Dict();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
fontRef.set("BaseFont", Name.get("PDFJS-FallbackFont"));
|
|
|
|
|
fontRef.set("Type", Name.get("FallbackType"));
|
|
|
|
|
fontRef.set("Subtype", Name.get("FallbackType"));
|
|
|
|
|
fontRef.set("Encoding", Name.get("WinAnsiEncoding"));
|
2014-06-12 19:46:39 +09:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 02:33:53 +09:00
|
|
|
|
if (this.fontCache.has(fontRef)) {
|
|
|
|
|
return this.fontCache.get(fontRef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
font = xref.fetchIfRef(fontRef);
|
|
|
|
|
if (!isDict(font)) {
|
2013-08-01 03:17:36 +09:00
|
|
|
|
return errorFont();
|
2013-05-04 03:13:45 +09:00
|
|
|
|
}
|
2014-03-04 02:44:45 +09:00
|
|
|
|
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
// We are holding `font.translated` references just for `fontRef`s that
|
|
|
|
|
// are not actually `Ref`s, but rather `Dict`s. See explanation below.
|
2014-05-20 06:27:54 +09:00
|
|
|
|
if (font.translated) {
|
|
|
|
|
return font.translated;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var fontCapability = createPromiseCapability();
|
|
|
|
|
|
2017-03-26 21:12:53 +09:00
|
|
|
|
var preEvaluatedFont = this.preEvaluateFont(font);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const { descriptor, hash } = preEvaluatedFont;
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontRefIsRef = isRef(fontRef),
|
|
|
|
|
fontID;
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
if (fontRefIsRef) {
|
|
|
|
|
fontID = fontRef.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 08:00:13 +09:00
|
|
|
|
if (hash && isDict(descriptor)) {
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (!descriptor.fontAliases) {
|
|
|
|
|
descriptor.fontAliases = Object.create(null);
|
|
|
|
|
}
|
|
|
|
|
var fontAliases = descriptor.fontAliases;
|
2019-03-27 08:00:13 +09:00
|
|
|
|
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (fontAliases[hash]) {
|
|
|
|
|
var aliasFontRef = fontAliases[hash].aliasRef;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
fontRefIsRef &&
|
|
|
|
|
aliasFontRef &&
|
|
|
|
|
this.fontCache.has(aliasFontRef)
|
|
|
|
|
) {
|
2014-03-04 02:44:45 +09:00
|
|
|
|
this.fontCache.putAlias(fontRef, aliasFontRef);
|
2014-05-20 06:27:54 +09:00
|
|
|
|
return this.fontCache.get(fontRef);
|
2014-03-04 02:44:45 +09:00
|
|
|
|
}
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
} else {
|
2014-03-04 02:44:45 +09:00
|
|
|
|
fontAliases[hash] = {
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
fontID: Font.getFontID(),
|
2014-03-04 02:44:45 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
if (fontRefIsRef) {
|
|
|
|
|
fontAliases[hash].aliasRef = fontRef;
|
|
|
|
|
}
|
2014-03-04 02:44:45 +09:00
|
|
|
|
fontID = fontAliases[hash].fontID;
|
|
|
|
|
}
|
|
|
|
|
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
// Workaround for bad PDF generators that reference fonts incorrectly,
|
|
|
|
|
// where `fontRef` is a `Dict` rather than a `Ref` (fixes bug946506.pdf).
|
Attempt to cache fonts that are direct objects (i.e. `Dict`s), as opposed to `Ref`s, to prevent re-rendering after `cleanup` from breaking (issue 7403 and issue 7402)
Fonts that are not referenced by `Ref`s are very uncommon in practice, but it can unfortunately happen. In this case, we're currently not caching them in the usual way, i.e. by `Ref`, which leads to failures when a page is rendered after `cleanup` has run.
The simplest solution would have been to remove the `font.translated` workaround, but since this would have meant loading these kind of fonts over and over, the patch attempts to be a bit clever about this situation.
Note that if we instead loaded fonts per *page*, instead of per document, this issue wouldn't have existed.
2016-06-11 21:28:59 +09:00
|
|
|
|
// In this case we should not put the font into `this.fontCache` (which is
|
|
|
|
|
// a `RefSetCache`), since it's not meaningful to use a `Dict` as a key.
|
|
|
|
|
//
|
|
|
|
|
// However, if we don't cache the font it's not possible to remove it
|
|
|
|
|
// when `cleanup` is triggered from the API, which causes issues on
|
|
|
|
|
// subsequent rendering operations (see issue7403.pdf).
|
|
|
|
|
// A simple workaround would be to just not hold `font.translated`
|
|
|
|
|
// references in this case, but this would force us to unnecessarily load
|
|
|
|
|
// the same fonts over and over.
|
|
|
|
|
//
|
|
|
|
|
// Instead, we cheat a bit by attempting to use a modified `fontID` as a
|
|
|
|
|
// key in `this.fontCache`, to allow the font to be cached.
|
|
|
|
|
// NOTE: This works because `RefSetCache` calls `toString()` on provided
|
|
|
|
|
// keys. Also, since `fontRef` is used when getting cached fonts,
|
|
|
|
|
// we'll not accidentally match fonts cached with the `fontID`.
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
if (fontRefIsRef) {
|
2014-05-10 10:21:15 +09:00
|
|
|
|
this.fontCache.put(fontRef, fontCapability.promise);
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
} else {
|
|
|
|
|
if (!fontID) {
|
2017-01-09 00:51:30 +09:00
|
|
|
|
fontID = this.idFactory.createObjId();
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
}
|
2019-04-20 19:36:49 +09:00
|
|
|
|
this.fontCache.put(`id_${fontID}`, fontCapability.promise);
|
2013-12-17 08:19:31 +09:00
|
|
|
|
}
|
Attempt to cache fonts that are direct objects (i.e. `Dict`s), as opposed to `Ref`s, to prevent re-rendering after `cleanup` from breaking (issue 7403 and issue 7402)
Fonts that are not referenced by `Ref`s are very uncommon in practice, but it can unfortunately happen. In this case, we're currently not caching them in the usual way, i.e. by `Ref`, which leads to failures when a page is rendered after `cleanup` has run.
The simplest solution would have been to remove the `font.translated` workaround, but since this would have meant loading these kind of fonts over and over, the patch attempts to be a bit clever about this situation.
Note that if we instead loaded fonts per *page*, instead of per document, this issue wouldn't have existed.
2016-06-11 21:28:59 +09:00
|
|
|
|
assert(fontID, 'The "fontID" must be defined.');
|
2013-05-04 03:13:45 +09:00
|
|
|
|
|
2014-03-23 03:15:51 +09:00
|
|
|
|
// Keep track of each font we translated so the caller can
|
|
|
|
|
// load them asynchronously before calling display on a page.
|
2019-04-20 19:36:49 +09:00
|
|
|
|
font.loadedName = `${this.idFactory.getDocId()}_f${fontID}`;
|
2012-02-21 22:28:42 +09:00
|
|
|
|
|
2014-05-20 06:27:54 +09:00
|
|
|
|
font.translated = fontCapability.promise;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
2014-05-20 06:27:54 +09:00
|
|
|
|
// TODO move promises into translate font
|
|
|
|
|
var translatedPromise;
|
|
|
|
|
try {
|
2017-03-26 21:12:53 +09:00
|
|
|
|
translatedPromise = this.translateFont(preEvaluatedFont);
|
2014-05-20 06:27:54 +09:00
|
|
|
|
} catch (e) {
|
|
|
|
|
translatedPromise = Promise.reject(e);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2014-05-20 06:27:54 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
translatedPromise
|
|
|
|
|
.then(function(translatedFont) {
|
|
|
|
|
if (translatedFont.fontType !== undefined) {
|
|
|
|
|
var xrefFontStats = xref.stats.fontTypes;
|
|
|
|
|
xrefFontStats[translatedFont.fontType] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fontCapability.resolve(
|
|
|
|
|
new TranslatedFont(font.loadedName, translatedFont, font)
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.catch(reason => {
|
|
|
|
|
// TODO fontCapability.reject?
|
|
|
|
|
// Error in the font data -- sending unsupported feature notification.
|
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.font,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// error, but it's still nice to have font type reported
|
|
|
|
|
var fontFile3 = descriptor && descriptor.get("FontFile3");
|
|
|
|
|
var subtype = fontFile3 && fontFile3.get("Subtype");
|
|
|
|
|
var fontType = getFontType(
|
|
|
|
|
preEvaluatedFont.type,
|
|
|
|
|
subtype && subtype.name
|
|
|
|
|
);
|
|
|
|
|
var xrefFontStats = xref.stats.fontTypes;
|
|
|
|
|
xrefFontStats[fontType] = true;
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
|
|
|
|
|
fontCapability.resolve(
|
|
|
|
|
new TranslatedFont(
|
|
|
|
|
font.loadedName,
|
|
|
|
|
new ErrorFont(reason instanceof Error ? reason.message : reason),
|
|
|
|
|
font
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
});
|
2014-05-20 06:27:54 +09:00
|
|
|
|
return fontCapability.promise;
|
2013-04-09 07:14:56 +09:00
|
|
|
|
},
|
|
|
|
|
|
2019-04-22 00:03:38 +09:00
|
|
|
|
buildPath(operatorList, fn, args, parsingText = false) {
|
2014-04-30 23:09:04 +09:00
|
|
|
|
var lastIndex = operatorList.length - 1;
|
2014-08-08 19:50:54 +09:00
|
|
|
|
if (!args) {
|
|
|
|
|
args = [];
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
lastIndex < 0 ||
|
|
|
|
|
operatorList.fnArray[lastIndex] !== OPS.constructPath
|
|
|
|
|
) {
|
2019-04-22 00:03:38 +09:00
|
|
|
|
// Handle corrupt PDF documents that contains path operators inside of
|
|
|
|
|
// text objects, which may shift subsequent text, by enclosing the path
|
|
|
|
|
// operator in save/restore operators (fixes issue10542_reduced.pdf).
|
|
|
|
|
//
|
|
|
|
|
// Note that this will effectively disable the optimization in the
|
|
|
|
|
// `else` branch below, but given that this type of corruption is
|
|
|
|
|
// *extremely* rare that shouldn't really matter much in practice.
|
|
|
|
|
if (parsingText) {
|
|
|
|
|
warn(`Encountered path operator "${fn}" inside of a text object.`);
|
|
|
|
|
operatorList.addOp(OPS.save, null);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 23:09:04 +09:00
|
|
|
|
operatorList.addOp(OPS.constructPath, [[fn], args]);
|
2019-04-22 00:03:38 +09:00
|
|
|
|
|
|
|
|
|
if (parsingText) {
|
|
|
|
|
operatorList.addOp(OPS.restore, null);
|
|
|
|
|
}
|
2014-04-30 23:09:04 +09:00
|
|
|
|
} else {
|
|
|
|
|
var opArgs = operatorList.argsArray[lastIndex];
|
|
|
|
|
opArgs[0].push(fn);
|
|
|
|
|
Array.prototype.push.apply(opArgs[1], args);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
parseColorSpace({ cs, resources }) {
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
resolve(
|
|
|
|
|
ColorSpace.parse(cs, this.xref, resources, this.pdfFunctionFactory)
|
|
|
|
|
);
|
|
|
|
|
}).catch(reason => {
|
2019-10-31 23:53:51 +09:00
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (this.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the ColorSpace -- sending unsupported feature
|
|
|
|
|
// notification and allow rendering to continue.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.unknown,
|
|
|
|
|
});
|
2019-10-31 23:53:51 +09:00
|
|
|
|
warn(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
throw reason;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2019-05-04 19:39:58 +09:00
|
|
|
|
async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
|
2014-05-22 02:47:42 +09:00
|
|
|
|
// compile tiling patterns
|
|
|
|
|
var patternName = args[args.length - 1];
|
|
|
|
|
// SCN/scn applies patterns along with normal colors
|
|
|
|
|
var pattern;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
|
|
|
|
|
var dict = isStream(pattern) ? pattern.dict : pattern;
|
|
|
|
|
var typeNum = dict.get("PatternType");
|
2014-05-22 02:47:42 +09:00
|
|
|
|
|
2014-06-02 19:43:20 +09:00
|
|
|
|
if (typeNum === TILING_PATTERN) {
|
2014-05-22 02:47:42 +09:00
|
|
|
|
var color = cs.base ? cs.base.getRgb(args, 0) : null;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.handleTilingType(
|
|
|
|
|
fn,
|
|
|
|
|
color,
|
|
|
|
|
resources,
|
|
|
|
|
pattern,
|
|
|
|
|
dict,
|
|
|
|
|
operatorList,
|
|
|
|
|
task
|
|
|
|
|
);
|
2014-06-02 19:43:20 +09:00
|
|
|
|
} else if (typeNum === SHADING_PATTERN) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var shading = dict.get("Shading");
|
|
|
|
|
var matrix = dict.getArray("Matrix");
|
|
|
|
|
pattern = Pattern.parseShading(
|
|
|
|
|
shading,
|
|
|
|
|
matrix,
|
|
|
|
|
this.xref,
|
|
|
|
|
resources,
|
|
|
|
|
this.handler,
|
|
|
|
|
this.pdfFunctionFactory
|
|
|
|
|
);
|
2014-05-22 02:47:42 +09:00
|
|
|
|
operatorList.addOp(fn, pattern.getIR());
|
2019-05-04 19:39:58 +09:00
|
|
|
|
return undefined;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
}
|
2019-05-04 19:39:58 +09:00
|
|
|
|
throw new FormatError(`Unknown PatternType: ${typeNum}`);
|
2014-05-22 02:47:42 +09:00
|
|
|
|
}
|
2019-05-04 19:39:58 +09:00
|
|
|
|
throw new FormatError(`Unknown PatternName: ${patternName}`);
|
2014-05-22 02:47:42 +09:00
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
getOperatorList({
|
|
|
|
|
stream,
|
|
|
|
|
task,
|
|
|
|
|
resources,
|
|
|
|
|
operatorList,
|
|
|
|
|
initialState = null,
|
|
|
|
|
}) {
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
// Ensure that `resources`/`initialState` is correctly initialized,
|
|
|
|
|
// even if the provided parameter is e.g. `null`.
|
|
|
|
|
resources = resources || Dict.empty;
|
|
|
|
|
initialState = initialState || new EvalState();
|
|
|
|
|
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!operatorList) {
|
|
|
|
|
throw new Error('getOperatorList: missing "operatorList" parameter');
|
|
|
|
|
}
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
|
2013-04-09 07:14:56 +09:00
|
|
|
|
var self = this;
|
|
|
|
|
var xref = this.xref;
|
2019-04-22 00:03:38 +09:00
|
|
|
|
let parsingText = false;
|
2016-01-28 02:04:13 +09:00
|
|
|
|
var imageCache = Object.create(null);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var xobjs = resources.get("XObject") || Dict.empty;
|
|
|
|
|
var patterns = resources.get("Pattern") || Dict.empty;
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
var stateManager = new StateManager(initialState);
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
|
2014-05-10 10:41:03 +09:00
|
|
|
|
var timeSlotManager = new TimeSlotManager();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
function closePendingRestoreOPS(argument) {
|
|
|
|
|
for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
|
|
|
|
|
operatorList.addOp(OPS.restore, []);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return new Promise(function promiseBody(resolve, reject) {
|
Use streams for OperatorList chunking (issue 10023)
*Please note:* The majority of this patch was written by Yury, and it's simply been rebased and slightly extended to prevent issues when dealing with `RenderingCancelledException`.
By leveraging streams this (finally) provides a simple way in which parsing can be aborted on the worker-thread, which will ultimately help save resources.
With this patch worker-thread parsing will *only* be aborted when the document is destroyed, and not when rendering is cancelled. There's a couple of reasons for this:
- The API currently expects the *entire* OperatorList to be extracted, or an Error to occur, once it's been started. Hence additional re-factoring/re-writing of the API code will be necessary to properly support cancelling and re-starting of OperatorList parsing in cases where the `lastChunk` hasn't yet been seen.
- Even with the above addressed, immediately cancelling when encountering a `RenderingCancelledException` will lead to worse performance in e.g. the default viewer. When zooming and/or rotation of the document occurs it's very likely that `cancel` will be (almost) immediately followed by a new `render` call. In that case you'd obviously *not* want to abort parsing on the worker-thread, since then you'd risk throwing away a partially parsed Page and thus be forced to re-parse it again which will regress perceived performance.
- This patch is already *somewhat* risky, given that it touches fundamentally important/critical code, and trying to keep it somewhat small should hopefully reduce the risk of regressions (and simplify reviewing as well).
Time permitting, once this has landed and been in Nightly for awhile, I'll try to work on the remaining points outlined above.
Co-Authored-By: Yury Delendik <ydelendik@mozilla.com>
Co-Authored-By: Jonas Jenwald <jonas.jenwald@gmail.com>
2017-11-10 10:58:43 +09:00
|
|
|
|
let next = function(promise) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
Promise.all([promise, operatorList.ready]).then(function() {
|
2016-03-11 22:59:09 +09:00
|
|
|
|
try {
|
|
|
|
|
promiseBody(resolve, reject);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
reject(ex);
|
|
|
|
|
}
|
|
|
|
|
}, reject);
|
|
|
|
|
};
|
2015-10-21 10:50:32 +09:00
|
|
|
|
task.ensureNotTerminated();
|
2014-05-10 10:41:03 +09:00
|
|
|
|
timeSlotManager.reset();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var stop,
|
|
|
|
|
operation = {},
|
|
|
|
|
i,
|
|
|
|
|
ii,
|
|
|
|
|
cs;
|
2014-08-11 09:23:23 +09:00
|
|
|
|
while (!(stop = timeSlotManager.check())) {
|
|
|
|
|
// The arguments parsed by read() are used beyond this loop, so we
|
|
|
|
|
// cannot reuse the same array on each iteration. Therefore we pass
|
|
|
|
|
// in |null| as the initial value (see the comment on
|
|
|
|
|
// EvaluatorPreprocessor_read() for why).
|
|
|
|
|
operation.args = null;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (!preprocessor.read(operation)) {
|
2014-08-11 09:23:23 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var args = operation.args;
|
|
|
|
|
var fn = operation.fn;
|
|
|
|
|
|
|
|
|
|
switch (fn | 0) {
|
|
|
|
|
case OPS.paintXObject:
|
|
|
|
|
// eagerly compile XForm objects
|
|
|
|
|
var name = args[0].name;
|
2017-09-17 20:35:18 +09:00
|
|
|
|
if (name && imageCache[name] !== undefined) {
|
2014-10-27 01:03:44 +09:00
|
|
|
|
operatorList.addOp(imageCache[name].fn, imageCache[name].args);
|
2014-06-20 12:52:39 +09:00
|
|
|
|
args = null;
|
2014-02-24 23:00:08 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
new Promise(function(resolveXObject, rejectXObject) {
|
|
|
|
|
if (!name) {
|
|
|
|
|
throw new FormatError(
|
|
|
|
|
"XObject must be referred to by name."
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-09-17 20:35:18 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let xobj = xobjs.get(name);
|
|
|
|
|
if (!xobj) {
|
|
|
|
|
operatorList.addOp(fn, args);
|
|
|
|
|
resolveXObject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isStream(xobj)) {
|
|
|
|
|
throw new FormatError("XObject should be a stream");
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let type = xobj.dict.get("Subtype");
|
|
|
|
|
if (!isName(type)) {
|
|
|
|
|
throw new FormatError("XObject should have a Name subtype");
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type.name === "Form") {
|
|
|
|
|
stateManager.save();
|
|
|
|
|
self
|
|
|
|
|
.buildFormXObject(
|
|
|
|
|
resources,
|
|
|
|
|
xobj,
|
|
|
|
|
null,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager.state.clone()
|
|
|
|
|
)
|
|
|
|
|
.then(function() {
|
|
|
|
|
stateManager.restore();
|
|
|
|
|
resolveXObject();
|
|
|
|
|
}, rejectXObject);
|
|
|
|
|
return;
|
|
|
|
|
} else if (type.name === "Image") {
|
|
|
|
|
self
|
|
|
|
|
.buildPaintImageXObject({
|
|
|
|
|
resources,
|
|
|
|
|
image: xobj,
|
|
|
|
|
operatorList,
|
|
|
|
|
cacheKey: name,
|
|
|
|
|
imageCache,
|
|
|
|
|
})
|
|
|
|
|
.then(resolveXObject, rejectXObject);
|
|
|
|
|
return;
|
|
|
|
|
} else if (type.name === "PS") {
|
|
|
|
|
// PostScript XObjects are unused when viewing documents.
|
|
|
|
|
// See section 4.7.1 of Adobe's PDF reference.
|
|
|
|
|
info("Ignored XObject subtype PS");
|
|
|
|
|
} else {
|
|
|
|
|
throw new FormatError(
|
|
|
|
|
`Unhandled XObject subtype ${type.name}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
resolveXObject();
|
|
|
|
|
}).catch(function(reason) {
|
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (self.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the XObject -- sending unsupported feature
|
|
|
|
|
// notification and allow rendering to continue.
|
|
|
|
|
self.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.unknown,
|
|
|
|
|
});
|
|
|
|
|
warn(`getOperatorList - ignoring XObject: "${reason}".`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw reason;
|
|
|
|
|
})
|
|
|
|
|
);
|
2017-09-17 20:35:18 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setFont:
|
|
|
|
|
var fontSize = args[1];
|
|
|
|
|
// eagerly collect all fonts
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
self
|
|
|
|
|
.handleSetFont(
|
|
|
|
|
resources,
|
|
|
|
|
args,
|
|
|
|
|
null,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager.state
|
|
|
|
|
)
|
|
|
|
|
.then(function(loadedName) {
|
|
|
|
|
operatorList.addDependency(loadedName);
|
|
|
|
|
operatorList.addOp(OPS.setFont, [loadedName, fontSize]);
|
|
|
|
|
})
|
|
|
|
|
);
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2019-04-22 00:03:38 +09:00
|
|
|
|
case OPS.beginText:
|
|
|
|
|
parsingText = true;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.endText:
|
|
|
|
|
parsingText = false;
|
|
|
|
|
break;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.endInlineImage:
|
|
|
|
|
var cacheKey = args[0].cacheKey;
|
2014-10-27 01:03:44 +09:00
|
|
|
|
if (cacheKey) {
|
|
|
|
|
var cacheEntry = imageCache[cacheKey];
|
|
|
|
|
if (cacheEntry !== undefined) {
|
|
|
|
|
operatorList.addOp(cacheEntry.fn, cacheEntry.args);
|
|
|
|
|
args = null;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-02-25 00:59:02 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
self.buildPaintImageXObject({
|
|
|
|
|
resources,
|
|
|
|
|
image: args[0],
|
|
|
|
|
isInline: true,
|
|
|
|
|
operatorList,
|
|
|
|
|
cacheKey,
|
|
|
|
|
imageCache,
|
|
|
|
|
})
|
|
|
|
|
);
|
2018-02-01 23:53:37 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.showText:
|
|
|
|
|
args[0] = self.handleText(args[0], stateManager.state);
|
|
|
|
|
break;
|
|
|
|
|
case OPS.showSpacedText:
|
|
|
|
|
var arr = args[0];
|
2014-05-24 03:36:54 +09:00
|
|
|
|
var combinedGlyphs = [];
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var arrLength = arr.length;
|
2015-08-28 20:42:01 +09:00
|
|
|
|
var state = stateManager.state;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
for (i = 0; i < arrLength; ++i) {
|
2014-05-24 03:36:54 +09:00
|
|
|
|
var arrItem = arr[i];
|
|
|
|
|
if (isString(arrItem)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
Array.prototype.push.apply(
|
|
|
|
|
combinedGlyphs,
|
|
|
|
|
self.handleText(arrItem, state)
|
|
|
|
|
);
|
2014-05-24 03:36:54 +09:00
|
|
|
|
} else if (isNum(arrItem)) {
|
|
|
|
|
combinedGlyphs.push(arrItem);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
|
args[0] = combinedGlyphs;
|
|
|
|
|
fn = OPS.showText;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.nextLineShowText:
|
2014-05-24 03:36:54 +09:00
|
|
|
|
operatorList.addOp(OPS.nextLine);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
args[0] = self.handleText(args[0], stateManager.state);
|
2014-05-24 03:36:54 +09:00
|
|
|
|
fn = OPS.showText;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.nextLineSetSpacingShowText:
|
2014-05-24 03:36:54 +09:00
|
|
|
|
operatorList.addOp(OPS.nextLine);
|
|
|
|
|
operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
|
|
|
|
|
operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
|
|
|
|
|
args[0] = self.handleText(args[0], stateManager.state);
|
|
|
|
|
fn = OPS.showText;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.setTextRenderingMode:
|
|
|
|
|
stateManager.state.textRenderingMode = args[0];
|
|
|
|
|
break;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setFillColorSpace:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
self
|
|
|
|
|
.parseColorSpace({
|
|
|
|
|
cs: args[0],
|
|
|
|
|
resources,
|
|
|
|
|
})
|
|
|
|
|
.then(function(colorSpace) {
|
|
|
|
|
if (colorSpace) {
|
|
|
|
|
stateManager.state.fillColorSpace = colorSpace;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
2019-10-31 23:53:51 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setStrokeColorSpace:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
self
|
|
|
|
|
.parseColorSpace({
|
|
|
|
|
cs: args[0],
|
|
|
|
|
resources,
|
|
|
|
|
})
|
|
|
|
|
.then(function(colorSpace) {
|
|
|
|
|
if (colorSpace) {
|
|
|
|
|
stateManager.state.strokeColorSpace = colorSpace;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
2019-10-31 23:53:51 +09:00
|
|
|
|
return;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
case OPS.setFillColor:
|
|
|
|
|
cs = stateManager.state.fillColorSpace;
|
|
|
|
|
args = cs.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setFillRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setStrokeColor:
|
|
|
|
|
cs = stateManager.state.strokeColorSpace;
|
|
|
|
|
args = cs.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setStrokeRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setFillGray:
|
|
|
|
|
stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
|
|
|
|
|
args = ColorSpace.singletons.gray.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setFillRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setStrokeGray:
|
|
|
|
|
stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
|
|
|
|
|
args = ColorSpace.singletons.gray.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setStrokeRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setFillCMYKColor:
|
|
|
|
|
stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
|
|
|
|
|
args = ColorSpace.singletons.cmyk.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setFillRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setStrokeCMYKColor:
|
|
|
|
|
stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
|
|
|
|
|
args = ColorSpace.singletons.cmyk.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setStrokeRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setFillRGBColor:
|
|
|
|
|
stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
|
|
|
|
|
args = ColorSpace.singletons.rgb.getRgb(args, 0);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
case OPS.setStrokeRGBColor:
|
|
|
|
|
stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
|
|
|
|
|
args = ColorSpace.singletons.rgb.getRgb(args, 0);
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setFillColorN:
|
|
|
|
|
cs = stateManager.state.fillColorSpace;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (cs.name === "Pattern") {
|
|
|
|
|
next(
|
|
|
|
|
self.handleColorN(
|
|
|
|
|
operatorList,
|
|
|
|
|
OPS.setFillColorN,
|
|
|
|
|
args,
|
|
|
|
|
cs,
|
|
|
|
|
patterns,
|
|
|
|
|
resources,
|
|
|
|
|
task
|
|
|
|
|
)
|
|
|
|
|
);
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
}
|
|
|
|
|
args = cs.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setFillRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setStrokeColorN:
|
|
|
|
|
cs = stateManager.state.strokeColorSpace;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (cs.name === "Pattern") {
|
|
|
|
|
next(
|
|
|
|
|
self.handleColorN(
|
|
|
|
|
operatorList,
|
|
|
|
|
OPS.setStrokeColorN,
|
|
|
|
|
args,
|
|
|
|
|
cs,
|
|
|
|
|
patterns,
|
|
|
|
|
resources,
|
|
|
|
|
task
|
|
|
|
|
)
|
|
|
|
|
);
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
}
|
|
|
|
|
args = cs.getRgb(args, 0);
|
|
|
|
|
fn = OPS.setStrokeRGBColor;
|
|
|
|
|
break;
|
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.shadingFill:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var shadingRes = resources.get("Shading");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!shadingRes) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("No shading resource found");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2013-06-05 09:57:52 +09:00
|
|
|
|
|
2014-05-22 02:47:42 +09:00
|
|
|
|
var shading = shadingRes.get(args[0].name);
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!shading) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("No shading object found");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2013-06-05 09:57:52 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var shadingFill = Pattern.parseShading(
|
|
|
|
|
shading,
|
|
|
|
|
null,
|
|
|
|
|
xref,
|
|
|
|
|
resources,
|
|
|
|
|
self.handler,
|
|
|
|
|
self.pdfFunctionFactory
|
|
|
|
|
);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var patternIR = shadingFill.getIR();
|
|
|
|
|
args = [patternIR];
|
|
|
|
|
fn = OPS.shadingFill;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
break;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setGState:
|
|
|
|
|
var dictName = args[0];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var extGState = resources.get("ExtGState");
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
if (!isDict(extGState) || !extGState.has(dictName.name)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var gState = extGState.get(dictName.name);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
self.setGState(
|
|
|
|
|
resources,
|
|
|
|
|
gState,
|
|
|
|
|
operatorList,
|
|
|
|
|
task,
|
|
|
|
|
stateManager
|
|
|
|
|
)
|
|
|
|
|
);
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.moveTo:
|
|
|
|
|
case OPS.lineTo:
|
|
|
|
|
case OPS.curveTo:
|
|
|
|
|
case OPS.curveTo2:
|
|
|
|
|
case OPS.curveTo3:
|
|
|
|
|
case OPS.closePath:
|
2014-06-24 05:07:31 +09:00
|
|
|
|
case OPS.rectangle:
|
2019-04-22 00:03:38 +09:00
|
|
|
|
self.buildPath(operatorList, fn, args, parsingText);
|
2014-06-24 05:07:31 +09:00
|
|
|
|
continue;
|
2015-10-21 22:39:25 +09:00
|
|
|
|
case OPS.markPoint:
|
|
|
|
|
case OPS.markPointProps:
|
|
|
|
|
case OPS.beginMarkedContent:
|
|
|
|
|
case OPS.beginMarkedContentProps:
|
|
|
|
|
case OPS.endMarkedContent:
|
|
|
|
|
case OPS.beginCompat:
|
|
|
|
|
case OPS.endCompat:
|
|
|
|
|
// Ignore operators where the corresponding handlers are known to
|
|
|
|
|
// be no-op in CanvasGraphics (display/canvas.js). This prevents
|
|
|
|
|
// serialization errors and is also a bit more efficient.
|
|
|
|
|
// We could also try to serialize all objects in a general way,
|
|
|
|
|
// e.g. as done in https://github.com/mozilla/pdf.js/pull/6266,
|
|
|
|
|
// but doing so is meaningless without knowing the semantics.
|
|
|
|
|
continue;
|
|
|
|
|
default:
|
2016-02-13 02:15:49 +09:00
|
|
|
|
// Note: Ignore the operator if it has `Dict` arguments, since
|
|
|
|
|
// those are non-serializable, otherwise postMessage will throw
|
2015-10-21 22:39:25 +09:00
|
|
|
|
// "An object could not be cloned.".
|
2016-02-13 02:15:49 +09:00
|
|
|
|
if (args !== null) {
|
|
|
|
|
for (i = 0, ii = args.length; i < ii; i++) {
|
|
|
|
|
if (args[i] instanceof Dict) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i < ii) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
warn("getOperatorList - ignoring operator: " + fn);
|
2016-02-13 02:15:49 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
|
|
|
|
operatorList.addOp(fn, args);
|
|
|
|
|
}
|
2014-05-10 10:41:03 +09:00
|
|
|
|
if (stop) {
|
2016-03-11 22:59:09 +09:00
|
|
|
|
next(deferred);
|
2014-05-10 10:41:03 +09:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
// Some PDFs don't close all restores inside object/form.
|
|
|
|
|
// Closing those for them.
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
closePendingRestoreOPS();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
resolve();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).catch(reason => {
|
Use streams for OperatorList chunking (issue 10023)
*Please note:* The majority of this patch was written by Yury, and it's simply been rebased and slightly extended to prevent issues when dealing with `RenderingCancelledException`.
By leveraging streams this (finally) provides a simple way in which parsing can be aborted on the worker-thread, which will ultimately help save resources.
With this patch worker-thread parsing will *only* be aborted when the document is destroyed, and not when rendering is cancelled. There's a couple of reasons for this:
- The API currently expects the *entire* OperatorList to be extracted, or an Error to occur, once it's been started. Hence additional re-factoring/re-writing of the API code will be necessary to properly support cancelling and re-starting of OperatorList parsing in cases where the `lastChunk` hasn't yet been seen.
- Even with the above addressed, immediately cancelling when encountering a `RenderingCancelledException` will lead to worse performance in e.g. the default viewer. When zooming and/or rotation of the document occurs it's very likely that `cancel` will be (almost) immediately followed by a new `render` call. In that case you'd obviously *not* want to abort parsing on the worker-thread, since then you'd risk throwing away a partially parsed Page and thus be forced to re-parse it again which will regress perceived performance.
- This patch is already *somewhat* risky, given that it touches fundamentally important/critical code, and trying to keep it somewhat small should hopefully reduce the risk of regressions (and simplify reviewing as well).
Time permitting, once this has landed and been in Nightly for awhile, I'll try to work on the remaining points outlined above.
Co-Authored-By: Yury Delendik <ydelendik@mozilla.com>
Co-Authored-By: Jonas Jenwald <jonas.jenwald@gmail.com>
2017-11-10 10:58:43 +09:00
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
if (this.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the OperatorList -- sending unsupported feature
|
|
|
|
|
// notification and allow rendering to continue.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.handler.send("UnsupportedFeature", {
|
|
|
|
|
featureId: UNSUPPORTED_FEATURES.unknown,
|
|
|
|
|
});
|
|
|
|
|
warn(
|
|
|
|
|
`getOperatorList - ignoring errors during "${task.name}" ` +
|
|
|
|
|
`task: "${reason}".`
|
|
|
|
|
);
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
|
|
|
|
|
closePendingRestoreOPS();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw reason;
|
2017-04-30 06:36:43 +09:00
|
|
|
|
});
|
2011-10-25 08:55:23 +09:00
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
getTextContent({
|
|
|
|
|
stream,
|
|
|
|
|
task,
|
|
|
|
|
resources,
|
|
|
|
|
stateManager = null,
|
|
|
|
|
normalizeWhitespace = false,
|
|
|
|
|
combineTextItems = false,
|
|
|
|
|
sink,
|
|
|
|
|
seenStyles = Object.create(null),
|
|
|
|
|
}) {
|
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).
Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.
With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.
*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.
---
[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-04-30 06:13:51 +09:00
|
|
|
|
// Ensure that `resources`/`stateManager` is correctly initialized,
|
|
|
|
|
// even if the provided parameter is e.g. `null`.
|
|
|
|
|
resources = resources || Dict.empty;
|
|
|
|
|
stateManager = stateManager || new StateManager(new TextState());
|
2014-01-18 04:26:00 +09:00
|
|
|
|
|
2015-11-24 00:57:43 +09:00
|
|
|
|
var WhitespaceRegexp = /\s/g;
|
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var textContent = {
|
|
|
|
|
items: [],
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
styles: Object.create(null),
|
2014-04-10 08:44:07 +09:00
|
|
|
|
};
|
2015-11-04 01:12:41 +09:00
|
|
|
|
var textContentItem = {
|
|
|
|
|
initialized: false,
|
|
|
|
|
str: [],
|
|
|
|
|
width: 0,
|
|
|
|
|
height: 0,
|
|
|
|
|
vertical: false,
|
|
|
|
|
lastAdvanceWidth: 0,
|
|
|
|
|
lastAdvanceHeight: 0,
|
|
|
|
|
textAdvanceScale: 0,
|
2015-11-06 23:40:44 +09:00
|
|
|
|
spaceWidth: 0,
|
|
|
|
|
fakeSpaceMin: Infinity,
|
|
|
|
|
fakeMultiSpaceMin: Infinity,
|
|
|
|
|
fakeMultiSpaceMax: -0,
|
|
|
|
|
textRunBreakAllowed: false,
|
2015-11-04 01:12:41 +09:00
|
|
|
|
transform: null,
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
fontName: null,
|
2015-11-04 01:12:41 +09:00
|
|
|
|
};
|
2015-02-14 15:27:17 +09:00
|
|
|
|
var SPACE_FACTOR = 0.3;
|
2012-11-10 06:34:11 +09:00
|
|
|
|
var MULTI_SPACE_FACTOR = 1.5;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
var MULTI_SPACE_FACTOR_MAX = 4;
|
2011-12-11 08:24:54 +09:00
|
|
|
|
|
2013-08-01 03:17:36 +09:00
|
|
|
|
var self = this;
|
|
|
|
|
var xref = this.xref;
|
|
|
|
|
|
2012-09-12 07:10:34 +09:00
|
|
|
|
// The xobj is parsed iff it's needed, e.g. if there is a `DO` cmd.
|
|
|
|
|
var xobjs = null;
|
2017-04-17 21:46:53 +09:00
|
|
|
|
var skipEmptyXObjs = Object.create(null);
|
2011-12-11 08:24:54 +09:00
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
|
2013-04-09 07:14:56 +09:00
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var textState;
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
function ensureTextContentItem() {
|
|
|
|
|
if (textContentItem.initialized) {
|
|
|
|
|
return textContentItem;
|
|
|
|
|
}
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var font = textState.font;
|
2017-04-17 21:46:53 +09:00
|
|
|
|
if (!(font.loadedName in seenStyles)) {
|
|
|
|
|
seenStyles[font.loadedName] = true;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
textContent.styles[font.loadedName] = {
|
|
|
|
|
fontFamily: font.fallbackName,
|
|
|
|
|
ascent: font.ascent,
|
|
|
|
|
descent: font.descent,
|
2019-01-29 22:24:48 +09:00
|
|
|
|
vertical: !!font.vertical,
|
2014-04-10 08:44:07 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textContentItem.fontName = font.loadedName;
|
|
|
|
|
|
|
|
|
|
// 9.4.4 Text Space Details
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var tsm = [
|
|
|
|
|
textState.fontSize * textState.textHScale,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
textState.fontSize,
|
|
|
|
|
0,
|
|
|
|
|
textState.textRise,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
font.isType3Font &&
|
|
|
|
|
textState.fontSize <= 1 &&
|
|
|
|
|
!isArrayEqual(textState.fontMatrix, FONT_IDENTITY_MATRIX)
|
|
|
|
|
) {
|
2019-03-08 20:55:44 +09:00
|
|
|
|
const glyphHeight = font.bbox[3] - font.bbox[1];
|
2015-11-04 01:12:41 +09:00
|
|
|
|
if (glyphHeight > 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
tsm[3] *= glyphHeight * textState.fontMatrix[3];
|
2015-11-04 01:12:41 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var trm = Util.transform(
|
|
|
|
|
textState.ctm,
|
|
|
|
|
Util.transform(textState.textMatrix, tsm)
|
|
|
|
|
);
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textContentItem.transform = trm;
|
|
|
|
|
if (!font.vertical) {
|
|
|
|
|
textContentItem.width = 0;
|
|
|
|
|
textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
|
|
|
|
|
textContentItem.vertical = false;
|
|
|
|
|
} else {
|
|
|
|
|
textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
|
|
|
|
|
textContentItem.height = 0;
|
|
|
|
|
textContentItem.vertical = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var a = textState.textLineMatrix[0];
|
|
|
|
|
var b = textState.textLineMatrix[1];
|
|
|
|
|
var scaleLineX = Math.sqrt(a * a + b * b);
|
|
|
|
|
a = textState.ctm[0];
|
|
|
|
|
b = textState.ctm[1];
|
|
|
|
|
var scaleCtmX = Math.sqrt(a * a + b * b);
|
|
|
|
|
textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
|
|
|
|
|
textContentItem.lastAdvanceWidth = 0;
|
|
|
|
|
textContentItem.lastAdvanceHeight = 0;
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var spaceWidth = (font.spaceWidth / 1000) * textState.fontSize;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (spaceWidth) {
|
|
|
|
|
textContentItem.spaceWidth = spaceWidth;
|
|
|
|
|
textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
|
|
|
|
|
textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
|
|
|
|
|
textContentItem.fakeMultiSpaceMax =
|
|
|
|
|
spaceWidth * MULTI_SPACE_FACTOR_MAX;
|
|
|
|
|
// It's okay for monospace fonts to fake as much space as needed.
|
|
|
|
|
textContentItem.textRunBreakAllowed = !font.isMonospace;
|
|
|
|
|
} else {
|
|
|
|
|
textContentItem.spaceWidth = 0;
|
|
|
|
|
textContentItem.fakeSpaceMin = Infinity;
|
|
|
|
|
textContentItem.fakeMultiSpaceMin = Infinity;
|
|
|
|
|
textContentItem.fakeMultiSpaceMax = 0;
|
|
|
|
|
textContentItem.textRunBreakAllowed = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textContentItem.initialized = true;
|
|
|
|
|
return textContentItem;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-24 00:57:43 +09:00
|
|
|
|
function replaceWhitespace(str) {
|
|
|
|
|
// Replaces all whitespaces with standard spaces (0x20), to avoid
|
|
|
|
|
// alignment issues between the textLayer and the canvas if the text
|
|
|
|
|
// contains e.g. tabs (fixes issue6612.pdf).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var i = 0,
|
|
|
|
|
ii = str.length,
|
|
|
|
|
code;
|
|
|
|
|
while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
|
2015-11-24 00:57:43 +09:00
|
|
|
|
i++;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return i < ii ? str.replace(WhitespaceRegexp, " ") : str;
|
2015-11-24 00:57:43 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
function runBidiTransform(textChunk) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var str = textChunk.str.join("");
|
2016-03-03 09:48:21 +09:00
|
|
|
|
var bidiResult = bidi(str, -1, textChunk.vertical);
|
2015-11-04 01:12:41 +09:00
|
|
|
|
return {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
str: normalizeWhitespace
|
|
|
|
|
? replaceWhitespace(bidiResult.str)
|
|
|
|
|
: bidiResult.str,
|
2015-11-04 01:12:41 +09:00
|
|
|
|
dir: bidiResult.dir,
|
|
|
|
|
width: textChunk.width,
|
|
|
|
|
height: textChunk.height,
|
|
|
|
|
transform: textChunk.transform,
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
fontName: textChunk.fontName,
|
2015-11-04 01:12:41 +09:00
|
|
|
|
};
|
2014-04-10 08:44:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSetFont(fontName, fontRef) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return self
|
|
|
|
|
.loadFont(fontName, fontRef, resources)
|
|
|
|
|
.then(function(translated) {
|
2014-05-20 06:27:54 +09:00
|
|
|
|
textState.font = translated.font;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
textState.fontMatrix =
|
|
|
|
|
translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
});
|
2014-04-10 08:44:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
function buildTextContentItem(chars) {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var font = textState.font;
|
2015-11-04 01:12:41 +09:00
|
|
|
|
var textChunk = ensureTextContentItem();
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var width = 0;
|
|
|
|
|
var height = 0;
|
|
|
|
|
var glyphs = font.charsToGlyphs(chars);
|
|
|
|
|
for (var i = 0; i < glyphs.length; i++) {
|
|
|
|
|
var glyph = glyphs[i];
|
|
|
|
|
var glyphWidth = null;
|
2017-01-19 22:00:36 +09:00
|
|
|
|
if (font.vertical && glyph.vmetric) {
|
|
|
|
|
glyphWidth = glyph.vmetric[0];
|
2014-04-10 08:44:07 +09:00
|
|
|
|
} else {
|
|
|
|
|
glyphWidth = glyph.width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var glyphUnicode = glyph.unicode;
|
2016-01-22 07:10:42 +09:00
|
|
|
|
var NormalizedUnicodes = getNormalizedUnicodes();
|
2014-06-02 19:43:20 +09:00
|
|
|
|
if (NormalizedUnicodes[glyphUnicode] !== undefined) {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
glyphUnicode = NormalizedUnicodes[glyphUnicode];
|
|
|
|
|
}
|
|
|
|
|
glyphUnicode = reverseIfRtl(glyphUnicode);
|
|
|
|
|
|
2015-11-02 23:54:15 +09:00
|
|
|
|
var charSpacing = textState.charSpacing;
|
|
|
|
|
if (glyph.isSpace) {
|
|
|
|
|
var wordSpacing = textState.wordSpacing;
|
|
|
|
|
charSpacing += wordSpacing;
|
|
|
|
|
if (wordSpacing > 0) {
|
2015-11-06 23:40:44 +09:00
|
|
|
|
addFakeSpaces(wordSpacing, textChunk.str);
|
2015-11-02 23:54:15 +09:00
|
|
|
|
}
|
2015-05-10 18:28:15 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var tx = 0;
|
|
|
|
|
var ty = 0;
|
|
|
|
|
if (!font.vertical) {
|
|
|
|
|
var w0 = glyphWidth * textState.fontMatrix[0];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
width += tx;
|
|
|
|
|
} else {
|
|
|
|
|
var w1 = glyphWidth * textState.fontMatrix[0];
|
2015-05-10 18:28:15 +09:00
|
|
|
|
ty = w1 * textState.fontSize + charSpacing;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
height += ty;
|
|
|
|
|
}
|
|
|
|
|
textState.translateTextMatrix(tx, ty);
|
|
|
|
|
|
2014-06-18 22:59:52 +09:00
|
|
|
|
textChunk.str.push(glyphUnicode);
|
2014-04-10 08:44:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!font.vertical) {
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textChunk.lastAdvanceWidth = width;
|
2016-12-07 07:07:16 +09:00
|
|
|
|
textChunk.width += width;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
} else {
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textChunk.lastAdvanceHeight = height;
|
2016-12-07 07:07:16 +09:00
|
|
|
|
textChunk.height += Math.abs(height);
|
2014-04-10 08:44:07 +09:00
|
|
|
|
}
|
2015-11-06 23:40:44 +09:00
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
return textChunk;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-02 23:54:15 +09:00
|
|
|
|
function addFakeSpaces(width, strBuf) {
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (width < textContentItem.fakeSpaceMin) {
|
2015-11-02 23:54:15 +09:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (width < textContentItem.fakeMultiSpaceMin) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
strBuf.push(" ");
|
2015-11-06 23:40:44 +09:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
|
|
|
|
|
while (fakeSpaces-- > 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
strBuf.push(" ");
|
2015-11-02 23:54:15 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
function flushTextContentItem() {
|
|
|
|
|
if (!textContentItem.initialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-12-07 07:07:16 +09:00
|
|
|
|
|
2019-01-29 22:24:48 +09:00
|
|
|
|
// Do final text scaling.
|
|
|
|
|
if (!textContentItem.vertical) {
|
|
|
|
|
textContentItem.width *= textContentItem.textAdvanceScale;
|
|
|
|
|
} else {
|
|
|
|
|
textContentItem.height *= textContentItem.textAdvanceScale;
|
|
|
|
|
}
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textContent.items.push(runBidiTransform(textContentItem));
|
|
|
|
|
|
|
|
|
|
textContentItem.initialized = false;
|
|
|
|
|
textContentItem.str.length = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 21:46:53 +09:00
|
|
|
|
function enqueueChunk() {
|
|
|
|
|
let length = textContent.items.length;
|
|
|
|
|
if (length > 0) {
|
|
|
|
|
sink.enqueue(textContent, length);
|
|
|
|
|
textContent.items = [];
|
|
|
|
|
textContent.styles = Object.create(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-10 10:41:03 +09:00
|
|
|
|
var timeSlotManager = new TimeSlotManager();
|
|
|
|
|
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return new Promise(function promiseBody(resolve, reject) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let next = function(promise) {
|
2017-04-17 21:46:53 +09:00
|
|
|
|
enqueueChunk();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
Promise.all([promise, sink.ready]).then(function() {
|
2016-03-11 22:59:09 +09:00
|
|
|
|
try {
|
|
|
|
|
promiseBody(resolve, reject);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
reject(ex);
|
|
|
|
|
}
|
|
|
|
|
}, reject);
|
|
|
|
|
};
|
2015-10-21 10:50:32 +09:00
|
|
|
|
task.ensureNotTerminated();
|
2014-05-10 10:41:03 +09:00
|
|
|
|
timeSlotManager.reset();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var stop,
|
|
|
|
|
operation = {},
|
|
|
|
|
args = [];
|
2014-08-11 09:23:23 +09:00
|
|
|
|
while (!(stop = timeSlotManager.check())) {
|
|
|
|
|
// The arguments parsed by read() are not used beyond this loop, so
|
|
|
|
|
// we can reuse the same array on every iteration, thus avoiding
|
|
|
|
|
// unnecessary allocations.
|
|
|
|
|
args.length = 0;
|
|
|
|
|
operation.args = args;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (!preprocessor.read(operation)) {
|
2014-08-11 09:23:23 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState = stateManager.state;
|
2018-09-06 01:01:33 +09:00
|
|
|
|
var fn = operation.fn;
|
2014-08-11 09:23:23 +09:00
|
|
|
|
args = operation.args;
|
2016-05-15 05:13:12 +09:00
|
|
|
|
var advance, diff;
|
2014-08-11 09:23:23 +09:00
|
|
|
|
|
2018-09-06 01:01:33 +09:00
|
|
|
|
switch (fn | 0) {
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setFont:
|
2016-06-01 06:01:35 +09:00
|
|
|
|
// Optimization to ignore multiple identical Tf commands.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontNameArg = args[0].name,
|
|
|
|
|
fontSizeArg = args[1];
|
|
|
|
|
if (
|
|
|
|
|
textState.font &&
|
|
|
|
|
fontNameArg === textState.fontName &&
|
|
|
|
|
fontSizeArg === textState.fontSize
|
|
|
|
|
) {
|
2016-06-01 06:01:35 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2016-06-01 06:01:35 +09:00
|
|
|
|
textState.fontName = fontNameArg;
|
|
|
|
|
textState.fontSize = fontSizeArg;
|
|
|
|
|
next(handleSetFont(fontNameArg, null));
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setTextRise:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.textRise = args[0];
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setHScale:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.textHScale = args[0] / 100;
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setLeading:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.leading = args[0];
|
|
|
|
|
break;
|
|
|
|
|
case OPS.moveText:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
// Optimization to treat same line movement as advance
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var isSameTextLine = !textState.font
|
|
|
|
|
? false
|
|
|
|
|
: (textState.font.vertical ? args[0] : args[1]) === 0;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
advance = args[0] - args[1];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
combineTextItems &&
|
|
|
|
|
isSameTextLine &&
|
|
|
|
|
textContentItem.initialized &&
|
|
|
|
|
advance > 0 &&
|
|
|
|
|
advance <= textContentItem.fakeMultiSpaceMax
|
|
|
|
|
) {
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textState.translateTextLineMatrix(args[0], args[1]);
|
|
|
|
|
textContentItem.width +=
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
args[0] - textContentItem.lastAdvanceWidth;
|
2015-11-04 01:12:41 +09:00
|
|
|
|
textContentItem.height +=
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
args[1] - textContentItem.lastAdvanceHeight;
|
|
|
|
|
diff =
|
|
|
|
|
args[0] -
|
|
|
|
|
textContentItem.lastAdvanceWidth -
|
2015-11-04 01:12:41 +09:00
|
|
|
|
(args[1] - textContentItem.lastAdvanceHeight);
|
2015-11-06 23:40:44 +09:00
|
|
|
|
addFakeSpaces(diff, textContentItem.str);
|
2015-11-04 01:12:41 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.translateTextLineMatrix(args[0], args[1]);
|
|
|
|
|
textState.textMatrix = textState.textLineMatrix.slice();
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setLeadingMoveText:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.leading = -args[1];
|
|
|
|
|
textState.translateTextLineMatrix(args[0], args[1]);
|
|
|
|
|
textState.textMatrix = textState.textLineMatrix.slice();
|
|
|
|
|
break;
|
|
|
|
|
case OPS.nextLine:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.carriageReturn();
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setTextMatrix:
|
2016-05-15 05:13:12 +09:00
|
|
|
|
// Optimization to treat same line movement as advance.
|
|
|
|
|
advance = textState.calcTextLineMatrixAdvance(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
args[0],
|
|
|
|
|
args[1],
|
|
|
|
|
args[2],
|
|
|
|
|
args[3],
|
|
|
|
|
args[4],
|
|
|
|
|
args[5]
|
|
|
|
|
);
|
|
|
|
|
if (
|
|
|
|
|
combineTextItems &&
|
|
|
|
|
advance !== null &&
|
|
|
|
|
textContentItem.initialized &&
|
|
|
|
|
advance.value > 0 &&
|
|
|
|
|
advance.value <= textContentItem.fakeMultiSpaceMax
|
|
|
|
|
) {
|
|
|
|
|
textState.translateTextLineMatrix(
|
|
|
|
|
advance.width,
|
|
|
|
|
advance.height
|
|
|
|
|
);
|
2016-05-15 05:13:12 +09:00
|
|
|
|
textContentItem.width +=
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
advance.width - textContentItem.lastAdvanceWidth;
|
2016-05-15 05:13:12 +09:00
|
|
|
|
textContentItem.height +=
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
advance.height - textContentItem.lastAdvanceHeight;
|
|
|
|
|
diff =
|
|
|
|
|
advance.width -
|
|
|
|
|
textContentItem.lastAdvanceWidth -
|
2016-05-15 05:13:12 +09:00
|
|
|
|
(advance.height - textContentItem.lastAdvanceHeight);
|
|
|
|
|
addFakeSpaces(diff, textContentItem.str);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
textState.setTextMatrix(
|
|
|
|
|
args[0],
|
|
|
|
|
args[1],
|
|
|
|
|
args[2],
|
|
|
|
|
args[3],
|
|
|
|
|
args[4],
|
|
|
|
|
args[5]
|
|
|
|
|
);
|
|
|
|
|
textState.setTextLineMatrix(
|
|
|
|
|
args[0],
|
|
|
|
|
args[1],
|
|
|
|
|
args[2],
|
|
|
|
|
args[3],
|
|
|
|
|
args[4],
|
|
|
|
|
args[5]
|
|
|
|
|
);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.setCharSpacing:
|
|
|
|
|
textState.charSpacing = args[0];
|
|
|
|
|
break;
|
|
|
|
|
case OPS.setWordSpacing:
|
|
|
|
|
textState.wordSpacing = args[0];
|
|
|
|
|
break;
|
|
|
|
|
case OPS.beginText:
|
2018-09-06 01:01:33 +09:00
|
|
|
|
flushTextContentItem();
|
|
|
|
|
textState.textMatrix = IDENTITY_MATRIX.slice();
|
|
|
|
|
textState.textLineMatrix = IDENTITY_MATRIX.slice();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.showSpacedText:
|
|
|
|
|
var items = args[0];
|
|
|
|
|
var offset;
|
|
|
|
|
for (var j = 0, jj = items.length; j < jj; j++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (typeof items[j] === "string") {
|
2015-11-04 01:12:41 +09:00
|
|
|
|
buildTextContentItem(items[j]);
|
2016-10-13 20:47:17 +09:00
|
|
|
|
} else if (isNum(items[j])) {
|
2015-11-06 23:40:44 +09:00
|
|
|
|
ensureTextContentItem();
|
|
|
|
|
|
2015-08-28 20:42:01 +09:00
|
|
|
|
// PDF Specification 5.3.2 states:
|
|
|
|
|
// The number is expressed in thousandths of a unit of text
|
|
|
|
|
// space.
|
|
|
|
|
// This amount is subtracted from the current horizontal or
|
|
|
|
|
// vertical coordinate, depending on the writing mode.
|
|
|
|
|
// In the default coordinate system, a positive adjustment
|
|
|
|
|
// has the effect of moving the next glyph painted either to
|
|
|
|
|
// the left or down by the given amount.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
advance = (items[j] * textState.fontSize) / 1000;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
var breakTextRun = false;
|
2015-08-28 20:42:01 +09:00
|
|
|
|
if (textState.font.vertical) {
|
2016-12-07 07:07:16 +09:00
|
|
|
|
offset = advance;
|
|
|
|
|
textState.translateTextMatrix(0, offset);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
breakTextRun =
|
|
|
|
|
textContentItem.textRunBreakAllowed &&
|
|
|
|
|
advance > textContentItem.fakeMultiSpaceMax;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (!breakTextRun) {
|
|
|
|
|
// Value needs to be added to height to paint down.
|
|
|
|
|
textContentItem.height += offset;
|
|
|
|
|
}
|
2015-08-28 20:42:01 +09:00
|
|
|
|
} else {
|
2015-11-06 23:40:44 +09:00
|
|
|
|
advance = -advance;
|
2016-12-07 07:07:16 +09:00
|
|
|
|
offset = advance * textState.textHScale;
|
|
|
|
|
textState.translateTextMatrix(offset, 0);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
breakTextRun =
|
|
|
|
|
textContentItem.textRunBreakAllowed &&
|
|
|
|
|
advance > textContentItem.fakeMultiSpaceMax;
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (!breakTextRun) {
|
|
|
|
|
// Value needs to be subtracted from width to paint left.
|
|
|
|
|
textContentItem.width += offset;
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
2015-11-06 23:40:44 +09:00
|
|
|
|
if (breakTextRun) {
|
|
|
|
|
flushTextContentItem();
|
|
|
|
|
} else if (advance > 0) {
|
2015-11-04 01:12:41 +09:00
|
|
|
|
addFakeSpaces(advance, textContentItem.str);
|
2012-09-15 02:53:06 +09:00
|
|
|
|
}
|
2013-06-05 09:57:52 +09:00
|
|
|
|
}
|
2013-08-01 03:17:36 +09:00
|
|
|
|
}
|
2014-03-23 03:15:51 +09:00
|
|
|
|
break;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.showText:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
buildTextContentItem(args[0]);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.nextLineShowText:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.carriageReturn();
|
2015-11-04 01:12:41 +09:00
|
|
|
|
buildTextContentItem(args[0]);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.nextLineSetSpacingShowText:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
textState.wordSpacing = args[0];
|
|
|
|
|
textState.charSpacing = args[1];
|
|
|
|
|
textState.carriageReturn();
|
2015-11-04 01:12:41 +09:00
|
|
|
|
buildTextContentItem(args[2]);
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.paintXObject:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
if (!xobjs) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
xobjs = resources.get("XObject") || Dict.empty;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
2012-09-12 07:10:34 +09:00
|
|
|
|
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var name = args[0].name;
|
2017-09-17 20:35:18 +09:00
|
|
|
|
if (name && skipEmptyXObjs[name] !== undefined) {
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
2014-02-24 23:00:08 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
next(
|
|
|
|
|
new Promise(function(resolveXObject, rejectXObject) {
|
|
|
|
|
if (!name) {
|
|
|
|
|
throw new FormatError(
|
|
|
|
|
"XObject must be referred to by name."
|
|
|
|
|
);
|
|
|
|
|
}
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let xobj = xobjs.get(name);
|
|
|
|
|
if (!xobj) {
|
|
|
|
|
resolveXObject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isStream(xobj)) {
|
|
|
|
|
throw new FormatError("XObject should be a stream");
|
|
|
|
|
}
|
2014-04-10 08:44:07 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let type = xobj.dict.get("Subtype");
|
|
|
|
|
if (!isName(type)) {
|
|
|
|
|
throw new FormatError("XObject should have a Name subtype");
|
|
|
|
|
}
|
2017-09-17 20:35:18 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type.name !== "Form") {
|
|
|
|
|
skipEmptyXObjs[name] = true;
|
|
|
|
|
resolveXObject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-17 20:35:18 +09:00
|
|
|
|
|
2019-12-26 04:03:46 +09:00
|
|
|
|
// Use a new `StateManager` to prevent incorrect positioning
|
|
|
|
|
// of textItems *after* the Form XObject, since errors in the
|
|
|
|
|
// data can otherwise prevent `restore` operators from
|
|
|
|
|
// executing.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
// NOTE: Only an issue when `options.ignoreErrors === true`.
|
|
|
|
|
let currentState = stateManager.state.clone();
|
|
|
|
|
let xObjStateManager = new StateManager(currentState);
|
2017-09-17 20:35:18 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let matrix = xobj.dict.getArray("Matrix");
|
|
|
|
|
if (Array.isArray(matrix) && matrix.length === 6) {
|
|
|
|
|
xObjStateManager.transform(matrix);
|
|
|
|
|
}
|
2017-09-17 20:35:18 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
// Enqueue the `textContent` chunk before parsing the /Form
|
|
|
|
|
// XObject.
|
|
|
|
|
enqueueChunk();
|
|
|
|
|
let sinkWrapper = {
|
|
|
|
|
enqueueInvoked: false,
|
|
|
|
|
|
|
|
|
|
enqueue(chunk, size) {
|
|
|
|
|
this.enqueueInvoked = true;
|
|
|
|
|
sink.enqueue(chunk, size);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get desiredSize() {
|
|
|
|
|
return sink.desiredSize;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get ready() {
|
|
|
|
|
return sink.ready;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
|
.getTextContent({
|
|
|
|
|
stream: xobj,
|
|
|
|
|
task,
|
|
|
|
|
resources: xobj.dict.get("Resources") || resources,
|
|
|
|
|
stateManager: xObjStateManager,
|
|
|
|
|
normalizeWhitespace,
|
|
|
|
|
combineTextItems,
|
|
|
|
|
sink: sinkWrapper,
|
|
|
|
|
seenStyles,
|
|
|
|
|
})
|
|
|
|
|
.then(function() {
|
|
|
|
|
if (!sinkWrapper.enqueueInvoked) {
|
|
|
|
|
skipEmptyXObjs[name] = true;
|
|
|
|
|
}
|
|
|
|
|
resolveXObject();
|
|
|
|
|
}, rejectXObject);
|
|
|
|
|
}).catch(function(reason) {
|
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return;
|
2017-09-17 20:35:18 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (self.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the XObject -- allow text-extraction to
|
|
|
|
|
// continue.
|
|
|
|
|
warn(`getTextContent - ignoring XObject: "${reason}".`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw reason;
|
|
|
|
|
})
|
|
|
|
|
);
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
case OPS.setGState:
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2014-05-10 10:21:15 +09:00
|
|
|
|
var dictName = args[0];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var extGState = resources.get("ExtGState");
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2016-06-01 06:40:19 +09:00
|
|
|
|
if (!isDict(extGState) || !isName(dictName)) {
|
2014-05-10 10:21:15 +09:00
|
|
|
|
break;
|
2012-09-15 11:52:37 +09:00
|
|
|
|
}
|
2016-06-01 06:40:19 +09:00
|
|
|
|
var gState = extGState.get(dictName.name);
|
|
|
|
|
if (!isDict(gState)) {
|
|
|
|
|
break;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var gStateFont = gState.get("Font");
|
2016-06-01 06:40:19 +09:00
|
|
|
|
if (gStateFont) {
|
2016-06-01 06:01:35 +09:00
|
|
|
|
textState.fontName = null;
|
2016-06-01 06:40:19 +09:00
|
|
|
|
textState.fontSize = gStateFont[1];
|
|
|
|
|
next(handleSetFont(null, gStateFont[0]));
|
2016-03-11 22:59:09 +09:00
|
|
|
|
return;
|
2014-05-10 10:21:15 +09:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
} // switch
|
2017-04-17 21:46:53 +09:00
|
|
|
|
if (textContent.items.length >= sink.desiredSize) {
|
|
|
|
|
// Wait for ready, if we reach highWaterMark.
|
|
|
|
|
stop = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-10 10:21:15 +09:00
|
|
|
|
} // while
|
2014-05-10 10:41:03 +09:00
|
|
|
|
if (stop) {
|
2016-03-11 22:59:09 +09:00
|
|
|
|
next(deferred);
|
2014-05-10 10:41:03 +09:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-11-04 01:12:41 +09:00
|
|
|
|
flushTextContentItem();
|
2017-04-17 21:46:53 +09:00
|
|
|
|
enqueueChunk();
|
|
|
|
|
resolve();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).catch(reason => {
|
2017-08-04 06:36:46 +09:00
|
|
|
|
if (reason instanceof AbortException) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
if (this.options.ignoreErrors) {
|
|
|
|
|
// Error(s) in the TextContent -- allow text-extraction to continue.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
warn(
|
|
|
|
|
`getTextContent - ignoring errors during "${task.name}" ` +
|
|
|
|
|
`task: "${reason}".`
|
|
|
|
|
);
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
|
|
|
|
|
flushTextContentItem();
|
2017-04-17 21:46:53 +09:00
|
|
|
|
enqueueChunk();
|
|
|
|
|
return;
|
[api-minor] Always allow e.g. rendering to continue even if there are errors, and add a `stopAtErrors` parameter to `getDocument` to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.
NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.
Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-02-19 22:03:08 +09:00
|
|
|
|
}
|
|
|
|
|
throw reason;
|
2017-04-30 06:36:43 +09:00
|
|
|
|
});
|
2011-12-11 08:24:54 +09:00
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
extractDataStructures: function PartialEvaluator_extractDataStructures(
|
|
|
|
|
dict,
|
|
|
|
|
baseDict,
|
|
|
|
|
properties
|
|
|
|
|
) {
|
|
|
|
|
let xref = this.xref,
|
|
|
|
|
cidToGidBytes;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
// 9.10.2
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
|
|
|
|
var toUnicodePromise = toUnicode
|
|
|
|
|
? this.readToUnicode(toUnicode)
|
|
|
|
|
: Promise.resolve(undefined);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (properties.composite) {
|
|
|
|
|
// CIDSystemInfo helps to match CID to glyphs
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var cidSystemInfo = dict.get("CIDSystemInfo");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
if (isDict(cidSystemInfo)) {
|
|
|
|
|
properties.cidSystemInfo = {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
registry: stringToPDFString(cidSystemInfo.get("Registry")),
|
|
|
|
|
ordering: stringToPDFString(cidSystemInfo.get("Ordering")),
|
|
|
|
|
supplement: cidSystemInfo.get("Supplement"),
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var cidToGidMap = dict.get("CIDToGIDMap");
|
2014-03-23 03:15:51 +09:00
|
|
|
|
if (isStream(cidToGidMap)) {
|
2019-05-08 00:44:37 +09:00
|
|
|
|
cidToGidBytes = cidToGidMap.getBytes();
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-11 01:51:06 +09:00
|
|
|
|
// Based on 9.6.6 of the spec the encoding can come from multiple places
|
2014-02-12 03:27:09 +09:00
|
|
|
|
// and depends on the font type. The base encoding and differences are
|
|
|
|
|
// read here, but the encoding that is actually used is chosen during
|
|
|
|
|
// glyph mapping in the font.
|
|
|
|
|
// TODO: Loading the built in encoding in the font would allow the
|
|
|
|
|
// differences to be merged in here not require us to hold on to it.
|
2011-10-29 10:38:31 +09:00
|
|
|
|
var differences = [];
|
2014-02-12 03:27:09 +09:00
|
|
|
|
var baseEncodingName = null;
|
2014-04-08 06:42:54 +09:00
|
|
|
|
var encoding;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (dict.has("Encoding")) {
|
|
|
|
|
encoding = dict.get("Encoding");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
if (isDict(encoding)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
baseEncodingName = encoding.get("BaseEncoding");
|
|
|
|
|
baseEncodingName = isName(baseEncodingName)
|
|
|
|
|
? baseEncodingName.name
|
|
|
|
|
: null;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
// Load the differences between the base and original
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (encoding.has("Differences")) {
|
|
|
|
|
var diffEncoding = encoding.get("Differences");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
var index = 0;
|
2011-11-03 04:08:19 +09:00
|
|
|
|
for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
|
2016-01-30 02:22:25 +09:00
|
|
|
|
var data = xref.fetchIfRef(diffEncoding[j]);
|
2014-03-23 03:15:51 +09:00
|
|
|
|
if (isNum(data)) {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
index = data;
|
2015-03-09 22:36:45 +09:00
|
|
|
|
} else if (isName(data)) {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
differences[index++] = data.name;
|
2015-03-09 22:36:45 +09:00
|
|
|
|
} else {
|
2017-06-29 05:51:31 +09:00
|
|
|
|
throw new FormatError(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
`Invalid entry in 'Differences' array: ${data}`
|
|
|
|
|
);
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (isName(encoding)) {
|
2014-02-12 03:27:09 +09:00
|
|
|
|
baseEncodingName = encoding.name;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("Encoding is not a Name nor a Dict");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
// According to table 114 if the encoding is a named encoding it must be
|
|
|
|
|
// one of these predefined encodings.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
baseEncodingName !== "MacRomanEncoding" &&
|
|
|
|
|
baseEncodingName !== "MacExpertEncoding" &&
|
|
|
|
|
baseEncodingName !== "WinAnsiEncoding"
|
|
|
|
|
) {
|
2014-02-12 03:27:09 +09:00
|
|
|
|
baseEncodingName = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (baseEncodingName) {
|
2016-01-22 06:18:46 +09:00
|
|
|
|
properties.defaultEncoding = getEncoding(baseEncodingName).slice();
|
2014-02-12 03:27:09 +09:00
|
|
|
|
} else {
|
Fallback to the `StandardEncoding` for Nonsymbolic fonts without `/Encoding` entry (issue 7580)
Even though this patch passes all tests (unit/font/reference) locally, including the new ones that I added in PR 7621, I'm still a bit nervous about modifying the code that choose the fallback encoding for fonts without an `/Encoding` entry.
Note that over the years this code has been changed on a number of occasions, see a possibly incomplete [list here], to deal with various cases of incorrect font data.
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1904184, it seems that we should fallback to the `StandardEncoding` for Nonsymbolic fonts.
There's obviously a risk that fixing this particular issue *could* break other PDF files for which we don't have tests. However I've tried to change the logic as little as possible in this patch, to hopefully reduce possible breakage.
Based on debugging numerous font issue, it seems that a lot of fonts actually set the Symbolic flag, even when they are in fact *not* Symbolic. Fonts actually marked as Nonsymbolic seem to be somewhat less common, which I hope should reduce the risk of the patch somewhat.
Fixes 7580.
2016-09-13 20:43:23 +09:00
|
|
|
|
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
|
|
|
|
|
var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
|
|
|
|
|
// According to "Table 114" in section "9.6.6.1 General" (under
|
|
|
|
|
// "9.6.6 Character Encoding") of the PDF specification, a Nonsymbolic
|
|
|
|
|
// font should use the `StandardEncoding` if no encoding is specified.
|
|
|
|
|
encoding = StandardEncoding;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (properties.type === "TrueType" && !isNonsymbolicFont) {
|
Fallback to the `StandardEncoding` for Nonsymbolic fonts without `/Encoding` entry (issue 7580)
Even though this patch passes all tests (unit/font/reference) locally, including the new ones that I added in PR 7621, I'm still a bit nervous about modifying the code that choose the fallback encoding for fonts without an `/Encoding` entry.
Note that over the years this code has been changed on a number of occasions, see a possibly incomplete [list here], to deal with various cases of incorrect font data.
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1904184, it seems that we should fallback to the `StandardEncoding` for Nonsymbolic fonts.
There's obviously a risk that fixing this particular issue *could* break other PDF files for which we don't have tests. However I've tried to change the logic as little as possible in this patch, to hopefully reduce possible breakage.
Based on debugging numerous font issue, it seems that a lot of fonts actually set the Symbolic flag, even when they are in fact *not* Symbolic. Fonts actually marked as Nonsymbolic seem to be somewhat less common, which I hope should reduce the risk of the patch somewhat.
Fixes 7580.
2016-09-13 20:43:23 +09:00
|
|
|
|
encoding = WinAnsiEncoding;
|
|
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
// The Symbolic attribute can be misused for regular fonts
|
|
|
|
|
// Heuristic: we have to check if the font is a standard one also
|
Fallback to the `StandardEncoding` for Nonsymbolic fonts without `/Encoding` entry (issue 7580)
Even though this patch passes all tests (unit/font/reference) locally, including the new ones that I added in PR 7621, I'm still a bit nervous about modifying the code that choose the fallback encoding for fonts without an `/Encoding` entry.
Note that over the years this code has been changed on a number of occasions, see a possibly incomplete [list here], to deal with various cases of incorrect font data.
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1904184, it seems that we should fallback to the `StandardEncoding` for Nonsymbolic fonts.
There's obviously a risk that fixing this particular issue *could* break other PDF files for which we don't have tests. However I've tried to change the logic as little as possible in this patch, to hopefully reduce possible breakage.
Based on debugging numerous font issue, it seems that a lot of fonts actually set the Symbolic flag, even when they are in fact *not* Symbolic. Fonts actually marked as Nonsymbolic seem to be somewhat less common, which I hope should reduce the risk of the patch somewhat.
Fixes 7580.
2016-09-13 20:43:23 +09:00
|
|
|
|
if (isSymbolicFont) {
|
2016-01-22 06:18:46 +09:00
|
|
|
|
encoding = MacRomanEncoding;
|
2014-09-01 10:22:24 +09:00
|
|
|
|
if (!properties.file) {
|
|
|
|
|
if (/Symbol/i.test(properties.name)) {
|
2016-01-22 06:18:46 +09:00
|
|
|
|
encoding = SymbolSetEncoding;
|
2014-09-01 10:22:24 +09:00
|
|
|
|
} else if (/Dingbats/i.test(properties.name)) {
|
2016-01-22 06:18:46 +09:00
|
|
|
|
encoding = ZapfDingbatsEncoding;
|
2014-09-01 10:22:24 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
}
|
|
|
|
|
properties.defaultEncoding = encoding;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2011-11-25 00:38:09 +09:00
|
|
|
|
|
2011-10-29 10:38:31 +09:00
|
|
|
|
properties.differences = differences;
|
2014-02-12 03:27:09 +09:00
|
|
|
|
properties.baseEncodingName = baseEncodingName;
|
For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.
Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
2016-08-18 01:33:06 +09:00
|
|
|
|
properties.hasEncoding = !!baseEncodingName || differences.length > 0;
|
2014-02-12 03:27:09 +09:00
|
|
|
|
properties.dict = dict;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return toUnicodePromise
|
|
|
|
|
.then(toUnicode => {
|
|
|
|
|
properties.toUnicode = toUnicode;
|
|
|
|
|
return this.buildToUnicode(properties);
|
|
|
|
|
})
|
|
|
|
|
.then(toUnicode => {
|
|
|
|
|
properties.toUnicode = toUnicode;
|
|
|
|
|
if (cidToGidBytes) {
|
|
|
|
|
properties.cidToGidMap = this.readCidToGidMap(
|
|
|
|
|
cidToGidBytes,
|
|
|
|
|
toUnicode
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return properties;
|
|
|
|
|
});
|
2011-10-29 10:38:31 +09:00
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
2017-11-26 20:53:06 +09:00
|
|
|
|
/**
|
|
|
|
|
* @returns {ToUnicodeMap}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2019-09-30 06:50:58 +09:00
|
|
|
|
_buildSimpleFontToUnicode(properties, forceGlyphs = false) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
assert(!properties.composite, "Must be a simple font.");
|
2017-11-26 20:53:06 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let toUnicode = [],
|
|
|
|
|
charcode,
|
|
|
|
|
glyphName;
|
2017-11-26 20:53:06 +09:00
|
|
|
|
let encoding = properties.defaultEncoding.slice();
|
|
|
|
|
let baseEncodingName = properties.baseEncodingName;
|
|
|
|
|
// Merge in the differences array.
|
|
|
|
|
let differences = properties.differences;
|
|
|
|
|
for (charcode in differences) {
|
|
|
|
|
glyphName = differences[charcode];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (glyphName === ".notdef") {
|
2017-11-26 20:53:06 +09:00
|
|
|
|
// Skip .notdef to prevent rendering errors, e.g. boxes appearing
|
|
|
|
|
// where there should be spaces (fixes issue5256.pdf).
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
encoding[charcode] = glyphName;
|
|
|
|
|
}
|
|
|
|
|
let glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
for (charcode in encoding) {
|
|
|
|
|
// a) Map the character code to a character name.
|
|
|
|
|
glyphName = encoding[charcode];
|
|
|
|
|
// b) Look up the character name in the Adobe Glyph List (see the
|
|
|
|
|
// Bibliography) to obtain the corresponding Unicode value.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (glyphName === "") {
|
2017-11-26 20:53:06 +09:00
|
|
|
|
continue;
|
|
|
|
|
} else if (glyphsUnicodeMap[glyphName] === undefined) {
|
|
|
|
|
// (undocumented) c) Few heuristics to recognize unknown glyphs
|
|
|
|
|
// NOTE: Adobe Reader does not do this step, but OSX Preview does
|
|
|
|
|
let code = 0;
|
|
|
|
|
switch (glyphName[0]) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "G": // Gxx glyph
|
2017-11-26 20:53:06 +09:00
|
|
|
|
if (glyphName.length === 3) {
|
2018-09-28 18:41:07 +09:00
|
|
|
|
code = parseInt(glyphName.substring(1), 16);
|
2017-11-26 20:53:06 +09:00
|
|
|
|
}
|
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "g": // g00xx glyph
|
2017-11-26 20:53:06 +09:00
|
|
|
|
if (glyphName.length === 5) {
|
2018-09-28 18:41:07 +09:00
|
|
|
|
code = parseInt(glyphName.substring(1), 16);
|
2017-11-26 20:53:06 +09:00
|
|
|
|
}
|
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
case "C": // Cdd{d} glyph
|
|
|
|
|
case "c": // cdd{d} glyph
|
2019-09-30 06:50:58 +09:00
|
|
|
|
if (glyphName.length >= 3 && glyphName.length <= 4) {
|
|
|
|
|
const codeStr = glyphName.substring(1);
|
|
|
|
|
|
|
|
|
|
if (forceGlyphs) {
|
|
|
|
|
code = parseInt(codeStr, 16);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// Normally the Cdd{d}/cdd{d} glyphName format will contain
|
|
|
|
|
// regular, i.e. base 10, charCodes (see issue4550.pdf)...
|
|
|
|
|
code = +codeStr;
|
|
|
|
|
|
|
|
|
|
// ... however some PDF generators violate that assumption by
|
|
|
|
|
// containing glyph, i.e. base 16, codes instead.
|
|
|
|
|
// In that case we need to re-parse the *entire* encoding to
|
|
|
|
|
// prevent broken text-selection (fixes issue9655_reduced.pdf).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
Number.isNaN(code) &&
|
|
|
|
|
Number.isInteger(parseInt(codeStr, 16))
|
|
|
|
|
) {
|
|
|
|
|
return this._buildSimpleFontToUnicode(
|
|
|
|
|
properties,
|
|
|
|
|
/* forceGlyphs */ true
|
|
|
|
|
);
|
2019-09-30 06:50:58 +09:00
|
|
|
|
}
|
2017-11-26 20:53:06 +09:00
|
|
|
|
}
|
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
default:
|
|
|
|
|
// 'uniXXXX'/'uXXXX{XX}' glyphs
|
2017-11-26 20:53:06 +09:00
|
|
|
|
let unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
|
|
|
|
|
if (unicode !== -1) {
|
|
|
|
|
code = unicode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (code) {
|
|
|
|
|
// If `baseEncodingName` is one the predefined encodings, and `code`
|
|
|
|
|
// equals `charcode`, using the glyph defined in the baseEncoding
|
|
|
|
|
// seems to yield a better `toUnicode` mapping (fixes issue 5070).
|
|
|
|
|
if (baseEncodingName && code === +charcode) {
|
|
|
|
|
let baseEncoding = getEncoding(baseEncodingName);
|
|
|
|
|
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
toUnicode[charcode] = String.fromCharCode(
|
|
|
|
|
glyphsUnicodeMap[glyphName]
|
|
|
|
|
);
|
2017-11-26 20:53:06 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-09 15:53:16 +09:00
|
|
|
|
toUnicode[charcode] = String.fromCodePoint(code);
|
2017-11-26 20:53:06 +09:00
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
|
|
|
|
|
}
|
|
|
|
|
return new ToUnicodeMap(toUnicode);
|
|
|
|
|
},
|
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
/**
|
|
|
|
|
* Builds a char code to unicode map based on section 9.10 of the spec.
|
|
|
|
|
* @param {Object} properties Font properties object.
|
2019-10-13 01:14:29 +09:00
|
|
|
|
* @returns {Promise} A Promise that is resolved with a
|
2016-04-08 19:14:05 +09:00
|
|
|
|
* {ToUnicodeMap|IdentityToUnicodeMap} object.
|
2016-02-29 01:20:29 +09:00
|
|
|
|
*/
|
2017-11-26 20:53:06 +09:00
|
|
|
|
buildToUnicode(properties) {
|
For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.
Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
2016-08-18 01:33:06 +09:00
|
|
|
|
properties.hasIncludedToUnicodeMap =
|
|
|
|
|
!!properties.toUnicode && properties.toUnicode.length > 0;
|
2017-11-26 20:53:06 +09:00
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// Section 9.10.2 Mapping Character Codes to Unicode Values
|
For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.
Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
2016-08-18 01:33:06 +09:00
|
|
|
|
if (properties.hasIncludedToUnicodeMap) {
|
Build a fallback `ToUnicode` map for simple fonts (issue 8229)
In some fonts, the included `ToUnicode` data is incomplete causing text-selection to not work properly. For simple fonts that contain encoding data, we can manually build a `ToUnicode` map to attempt to improve things.
Please note that since we're currently using the `ToUnicode` data during glyph mapping, in an attempt to avoid rendering regressions, I purposely didn't want to amend to original `ToUnicode` data for this text-selection edge-case.
Instead, I opted for the current solution, which will (hopefully) give slightly better text-extraction results in PDF file with incomplete `ToUnicode` data.
According to the PDF specification, see [section 9.10.2](http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1873172):
> A conforming reader can use these methods, in the priority given, to map a character code to a Unicode value.
> ...
Reading that paragraph literally, it doesn't seem too unreasonable to use *different* methods for different charcodes.
Fixes 8229.
2017-11-26 21:29:43 +09:00
|
|
|
|
// Some fonts contain incomplete ToUnicode data, causing issues with
|
|
|
|
|
// text-extraction. For simple fonts, containing encoding information,
|
|
|
|
|
// use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
|
|
|
|
|
if (!properties.composite && properties.hasEncoding) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
properties.fallbackToUnicode = this._buildSimpleFontToUnicode(
|
|
|
|
|
properties
|
|
|
|
|
);
|
Build a fallback `ToUnicode` map for simple fonts (issue 8229)
In some fonts, the included `ToUnicode` data is incomplete causing text-selection to not work properly. For simple fonts that contain encoding data, we can manually build a `ToUnicode` map to attempt to improve things.
Please note that since we're currently using the `ToUnicode` data during glyph mapping, in an attempt to avoid rendering regressions, I purposely didn't want to amend to original `ToUnicode` data for this text-selection edge-case.
Instead, I opted for the current solution, which will (hopefully) give slightly better text-extraction results in PDF file with incomplete `ToUnicode` data.
According to the PDF specification, see [section 9.10.2](http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1873172):
> A conforming reader can use these methods, in the priority given, to map a character code to a Unicode value.
> ...
Reading that paragraph literally, it doesn't seem too unreasonable to use *different* methods for different charcodes.
Fixes 8229.
2017-11-26 21:29:43 +09:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
return Promise.resolve(properties.toUnicode);
|
|
|
|
|
}
|
2017-11-26 20:53:06 +09:00
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// According to the spec if the font is a simple font we should only map
|
|
|
|
|
// to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
|
|
|
|
|
// the differences array only contains adobe standard or symbol set names,
|
2017-11-26 20:53:06 +09:00
|
|
|
|
// in pratice it seems better to always try to create a toUnicode map
|
|
|
|
|
// based of the default encoding.
|
2016-02-29 01:20:29 +09:00
|
|
|
|
if (!properties.composite /* is simple font */) {
|
2017-11-26 20:53:06 +09:00
|
|
|
|
return Promise.resolve(this._buildSimpleFontToUnicode(properties));
|
2016-02-29 01:20:29 +09:00
|
|
|
|
}
|
2017-11-26 20:53:06 +09:00
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// If the font is a composite font that uses one of the predefined CMaps
|
|
|
|
|
// listed in Table 118 (except Identity–H and Identity–V) or whose
|
|
|
|
|
// descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
|
|
|
|
|
// Adobe-Korea1 character collection:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
properties.composite &&
|
|
|
|
|
((properties.cMap.builtInCMap &&
|
|
|
|
|
!(properties.cMap instanceof IdentityCMap)) ||
|
|
|
|
|
(properties.cidSystemInfo.registry === "Adobe" &&
|
|
|
|
|
(properties.cidSystemInfo.ordering === "GB1" ||
|
|
|
|
|
properties.cidSystemInfo.ordering === "CNS1" ||
|
|
|
|
|
properties.cidSystemInfo.ordering === "Japan1" ||
|
|
|
|
|
properties.cidSystemInfo.ordering === "Korea1")))
|
|
|
|
|
) {
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// Then:
|
|
|
|
|
// a) Map the character code to a character identifier (CID) according
|
|
|
|
|
// to the font’s CMap.
|
|
|
|
|
// b) Obtain the registry and ordering of the character collection used
|
|
|
|
|
// by the font’s CMap (for example, Adobe and Japan1) from its
|
|
|
|
|
// CIDSystemInfo dictionary.
|
2017-11-26 20:53:06 +09:00
|
|
|
|
let registry = properties.cidSystemInfo.registry;
|
|
|
|
|
let ordering = properties.cidSystemInfo.ordering;
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// c) Construct a second CMap name by concatenating the registry and
|
|
|
|
|
// ordering obtained in step (b) in the format registry–ordering–UCS2
|
|
|
|
|
// (for example, Adobe–Japan1–UCS2).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
let ucs2CMapName = Name.get(registry + "-" + ordering + "-UCS2");
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// d) Obtain the CMap with the name constructed in step (c) (available
|
|
|
|
|
// from the ASN Web site; see the Bibliography).
|
2017-02-12 23:54:41 +09:00
|
|
|
|
return CMapFactory.create({
|
|
|
|
|
encoding: ucs2CMapName,
|
|
|
|
|
fetchBuiltInCMap: this.fetchBuiltInCMap,
|
|
|
|
|
useCMap: null,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).then(function(ucs2CMap) {
|
2017-11-26 20:53:06 +09:00
|
|
|
|
let cMap = properties.cMap;
|
|
|
|
|
let toUnicode = [];
|
2016-02-29 01:20:29 +09:00
|
|
|
|
cMap.forEach(function(charcode, cid) {
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (cid > 0xffff) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("Max size of CID is 65,535");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
|
// e) Map the CID obtained in step (a) according to the CMap
|
|
|
|
|
// obtained in step (d), producing a Unicode value.
|
2017-11-26 20:53:06 +09:00
|
|
|
|
let ucs2 = ucs2CMap.lookup(cid);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
if (ucs2) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
toUnicode[charcode] = String.fromCharCode(
|
|
|
|
|
(ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1)
|
|
|
|
|
);
|
2011-10-29 10:38:31 +09:00
|
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
|
});
|
|
|
|
|
return new ToUnicodeMap(toUnicode);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The viewer's choice, just use an identity map.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return Promise.resolve(
|
|
|
|
|
new IdentityToUnicodeMap(properties.firstChar, properties.lastChar)
|
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
|
|
|
|
|
var cmapObj = toUnicode;
|
|
|
|
|
if (isName(cmapObj)) {
|
2017-02-12 23:54:41 +09:00
|
|
|
|
return CMapFactory.create({
|
|
|
|
|
encoding: cmapObj,
|
|
|
|
|
fetchBuiltInCMap: this.fetchBuiltInCMap,
|
|
|
|
|
useCMap: null,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).then(function(cmap) {
|
2016-02-29 01:20:29 +09:00
|
|
|
|
if (cmap instanceof IdentityCMap) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return new IdentityToUnicodeMap(0, 0xffff);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
}
|
|
|
|
|
return new ToUnicodeMap(cmap.getMap());
|
|
|
|
|
});
|
|
|
|
|
} else if (isStream(cmapObj)) {
|
2017-02-12 23:54:41 +09:00
|
|
|
|
return CMapFactory.create({
|
|
|
|
|
encoding: cmapObj,
|
|
|
|
|
fetchBuiltInCMap: this.fetchBuiltInCMap,
|
|
|
|
|
useCMap: null,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).then(function(cmap) {
|
2016-02-29 01:20:29 +09:00
|
|
|
|
if (cmap instanceof IdentityCMap) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return new IdentityToUnicodeMap(0, 0xffff);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
|
var map = new Array(cmap.length);
|
|
|
|
|
// Convert UTF-16BE
|
|
|
|
|
// NOTE: cmap can be a sparse array, so use forEach instead of for(;;)
|
|
|
|
|
// to iterate over all keys.
|
|
|
|
|
cmap.forEach(function(charCode, token) {
|
|
|
|
|
var str = [];
|
|
|
|
|
for (var k = 0; k < token.length; k += 2) {
|
|
|
|
|
var w1 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if ((w1 & 0xf800) !== 0xd800) {
|
|
|
|
|
// w1 < 0xD800 || w1 > 0xDFFF
|
2016-02-29 01:20:29 +09:00
|
|
|
|
str.push(w1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
k += 2;
|
|
|
|
|
var w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
|
|
|
|
|
str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
|
|
|
|
|
}
|
2019-02-09 15:53:16 +09:00
|
|
|
|
map[charCode] = String.fromCodePoint.apply(String, str);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
});
|
|
|
|
|
return new ToUnicodeMap(map);
|
2014-01-26 02:04:33 +09:00
|
|
|
|
});
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
|
return Promise.resolve(null);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
},
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2019-05-08 00:44:37 +09:00
|
|
|
|
readCidToGidMap(glyphsData, toUnicode) {
|
2011-10-29 10:38:31 +09:00
|
|
|
|
// Extract the encoding from the CIDToGIDMap
|
|
|
|
|
|
|
|
|
|
// Set encoding 0 to later verify the font has an encoding
|
|
|
|
|
var result = [];
|
2011-11-13 02:09:19 +09:00
|
|
|
|
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
2011-10-29 10:38:31 +09:00
|
|
|
|
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
2019-05-08 00:44:37 +09:00
|
|
|
|
const code = j >> 1;
|
|
|
|
|
if (glyphID === 0 && !toUnicode.has(code)) {
|
2011-10-29 10:38:31 +09:00
|
|
|
|
continue;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2011-10-29 10:38:31 +09:00
|
|
|
|
result[code] = glyphID;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2011-10-29 10:38:31 +09:00
|
|
|
|
return result;
|
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
extractWidths: function PartialEvaluator_extractWidths(
|
|
|
|
|
dict,
|
|
|
|
|
descriptor,
|
|
|
|
|
properties
|
|
|
|
|
) {
|
2017-03-26 21:12:53 +09:00
|
|
|
|
var xref = this.xref;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
var glyphsWidths = [];
|
2011-10-25 08:55:23 +09:00
|
|
|
|
var defaultWidth = 0;
|
2013-02-08 21:29:22 +09:00
|
|
|
|
var glyphsVMetrics = [];
|
|
|
|
|
var defaultVMetrics;
|
2014-04-08 06:42:54 +09:00
|
|
|
|
var i, ii, j, jj, start, code, widths;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (properties.composite) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
widths = dict.get("W");
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (widths) {
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (i = 0, ii = widths.length; i < ii; i++) {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
start = xref.fetchIfRef(widths[i++]);
|
2014-04-08 06:42:54 +09:00
|
|
|
|
code = xref.fetchIfRef(widths[i]);
|
2017-09-02 03:27:13 +09:00
|
|
|
|
if (Array.isArray(code)) {
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (j = 0, jj = code.length; j < jj; j++) {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
glyphsWidths[start++] = xref.fetchIfRef(code[j]);
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2013-01-30 07:19:08 +09:00
|
|
|
|
} else {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
var width = xref.fetchIfRef(widths[++i]);
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (j = start; j <= code; j++) {
|
2011-10-29 10:38:31 +09:00
|
|
|
|
glyphsWidths[j] = width;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2011-10-29 10:38:31 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-08 21:29:22 +09:00
|
|
|
|
|
|
|
|
|
if (properties.vertical) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var vmetrics = dict.getArray("DW2") || [880, -1000];
|
2013-03-13 01:27:45 +09:00
|
|
|
|
defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
vmetrics = dict.get("W2");
|
2013-02-08 21:29:22 +09:00
|
|
|
|
if (vmetrics) {
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (i = 0, ii = vmetrics.length; i < ii; i++) {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
start = xref.fetchIfRef(vmetrics[i++]);
|
2014-04-08 06:42:54 +09:00
|
|
|
|
code = xref.fetchIfRef(vmetrics[i]);
|
2017-09-02 03:27:13 +09:00
|
|
|
|
if (Array.isArray(code)) {
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (j = 0, jj = code.length; j < jj; j++) {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
glyphsVMetrics[start++] = [
|
|
|
|
|
xref.fetchIfRef(code[j++]),
|
|
|
|
|
xref.fetchIfRef(code[j++]),
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
xref.fetchIfRef(code[j]),
|
2016-11-30 02:28:32 +09:00
|
|
|
|
];
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2013-02-08 21:29:22 +09:00
|
|
|
|
} else {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
var vmetric = [
|
|
|
|
|
xref.fetchIfRef(vmetrics[++i]),
|
|
|
|
|
xref.fetchIfRef(vmetrics[++i]),
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
xref.fetchIfRef(vmetrics[++i]),
|
2016-11-30 02:28:32 +09:00
|
|
|
|
];
|
2014-04-08 06:42:54 +09:00
|
|
|
|
for (j = start; j <= code; j++) {
|
2013-02-08 21:29:22 +09:00
|
|
|
|
glyphsVMetrics[j] = vmetric;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2013-02-08 21:29:22 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-29 10:38:31 +09:00
|
|
|
|
} else {
|
|
|
|
|
var firstChar = properties.firstChar;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
widths = dict.get("Widths");
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (widths) {
|
2014-04-08 06:42:54 +09:00
|
|
|
|
j = firstChar;
|
|
|
|
|
for (i = 0, ii = widths.length; i < ii; i++) {
|
2016-11-30 02:28:32 +09:00
|
|
|
|
glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
} else {
|
|
|
|
|
// Trying get the BaseFont metrics (see comment above).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var baseFontName = dict.get("BaseFont");
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (isName(baseFontName)) {
|
|
|
|
|
var metrics = this.getBaseFontMetrics(baseFontName.name);
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
glyphsWidths = this.buildCharCodeToWidth(
|
|
|
|
|
metrics.widths,
|
|
|
|
|
properties
|
|
|
|
|
);
|
2011-10-29 10:38:31 +09:00
|
|
|
|
defaultWidth = metrics.defaultWidth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-17 04:38:30 +09:00
|
|
|
|
// Heuristic: detection of monospace font by checking all non-zero widths
|
2014-03-23 03:15:51 +09:00
|
|
|
|
var isMonospace = true;
|
|
|
|
|
var firstWidth = defaultWidth;
|
2012-09-17 04:38:30 +09:00
|
|
|
|
for (var glyph in glyphsWidths) {
|
|
|
|
|
var glyphWidth = glyphsWidths[glyph];
|
2014-03-23 03:15:51 +09:00
|
|
|
|
if (!glyphWidth) {
|
2012-09-17 04:38:30 +09:00
|
|
|
|
continue;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2012-09-17 04:38:30 +09:00
|
|
|
|
if (!firstWidth) {
|
|
|
|
|
firstWidth = glyphWidth;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-08-02 01:25:21 +09:00
|
|
|
|
if (firstWidth !== glyphWidth) {
|
2012-09-17 04:38:30 +09:00
|
|
|
|
isMonospace = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-23 03:15:51 +09:00
|
|
|
|
if (isMonospace) {
|
2012-09-17 04:38:30 +09:00
|
|
|
|
properties.flags |= FontFlags.FixedPitch;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
2012-09-17 04:38:30 +09:00
|
|
|
|
|
2011-10-29 10:38:31 +09:00
|
|
|
|
properties.defaultWidth = defaultWidth;
|
|
|
|
|
properties.widths = glyphsWidths;
|
2013-02-08 21:29:22 +09:00
|
|
|
|
properties.defaultVMetrics = defaultVMetrics;
|
|
|
|
|
properties.vmetrics = glyphsVMetrics;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-12 04:04:56 +09:00
|
|
|
|
isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
|
|
|
|
|
// Simulating descriptor flags attribute
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontNameWoStyle = baseFontName.split("-")[0];
|
|
|
|
|
return (
|
|
|
|
|
fontNameWoStyle in getSerifFonts() ||
|
|
|
|
|
fontNameWoStyle.search(/serif/gi) !== -1
|
|
|
|
|
);
|
2013-01-12 04:04:56 +09:00
|
|
|
|
},
|
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
|
getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
|
2014-03-23 03:15:51 +09:00
|
|
|
|
var defaultWidth = 0;
|
|
|
|
|
var widths = [];
|
|
|
|
|
var monospace = false;
|
2016-01-22 06:52:24 +09:00
|
|
|
|
var stdFontMap = getStdFontMap();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var lookupName = stdFontMap[name] || name;
|
2016-01-22 07:29:05 +09:00
|
|
|
|
var Metrics = getMetrics();
|
2013-01-12 04:04:56 +09:00
|
|
|
|
|
|
|
|
|
if (!(lookupName in Metrics)) {
|
|
|
|
|
// Use default fonts for looking up font metrics if the passed
|
|
|
|
|
// font is not a base font
|
|
|
|
|
if (this.isSerifFont(name)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
lookupName = "Times-Roman";
|
2013-01-12 04:04:56 +09:00
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
lookupName = "Helvetica";
|
2013-01-12 04:04:56 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var glyphWidths = Metrics[lookupName];
|
|
|
|
|
|
2011-10-29 10:38:31 +09:00
|
|
|
|
if (isNum(glyphWidths)) {
|
|
|
|
|
defaultWidth = glyphWidths;
|
2012-09-17 04:38:30 +09:00
|
|
|
|
monospace = true;
|
2011-10-29 10:38:31 +09:00
|
|
|
|
} else {
|
2016-01-22 07:29:05 +09:00
|
|
|
|
widths = glyphWidths(); // expand lazy widths array
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
defaultWidth,
|
|
|
|
|
monospace,
|
|
|
|
|
widths,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(
|
|
|
|
|
widthsByGlyphName,
|
|
|
|
|
properties
|
|
|
|
|
) {
|
2014-02-12 03:27:09 +09:00
|
|
|
|
var widths = Object.create(null);
|
|
|
|
|
var differences = properties.differences;
|
|
|
|
|
var encoding = properties.defaultEncoding;
|
|
|
|
|
for (var charCode = 0; charCode < 256; charCode++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
charCode in differences &&
|
|
|
|
|
widthsByGlyphName[differences[charCode]]
|
|
|
|
|
) {
|
2014-02-12 03:27:09 +09:00
|
|
|
|
widths[charCode] = widthsByGlyphName[differences[charCode]];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
|
|
|
|
|
widths[charCode] = widthsByGlyphName[encoding[charCode]];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return widths;
|
|
|
|
|
},
|
|
|
|
|
|
2017-03-26 21:12:53 +09:00
|
|
|
|
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
var baseDict = dict;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var type = dict.get("Subtype");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!isName(type)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("invalid font Subtype");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
|
|
var composite = false;
|
2014-04-10 02:47:42 +09:00
|
|
|
|
var uint8array;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type.name === "Type0") {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
// If font is a composite
|
|
|
|
|
// - get the descendant font
|
|
|
|
|
// - set the type according to the descendant font
|
|
|
|
|
// - get the FontDescriptor from the descendant font
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var df = dict.get("DescendantFonts");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!df) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("Descendant fonts are not specified");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
type = dict.get("Subtype");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!isName(type)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("invalid font Subtype");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
composite = true;
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var descriptor = dict.get("FontDescriptor");
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (descriptor) {
|
|
|
|
|
var hash = new MurmurHash3_64();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var encoding = baseDict.getRaw("Encoding");
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (isName(encoding)) {
|
|
|
|
|
hash.update(encoding.name);
|
|
|
|
|
} else if (isRef(encoding)) {
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
hash.update(encoding.toString());
|
2015-04-25 20:27:10 +09:00
|
|
|
|
} else if (isDict(encoding)) {
|
|
|
|
|
var keys = encoding.getKeys();
|
|
|
|
|
for (var i = 0, ii = keys.length; i < ii; i++) {
|
|
|
|
|
var entry = encoding.getRaw(keys[i]);
|
|
|
|
|
if (isName(entry)) {
|
|
|
|
|
hash.update(entry.name);
|
|
|
|
|
} else if (isRef(entry)) {
|
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.
There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.
Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)
In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-05-23 22:32:04 +09:00
|
|
|
|
hash.update(entry.toString());
|
2017-09-02 03:27:13 +09:00
|
|
|
|
} else if (Array.isArray(entry)) {
|
2016-12-28 08:06:54 +09:00
|
|
|
|
// 'Differences' array (fixes bug1157493.pdf).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var diffLength = entry.length,
|
|
|
|
|
diffBuf = new Array(diffLength);
|
2016-12-28 08:06:54 +09:00
|
|
|
|
|
|
|
|
|
for (var j = 0; j < diffLength; j++) {
|
|
|
|
|
var diffEntry = entry[j];
|
|
|
|
|
if (isName(diffEntry)) {
|
|
|
|
|
diffBuf[j] = diffEntry.name;
|
|
|
|
|
} else if (isNum(diffEntry) || isRef(diffEntry)) {
|
|
|
|
|
diffBuf[j] = diffEntry.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
hash.update(diffBuf.join());
|
2015-04-25 20:27:10 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-04 02:44:45 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const firstChar = dict.get("FirstChar") || 0;
|
|
|
|
|
const lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
|
2019-03-27 08:25:34 +09:00
|
|
|
|
hash.update(`${firstChar}-${lastChar}`);
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (isStream(toUnicode)) {
|
|
|
|
|
var stream = toUnicode.str || toUnicode;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
uint8array = stream.buffer
|
|
|
|
|
? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength)
|
|
|
|
|
: new Uint8Array(
|
|
|
|
|
stream.bytes.buffer,
|
|
|
|
|
stream.start,
|
|
|
|
|
stream.end - stream.start
|
|
|
|
|
);
|
2014-03-04 02:44:45 +09:00
|
|
|
|
hash.update(uint8array);
|
|
|
|
|
} else if (isName(toUnicode)) {
|
|
|
|
|
hash.update(toUnicode.name);
|
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var widths = dict.get("Widths") || baseDict.get("Widths");
|
2014-03-04 02:44:45 +09:00
|
|
|
|
if (widths) {
|
2014-04-10 02:47:42 +09:00
|
|
|
|
uint8array = new Uint8Array(new Uint32Array(widths).buffer);
|
2014-03-04 02:44:45 +09:00
|
|
|
|
hash.update(uint8array);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
descriptor,
|
|
|
|
|
dict,
|
|
|
|
|
baseDict,
|
|
|
|
|
composite,
|
2014-06-16 23:52:04 +09:00
|
|
|
|
type: type.name,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
hash: hash ? hash.hexdigest() : "",
|
2014-03-04 02:44:45 +09:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2017-03-26 21:12:53 +09:00
|
|
|
|
translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
|
2014-03-04 02:44:45 +09:00
|
|
|
|
var baseDict = preEvaluatedFont.baseDict;
|
|
|
|
|
var dict = preEvaluatedFont.dict;
|
|
|
|
|
var composite = preEvaluatedFont.composite;
|
|
|
|
|
var descriptor = preEvaluatedFont.descriptor;
|
2014-06-16 23:52:04 +09:00
|
|
|
|
var type = preEvaluatedFont.type;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var maxCharIndex = composite ? 0xffff : 0xff;
|
2014-04-10 02:47:42 +09:00
|
|
|
|
var properties;
|
2014-03-04 02:44:45 +09:00
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
|
if (!descriptor) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type === "Type3") {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
// FontDescriptor is only required for Type3 fonts when the document
|
|
|
|
|
// is a tagged pdf. Create a barbebones one to get by.
|
2014-03-26 23:07:38 +09:00
|
|
|
|
descriptor = new Dict(null);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
descriptor.set("FontName", Name.get(type));
|
|
|
|
|
descriptor.set("FontBBox", dict.getArray("FontBBox"));
|
2011-10-25 08:55:23 +09:00
|
|
|
|
} else {
|
|
|
|
|
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
|
|
|
|
|
// FontDescriptor was not required.
|
|
|
|
|
// This case is here for compatibility.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var baseFontName = dict.get("BaseFont");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!isName(baseFontName)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("Base font is not specified");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
|
|
// Using base font name as a font name.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
baseFontName = baseFontName.name.replace(/[,_]/g, "-");
|
2011-10-29 10:38:31 +09:00
|
|
|
|
var metrics = this.getBaseFontMetrics(baseFontName);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
2012-01-10 12:15:18 +09:00
|
|
|
|
// Simulating descriptor flags attribute
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontNameWoStyle = baseFontName.split("-")[0];
|
2014-03-23 03:15:51 +09:00
|
|
|
|
var flags =
|
|
|
|
|
(this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) |
|
2012-09-17 04:38:30 +09:00
|
|
|
|
(metrics.monospace ? FontFlags.FixedPitch : 0) |
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
(getSymbolsFonts()[fontNameWoStyle]
|
|
|
|
|
? FontFlags.Symbolic
|
|
|
|
|
: FontFlags.Nonsymbolic);
|
2012-01-10 12:15:18 +09:00
|
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
|
properties = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
type,
|
2014-01-09 07:33:22 +09:00
|
|
|
|
name: baseFontName,
|
2011-10-29 10:38:31 +09:00
|
|
|
|
widths: metrics.widths,
|
|
|
|
|
defaultWidth: metrics.defaultWidth,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
flags,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
firstChar: 0,
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
lastChar: maxCharIndex,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return this.extractDataStructures(dict, dict, properties).then(
|
|
|
|
|
properties => {
|
|
|
|
|
properties.widths = this.buildCharCodeToWidth(
|
|
|
|
|
metrics.widths,
|
|
|
|
|
properties
|
|
|
|
|
);
|
2017-04-30 06:36:43 +09:00
|
|
|
|
return new Font(baseFontName, null, properties);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}
|
|
|
|
|
);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// According to the spec if 'FontDescriptor' is declared, 'FirstChar',
|
2012-01-20 04:19:19 +09:00
|
|
|
|
// 'LastChar' and 'Widths' should exist too, but some PDF encoders seem
|
2016-07-17 21:33:41 +09:00
|
|
|
|
// to ignore this rule when a variant of a standard font is used.
|
2011-10-25 08:55:23 +09:00
|
|
|
|
// TODO Fill the width array depending on which of the base font this is
|
|
|
|
|
// a variant.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var firstChar = dict.get("FirstChar") || 0;
|
|
|
|
|
var lastChar = dict.get("LastChar") || maxCharIndex;
|
2013-01-12 10:10:09 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontName = descriptor.get("FontName");
|
|
|
|
|
var baseFont = dict.get("BaseFont");
|
2014-03-23 03:15:51 +09:00
|
|
|
|
// Some bad PDFs have a string as the font name.
|
2013-01-12 10:10:09 +09:00
|
|
|
|
if (isString(fontName)) {
|
2014-02-28 13:41:03 +09:00
|
|
|
|
fontName = Name.get(fontName);
|
2013-01-12 10:10:09 +09:00
|
|
|
|
}
|
|
|
|
|
if (isString(baseFont)) {
|
2014-02-28 13:41:03 +09:00
|
|
|
|
baseFont = Name.get(baseFont);
|
2013-01-12 10:10:09 +09:00
|
|
|
|
}
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type !== "Type3") {
|
2013-03-03 21:30:08 +09:00
|
|
|
|
var fontNameStr = fontName && fontName.name;
|
|
|
|
|
var baseFontStr = baseFont && baseFont.name;
|
|
|
|
|
if (fontNameStr !== baseFontStr) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
info(
|
|
|
|
|
`The FontDescriptor\'s FontName is "${fontNameStr}" but ` +
|
|
|
|
|
`should be the same as the Font\'s BaseFont "${baseFontStr}".`
|
|
|
|
|
);
|
2014-04-09 05:49:51 +09:00
|
|
|
|
// Workaround for cases where e.g. fontNameStr = 'Arial' and
|
|
|
|
|
// baseFontStr = 'Arial,Bold' (needed when no font file is embedded).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
fontNameStr &&
|
|
|
|
|
baseFontStr &&
|
|
|
|
|
baseFontStr.startsWith(fontNameStr)
|
|
|
|
|
) {
|
2014-04-09 05:49:51 +09:00
|
|
|
|
fontName = baseFont;
|
|
|
|
|
}
|
2013-03-03 21:30:08 +09:00
|
|
|
|
}
|
2013-01-12 10:10:09 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
fontName = fontName || baseFont;
|
2013-01-12 10:10:09 +09:00
|
|
|
|
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!isName(fontName)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("invalid font name");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
if (fontFile) {
|
|
|
|
|
if (fontFile.dict) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var subtype = fontFile.dict.get("Subtype");
|
2014-03-23 03:15:51 +09:00
|
|
|
|
if (subtype) {
|
2011-10-25 08:55:23 +09:00
|
|
|
|
subtype = subtype.name;
|
2014-03-23 03:15:51 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var length1 = fontFile.dict.get("Length1");
|
|
|
|
|
var length2 = fontFile.dict.get("Length2");
|
|
|
|
|
var length3 = fontFile.dict.get("Length3");
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
|
properties = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
type,
|
2014-01-09 07:33:22 +09:00
|
|
|
|
name: fontName.name,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
subtype,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
file: fontFile,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
length1,
|
|
|
|
|
length2,
|
|
|
|
|
length3,
|
2012-09-14 00:09:46 +09:00
|
|
|
|
loadedName: baseDict.loadedName,
|
2017-04-27 19:58:44 +09:00
|
|
|
|
composite,
|
2012-04-24 07:44:51 +09:00
|
|
|
|
wideChars: composite,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
fixedPitch: false,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
fontMatrix: dict.getArray("FontMatrix") || FONT_IDENTITY_MATRIX,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
firstChar: firstChar || 0,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
lastChar: lastChar || maxCharIndex,
|
|
|
|
|
bbox: descriptor.getArray("FontBBox"),
|
|
|
|
|
ascent: descriptor.get("Ascent"),
|
|
|
|
|
descent: descriptor.get("Descent"),
|
|
|
|
|
xHeight: descriptor.get("XHeight"),
|
|
|
|
|
capHeight: descriptor.get("CapHeight"),
|
|
|
|
|
flags: descriptor.get("Flags"),
|
|
|
|
|
italicAngle: descriptor.get("ItalicAngle"),
|
2017-08-08 21:03:02 +09:00
|
|
|
|
isType3Font: false,
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
2013-02-08 21:29:22 +09:00
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
|
var cMapPromise;
|
2013-02-08 21:29:22 +09:00
|
|
|
|
if (composite) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var cidEncoding = baseDict.get("Encoding");
|
2013-02-08 21:29:22 +09:00
|
|
|
|
if (isName(cidEncoding)) {
|
|
|
|
|
properties.cidEncoding = cidEncoding.name;
|
|
|
|
|
}
|
2017-02-12 23:54:41 +09:00
|
|
|
|
cMapPromise = CMapFactory.create({
|
|
|
|
|
encoding: cidEncoding,
|
|
|
|
|
fetchBuiltInCMap: this.fetchBuiltInCMap,
|
|
|
|
|
useCMap: null,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
}).then(function(cMap) {
|
2016-02-29 01:20:29 +09:00
|
|
|
|
properties.cMap = cMap;
|
|
|
|
|
properties.vertical = properties.cMap.vertical;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
cMapPromise = Promise.resolve(undefined);
|
2013-02-08 21:29:22 +09:00
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return cMapPromise
|
|
|
|
|
.then(() => {
|
|
|
|
|
return this.extractDataStructures(dict, baseDict, properties);
|
|
|
|
|
})
|
|
|
|
|
.then(properties => {
|
|
|
|
|
this.extractWidths(dict, descriptor, properties);
|
2016-02-29 01:20:29 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (type === "Type3") {
|
|
|
|
|
properties.isType3Font = true;
|
|
|
|
|
}
|
|
|
|
|
return new Font(fontName.name, fontFile, properties);
|
|
|
|
|
});
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
|
|
|
|
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
PartialEvaluator.buildFontPaths = function(font, glyphs, handler) {
|
|
|
|
|
function buildPath(fontChar) {
|
|
|
|
|
if (font.renderer.hasBuiltPath(fontChar)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
handler.send("commonobj", [
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
`${font.loadedName}_path_${fontChar}`,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
"FontPath",
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
font.renderer.getPathJs(fontChar),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const glyph of glyphs) {
|
|
|
|
|
buildPath(glyph.fontChar);
|
|
|
|
|
|
|
|
|
|
// If the glyph has an accent we need to build a path for its
|
|
|
|
|
// fontChar too, otherwise CanvasGraphics_paintChar will fail.
|
|
|
|
|
const accent = glyph.accent;
|
|
|
|
|
if (accent && accent.fontChar) {
|
|
|
|
|
buildPath(accent.fontChar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
|
return PartialEvaluator;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
})();
|
|
|
|
|
|
2014-05-20 06:27:54 +09:00
|
|
|
|
var TranslatedFont = (function TranslatedFontClosure() {
|
|
|
|
|
function TranslatedFont(loadedName, font, dict) {
|
|
|
|
|
this.loadedName = loadedName;
|
|
|
|
|
this.font = font;
|
|
|
|
|
this.dict = dict;
|
|
|
|
|
this.type3Loaded = null;
|
|
|
|
|
this.sent = false;
|
|
|
|
|
}
|
|
|
|
|
TranslatedFont.prototype = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
send(handler) {
|
2014-05-20 06:27:54 +09:00
|
|
|
|
if (this.sent) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
this.sent = true;
|
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
handler.send("commonobj", [
|
2014-05-20 06:27:54 +09:00
|
|
|
|
this.loadedName,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
"Font",
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
this.font.exportData(),
|
2014-05-20 06:27:54 +09:00
|
|
|
|
]);
|
|
|
|
|
},
|
Fallback to the built-in font renderer when font loading fails
After PR 9340 all glyphs are now re-mapped to a Private Use Area (PUA) which means that if a font fails to load, for whatever reason[1], all glyphs in the font will now render as Unicode glyph outlines.
This obviously doesn't look good, to say the least, and might be seen as a "regression" since previously many glyphs were left in their original positions which provided a slightly better fallback[2].
Hence this patch, which implements a *general* fallback to the PDF.js built-in font renderer for fonts that fail to load (i.e. are rejected by the sanitizer). One caveat here is that this only works for the Font Loading API, since it's easy to handle errors in that case[3].
The solution implemented in this patch does *not* in any way delay the loading of valid fonts, which was the problem with my previous attempt at a solution, and will only require a bit of extra work/waiting for those fonts that actually fail to load.
*Please note:* This patch doesn't fix any of the underlying PDF.js font conversion bugs that's responsible for creating corrupt font files, however it does *improve* rendering in a number of cases; refer to this possibly incomplete list:
[Bug 1524888](https://bugzilla.mozilla.org/show_bug.cgi?id=1524888)
Issue 10175
Issue 10232
---
[1] Usually because the PDF.js font conversion code wasn't able to parse the font file correctly.
[2] Glyphs fell back to some default font, which while not accurate was more useful than the current state.
[3] Furthermore I'm not sure how to implement this generally, assuming that's even possible, and don't really have time/interest to look into it either.
2019-02-11 08:47:56 +09:00
|
|
|
|
|
|
|
|
|
fallback(handler) {
|
|
|
|
|
if (!this.font.data) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// When font loading failed, fall back to the built-in font renderer.
|
|
|
|
|
this.font.disableFontFace = true;
|
|
|
|
|
// An arbitrary number of text rendering operators could have been
|
|
|
|
|
// encountered between the point in time when the 'Font' message was sent
|
|
|
|
|
// to the main-thread, and the point in time when the 'FontFallback'
|
|
|
|
|
// message was received on the worker-thread.
|
|
|
|
|
// To ensure that all 'FontPath's are available on the main-thread, when
|
|
|
|
|
// font loading failed, attempt to resend *all* previously parsed glyphs.
|
|
|
|
|
const glyphs = this.font.glyphCacheValues;
|
|
|
|
|
PartialEvaluator.buildFontPaths(this.font, glyphs, handler);
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-27 19:58:44 +09:00
|
|
|
|
loadType3Data(evaluator, resources, parentOperatorList, task) {
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (!this.font.isType3Font) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new Error("Must be a Type3 font.");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2014-05-20 06:27:54 +09:00
|
|
|
|
|
|
|
|
|
if (this.type3Loaded) {
|
|
|
|
|
return this.type3Loaded;
|
|
|
|
|
}
|
2017-04-05 20:32:36 +09:00
|
|
|
|
// 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.
|
2019-04-11 19:26:15 +09:00
|
|
|
|
//
|
|
|
|
|
// Also, ensure that any Type3 image resources (which should be very rare
|
|
|
|
|
// in practice) are completely decoded on the worker-thread, to simplify
|
|
|
|
|
// the rendering code on the main-thread (see issue10717.pdf).
|
2017-04-05 20:32:36 +09:00
|
|
|
|
var type3Options = Object.create(evaluator.options);
|
|
|
|
|
type3Options.ignoreErrors = false;
|
2019-04-11 19:26:15 +09:00
|
|
|
|
type3Options.nativeImageDecoderSupport = NativeImageDecoding.NONE;
|
2017-04-05 20:32:36 +09:00
|
|
|
|
var type3Evaluator = evaluator.clone(type3Options);
|
2019-04-11 19:26:15 +09:00
|
|
|
|
type3Evaluator.parsingType3Font = true;
|
2014-05-20 06:27:54 +09:00
|
|
|
|
|
|
|
|
|
var translatedFont = this.font;
|
|
|
|
|
var loadCharProcsPromise = Promise.resolve();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var charProcs = this.dict.get("CharProcs");
|
|
|
|
|
var fontResources = this.dict.get("Resources") || resources;
|
2016-02-11 04:19:14 +09:00
|
|
|
|
var charProcKeys = charProcs.getKeys();
|
2016-01-28 02:04:13 +09:00
|
|
|
|
var charProcOperatorList = Object.create(null);
|
2017-04-05 20:32:36 +09:00
|
|
|
|
|
2014-05-20 06:27:54 +09:00
|
|
|
|
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
|
2017-04-30 06:36:43 +09:00
|
|
|
|
let key = charProcKeys[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
loadCharProcsPromise = loadCharProcsPromise.then(function() {
|
2016-02-11 04:19:14 +09:00
|
|
|
|
var glyphStream = charProcs.get(key);
|
2014-05-20 06:27:54 +09:00
|
|
|
|
var operatorList = new OperatorList();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return type3Evaluator
|
|
|
|
|
.getOperatorList({
|
|
|
|
|
stream: glyphStream,
|
|
|
|
|
task,
|
|
|
|
|
resources: fontResources,
|
|
|
|
|
operatorList,
|
|
|
|
|
})
|
|
|
|
|
.then(function() {
|
|
|
|
|
charProcOperatorList[key] = operatorList.getIR();
|
|
|
|
|
|
|
|
|
|
// Add the dependencies to the parent operator list so they are
|
|
|
|
|
// resolved before sub operator list is executed synchronously.
|
|
|
|
|
parentOperatorList.addDependencies(operatorList.dependencies);
|
|
|
|
|
})
|
|
|
|
|
.catch(function(reason) {
|
|
|
|
|
warn(`Type3 font resource "${key}" is not available.`);
|
|
|
|
|
var operatorList = new OperatorList();
|
|
|
|
|
charProcOperatorList[key] = operatorList.getIR();
|
|
|
|
|
});
|
2017-04-30 06:36:43 +09:00
|
|
|
|
});
|
2014-05-20 06:27:54 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
this.type3Loaded = loadCharProcsPromise.then(function() {
|
2014-05-20 06:27:54 +09:00
|
|
|
|
translatedFont.charProcOperatorList = charProcOperatorList;
|
|
|
|
|
});
|
|
|
|
|
return this.type3Loaded;
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2014-05-20 06:27:54 +09:00
|
|
|
|
};
|
|
|
|
|
return TranslatedFont;
|
|
|
|
|
})();
|
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var StateManager = (function StateManagerClosure() {
|
|
|
|
|
function StateManager(initialState) {
|
|
|
|
|
this.state = initialState;
|
|
|
|
|
this.stateStack = [];
|
|
|
|
|
}
|
|
|
|
|
StateManager.prototype = {
|
2017-04-27 19:58:44 +09:00
|
|
|
|
save() {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var old = this.state;
|
|
|
|
|
this.stateStack.push(this.state);
|
|
|
|
|
this.state = old.clone();
|
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
|
restore() {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
var prev = this.stateStack.pop();
|
|
|
|
|
if (prev) {
|
|
|
|
|
this.state = prev;
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
|
transform(args) {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.state.ctm = Util.transform(this.state.ctm, args);
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2014-04-10 08:44:07 +09:00
|
|
|
|
};
|
|
|
|
|
return StateManager;
|
|
|
|
|
})();
|
|
|
|
|
|
2013-09-15 02:58:58 +09:00
|
|
|
|
var TextState = (function TextStateClosure() {
|
|
|
|
|
function TextState() {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.ctm = new Float32Array(IDENTITY_MATRIX);
|
2016-06-01 06:01:35 +09:00
|
|
|
|
this.fontName = null;
|
2013-09-15 02:58:58 +09:00
|
|
|
|
this.fontSize = 0;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.font = null;
|
|
|
|
|
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
|
|
|
|
this.textMatrix = IDENTITY_MATRIX.slice();
|
|
|
|
|
this.textLineMatrix = IDENTITY_MATRIX.slice();
|
|
|
|
|
this.charSpacing = 0;
|
|
|
|
|
this.wordSpacing = 0;
|
2013-09-15 02:58:58 +09:00
|
|
|
|
this.leading = 0;
|
|
|
|
|
this.textHScale = 1;
|
|
|
|
|
this.textRise = 0;
|
|
|
|
|
}
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2013-09-15 02:58:58 +09:00
|
|
|
|
TextState.prototype = {
|
|
|
|
|
setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
|
|
|
|
|
var m = this.textMatrix;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
m[0] = a;
|
|
|
|
|
m[1] = b;
|
|
|
|
|
m[2] = c;
|
|
|
|
|
m[3] = d;
|
|
|
|
|
m[4] = e;
|
|
|
|
|
m[5] = f;
|
2013-09-15 02:58:58 +09:00
|
|
|
|
},
|
2014-04-10 08:44:07 +09:00
|
|
|
|
setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
|
|
|
|
|
var m = this.textLineMatrix;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
m[0] = a;
|
|
|
|
|
m[1] = b;
|
|
|
|
|
m[2] = c;
|
|
|
|
|
m[3] = d;
|
|
|
|
|
m[4] = e;
|
|
|
|
|
m[5] = f;
|
2014-04-10 08:44:07 +09:00
|
|
|
|
},
|
2013-09-15 02:58:58 +09:00
|
|
|
|
translateTextMatrix: function TextState_translateTextMatrix(x, y) {
|
|
|
|
|
var m = this.textMatrix;
|
|
|
|
|
m[4] = m[0] * x + m[2] * y + m[4];
|
|
|
|
|
m[5] = m[1] * x + m[3] * y + m[5];
|
|
|
|
|
},
|
2014-04-10 08:44:07 +09:00
|
|
|
|
translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
|
|
|
|
|
var m = this.textLineMatrix;
|
|
|
|
|
m[4] = m[0] * x + m[2] * y + m[4];
|
|
|
|
|
m[5] = m[1] * x + m[3] * y + m[5];
|
2013-09-15 02:58:58 +09:00
|
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(
|
|
|
|
|
a,
|
|
|
|
|
b,
|
|
|
|
|
c,
|
|
|
|
|
d,
|
|
|
|
|
e,
|
|
|
|
|
f
|
|
|
|
|
) {
|
2016-05-15 05:13:12 +09:00
|
|
|
|
var font = this.font;
|
|
|
|
|
if (!font) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var m = this.textLineMatrix;
|
|
|
|
|
if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var txDiff = e - m[4],
|
|
|
|
|
tyDiff = f - m[5];
|
2016-05-15 05:13:12 +09:00
|
|
|
|
if ((font.vertical && txDiff !== 0) || (!font.vertical && tyDiff !== 0)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var tx,
|
|
|
|
|
ty,
|
|
|
|
|
denominator = a * d - b * c;
|
2016-05-15 05:13:12 +09:00
|
|
|
|
if (font.vertical) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
tx = (-tyDiff * c) / denominator;
|
|
|
|
|
ty = (tyDiff * a) / denominator;
|
2016-05-15 05:13:12 +09:00
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
tx = (txDiff * d) / denominator;
|
|
|
|
|
ty = (-txDiff * b) / denominator;
|
2016-05-15 05:13:12 +09:00
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
return { width: tx, height: ty, value: font.vertical ? ty : tx };
|
2016-05-15 05:13:12 +09:00
|
|
|
|
},
|
2014-04-10 08:44:07 +09:00
|
|
|
|
calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
|
|
|
|
|
// 9.4.4 Text Space Details
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var tsm = [
|
|
|
|
|
this.fontSize * this.textHScale,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
this.fontSize,
|
|
|
|
|
0,
|
|
|
|
|
this.textRise,
|
|
|
|
|
];
|
2014-04-10 08:44:07 +09:00
|
|
|
|
return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
|
|
|
|
|
},
|
|
|
|
|
carriageReturn: function TextState_carriageReturn() {
|
|
|
|
|
this.translateTextLineMatrix(0, -this.leading);
|
|
|
|
|
this.textMatrix = this.textLineMatrix.slice();
|
|
|
|
|
},
|
|
|
|
|
clone: function TextState_clone() {
|
|
|
|
|
var clone = Object.create(this);
|
|
|
|
|
clone.textMatrix = this.textMatrix.slice();
|
|
|
|
|
clone.textLineMatrix = this.textLineMatrix.slice();
|
|
|
|
|
clone.fontMatrix = this.fontMatrix.slice();
|
|
|
|
|
return clone;
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2013-09-15 02:58:58 +09:00
|
|
|
|
};
|
|
|
|
|
return TextState;
|
|
|
|
|
})();
|
2013-08-01 03:17:36 +09:00
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
|
var EvalState = (function EvalStateClosure() {
|
|
|
|
|
function EvalState() {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.ctm = new Float32Array(IDENTITY_MATRIX);
|
2013-08-01 06:01:55 +09:00
|
|
|
|
this.font = null;
|
2013-08-20 08:33:20 +09:00
|
|
|
|
this.textRenderingMode = TextRenderingMode.FILL;
|
2014-05-22 02:47:42 +09:00
|
|
|
|
this.fillColorSpace = ColorSpace.singletons.gray;
|
|
|
|
|
this.strokeColorSpace = ColorSpace.singletons.gray;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
}
|
2011-12-09 07:18:43 +09:00
|
|
|
|
EvalState.prototype = {
|
2013-08-01 06:01:55 +09:00
|
|
|
|
clone: function CanvasExtraState_clone() {
|
|
|
|
|
return Object.create(this);
|
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
|
};
|
2011-12-09 07:18:43 +09:00
|
|
|
|
return EvalState;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
})();
|
2011-10-28 03:51:10 +09:00
|
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
|
var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
2014-01-17 22:16:52 +09:00
|
|
|
|
// Specifies properties for each command
|
|
|
|
|
//
|
|
|
|
|
// If variableArgs === true: [0, `numArgs`] expected
|
|
|
|
|
// If variableArgs === false: exactly `numArgs` expected
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
var getOPMap = getLookupTableFactory(function(t) {
|
2014-01-17 22:16:52 +09:00
|
|
|
|
// Graphic state
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["w"] = { id: OPS.setLineWidth, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["J"] = { id: OPS.setLineCap, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["j"] = { id: OPS.setLineJoin, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["M"] = { id: OPS.setMiterLimit, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["d"] = { id: OPS.setDash, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["ri"] = { id: OPS.setRenderingIntent, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["i"] = { id: OPS.setFlatness, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["gs"] = { id: OPS.setGState, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["q"] = { id: OPS.save, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["Q"] = { id: OPS.restore, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["cm"] = { id: OPS.transform, numArgs: 6, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Path
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["m"] = { id: OPS.moveTo, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["l"] = { id: OPS.lineTo, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["c"] = { id: OPS.curveTo, numArgs: 6, variableArgs: false };
|
|
|
|
|
t["v"] = { id: OPS.curveTo2, numArgs: 4, variableArgs: false };
|
|
|
|
|
t["y"] = { id: OPS.curveTo3, numArgs: 4, variableArgs: false };
|
|
|
|
|
t["h"] = { id: OPS.closePath, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["re"] = { id: OPS.rectangle, numArgs: 4, variableArgs: false };
|
|
|
|
|
t["S"] = { id: OPS.stroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["s"] = { id: OPS.closeStroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["f"] = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["F"] = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["f*"] = { id: OPS.eoFill, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["B"] = { id: OPS.fillStroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["B*"] = { id: OPS.eoFillStroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["b"] = { id: OPS.closeFillStroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["b*"] = { id: OPS.closeEOFillStroke, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["n"] = { id: OPS.endPath, numArgs: 0, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Clipping
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["W"] = { id: OPS.clip, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["W*"] = { id: OPS.eoClip, numArgs: 0, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Text
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["BT"] = { id: OPS.beginText, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["ET"] = { id: OPS.endText, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["Tc"] = { id: OPS.setCharSpacing, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["Tw"] = { id: OPS.setWordSpacing, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["Tz"] = { id: OPS.setHScale, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["TL"] = { id: OPS.setLeading, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["Tf"] = { id: OPS.setFont, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["Tr"] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["Ts"] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["Td"] = { id: OPS.moveText, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["TD"] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["Tm"] = { id: OPS.setTextMatrix, numArgs: 6, variableArgs: false };
|
|
|
|
|
t["T*"] = { id: OPS.nextLine, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["Tj"] = { id: OPS.showText, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["TJ"] = { id: OPS.showSpacedText, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["'"] = { id: OPS.nextLineShowText, numArgs: 1, variableArgs: false };
|
|
|
|
|
t['"'] = {
|
|
|
|
|
id: OPS.nextLineSetSpacingShowText,
|
|
|
|
|
numArgs: 3,
|
|
|
|
|
variableArgs: false,
|
|
|
|
|
};
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Type3 fonts
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["d0"] = { id: OPS.setCharWidth, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["d1"] = {
|
|
|
|
|
id: OPS.setCharWidthAndBounds,
|
|
|
|
|
numArgs: 6,
|
|
|
|
|
variableArgs: false,
|
|
|
|
|
};
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Color
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["CS"] = { id: OPS.setStrokeColorSpace, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["cs"] = { id: OPS.setFillColorSpace, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["SC"] = { id: OPS.setStrokeColor, numArgs: 4, variableArgs: true };
|
|
|
|
|
t["SCN"] = { id: OPS.setStrokeColorN, numArgs: 33, variableArgs: true };
|
|
|
|
|
t["sc"] = { id: OPS.setFillColor, numArgs: 4, variableArgs: true };
|
|
|
|
|
t["scn"] = { id: OPS.setFillColorN, numArgs: 33, variableArgs: true };
|
|
|
|
|
t["G"] = { id: OPS.setStrokeGray, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["g"] = { id: OPS.setFillGray, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["RG"] = { id: OPS.setStrokeRGBColor, numArgs: 3, variableArgs: false };
|
|
|
|
|
t["rg"] = { id: OPS.setFillRGBColor, numArgs: 3, variableArgs: false };
|
|
|
|
|
t["K"] = { id: OPS.setStrokeCMYKColor, numArgs: 4, variableArgs: false };
|
|
|
|
|
t["k"] = { id: OPS.setFillCMYKColor, numArgs: 4, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Shading
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["sh"] = { id: OPS.shadingFill, numArgs: 1, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Images
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["BI"] = { id: OPS.beginInlineImage, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["ID"] = { id: OPS.beginImageData, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["EI"] = { id: OPS.endInlineImage, numArgs: 1, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// XObjects
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["Do"] = { id: OPS.paintXObject, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["MP"] = { id: OPS.markPoint, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["DP"] = { id: OPS.markPointProps, numArgs: 2, variableArgs: false };
|
|
|
|
|
t["BMC"] = { id: OPS.beginMarkedContent, numArgs: 1, variableArgs: false };
|
|
|
|
|
t["BDC"] = {
|
|
|
|
|
id: OPS.beginMarkedContentProps,
|
|
|
|
|
numArgs: 2,
|
|
|
|
|
variableArgs: false,
|
|
|
|
|
};
|
|
|
|
|
t["EMC"] = { id: OPS.endMarkedContent, numArgs: 0, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// Compatibility
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["BX"] = { id: OPS.beginCompat, numArgs: 0, variableArgs: false };
|
|
|
|
|
t["EX"] = { id: OPS.endCompat, numArgs: 0, variableArgs: false };
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
|
|
|
|
// (reserved partial commands for the lexer)
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
t["BM"] = null;
|
|
|
|
|
t["BD"] = null;
|
|
|
|
|
t["true"] = null;
|
|
|
|
|
t["fa"] = null;
|
|
|
|
|
t["fal"] = null;
|
|
|
|
|
t["fals"] = null;
|
|
|
|
|
t["false"] = null;
|
|
|
|
|
t["nu"] = null;
|
|
|
|
|
t["nul"] = null;
|
|
|
|
|
t["null"] = null;
|
2016-01-22 07:43:27 +09:00
|
|
|
|
});
|
2014-01-17 22:16:52 +09:00
|
|
|
|
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
const MAX_INVALID_PATH_OPS = 20;
|
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
|
function EvaluatorPreprocessor(stream, xref, stateManager) {
|
2016-01-22 07:43:27 +09:00
|
|
|
|
this.opMap = getOPMap();
|
|
|
|
|
// TODO(mduan): pass array of knownCommands rather than this.opMap
|
2014-01-17 22:16:52 +09:00
|
|
|
|
// dictionary
|
2019-06-23 23:01:45 +09:00
|
|
|
|
this.parser = new Parser({
|
|
|
|
|
lexer: new Lexer(stream, this.opMap),
|
|
|
|
|
xref,
|
|
|
|
|
});
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.stateManager = stateManager;
|
2014-05-15 15:07:43 +09:00
|
|
|
|
this.nonProcessedArgs = [];
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
this._numInvalidPathOPS = 0;
|
2014-01-17 22:16:52 +09:00
|
|
|
|
}
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2014-01-17 22:16:52 +09:00
|
|
|
|
EvaluatorPreprocessor.prototype = {
|
|
|
|
|
get savedStatesDepth() {
|
2014-04-10 08:44:07 +09:00
|
|
|
|
return this.stateManager.stateStack.length;
|
2014-01-17 22:16:52 +09:00
|
|
|
|
},
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
2014-08-11 09:23:23 +09:00
|
|
|
|
// |operation| is an object with two fields:
|
|
|
|
|
//
|
|
|
|
|
// - |fn| is an out param.
|
|
|
|
|
//
|
|
|
|
|
// - |args| is an inout param. On entry, it should have one of two values.
|
|
|
|
|
//
|
|
|
|
|
// - An empty array. This indicates that the caller is providing the
|
|
|
|
|
// array in which the args will be stored in. The caller should use
|
|
|
|
|
// this value if it can reuse a single array for each call to read().
|
|
|
|
|
//
|
|
|
|
|
// - |null|. This indicates that the caller needs this function to create
|
|
|
|
|
// the array in which any args are stored in. If there are zero args,
|
|
|
|
|
// this function will leave |operation.args| as |null| (thus avoiding
|
|
|
|
|
// allocations that would occur if we used an empty array to represent
|
|
|
|
|
// zero arguments). Otherwise, it will replace |null| with a new array
|
|
|
|
|
// containing the arguments. The caller should use this value if it
|
|
|
|
|
// cannot reuse an array for each call to read().
|
|
|
|
|
//
|
|
|
|
|
// These two modes are present because this function is very hot and so
|
|
|
|
|
// avoiding allocations where possible is worthwhile.
|
|
|
|
|
//
|
2014-06-19 00:15:35 +09:00
|
|
|
|
read: function EvaluatorPreprocessor_read(operation) {
|
2014-08-11 09:23:23 +09:00
|
|
|
|
var args = operation.args;
|
2014-01-17 22:16:52 +09:00
|
|
|
|
while (true) {
|
|
|
|
|
var obj = this.parser.getObj();
|
2019-07-28 23:24:58 +09:00
|
|
|
|
if (obj instanceof Cmd) {
|
2014-06-19 19:47:00 +09:00
|
|
|
|
var cmd = obj.cmd;
|
|
|
|
|
// Check that the command is valid
|
2016-01-22 07:43:27 +09:00
|
|
|
|
var opSpec = this.opMap[cmd];
|
2014-06-19 19:47:00 +09:00
|
|
|
|
if (!opSpec) {
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
warn(`Unknown command "${cmd}".`);
|
2014-06-19 19:47:00 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fn = opSpec.id;
|
|
|
|
|
var numArgs = opSpec.numArgs;
|
2014-08-08 19:50:54 +09:00
|
|
|
|
var argsLength = args !== null ? args.length : 0;
|
2014-06-19 19:47:00 +09:00
|
|
|
|
|
|
|
|
|
if (!opSpec.variableArgs) {
|
|
|
|
|
// Postscript commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
|
|
|
|
|
if (argsLength !== numArgs) {
|
|
|
|
|
var nonProcessedArgs = this.nonProcessedArgs;
|
|
|
|
|
while (argsLength > numArgs) {
|
|
|
|
|
nonProcessedArgs.push(args.shift());
|
|
|
|
|
argsLength--;
|
|
|
|
|
}
|
|
|
|
|
while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
|
2016-11-15 21:09:41 +09:00
|
|
|
|
if (args === null) {
|
2014-06-19 19:47:00 +09:00
|
|
|
|
args = [];
|
|
|
|
|
}
|
|
|
|
|
args.unshift(nonProcessedArgs.pop());
|
|
|
|
|
argsLength++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argsLength < numArgs) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
const partialMsg =
|
|
|
|
|
`command ${cmd}: expected ${numArgs} args, ` +
|
|
|
|
|
`but received ${argsLength} args.`;
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
|
|
|
|
|
// Incomplete path operators, in particular, can result in fairly
|
|
|
|
|
// chaotic rendering artifacts. Hence the following heuristics is
|
|
|
|
|
// used to error, rather than just warn, once a number of invalid
|
|
|
|
|
// path operators have been encountered (fixes bug1443140.pdf).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
if (
|
|
|
|
|
fn >= OPS.moveTo &&
|
|
|
|
|
fn <= OPS.endPath && // Path operator
|
|
|
|
|
++this._numInvalidPathOPS > MAX_INVALID_PATH_OPS
|
|
|
|
|
) {
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
throw new FormatError(`Invalid ${partialMsg}`);
|
|
|
|
|
}
|
2016-11-15 21:09:41 +09:00
|
|
|
|
// If we receive too few arguments, it's not possible to execute
|
|
|
|
|
// the command, hence we skip the command.
|
Error, rather than warn, once a number of invalid path operators are encountered in `EvaluatorPreprocessor.read` (bug 1443140)
Incomplete path operators, in particular, can result in fairly chaotic rendering artifacts, as can be observed on page four of the referenced PDF file.
The initial (naive) solution that was attempted, was to simply throw a `FormatError` as soon as any invalid (i.e. too short) operator was found and rely on the existing `ignoreErrors` code-paths. However, doing so would have caused regressions in some files; see the existing `issue2391-1` test-case, which was promoted to an `eq` test to help prevent future bugs.
Hence this patch, which adds special handling for invalid path operators since those may cause quite bad rendering artifacts.
You could, in all fairness, argue that the patch is a handwavy solution and I wouldn't object. However, given that this only concerns *corrupt* PDF files, the way that PDF viewers (PDF.js included) try to gracefully deal with those could probably be described as a best-effort solution anyway.
This patch also adjusts the existing `warn`/`info` messages to print the command name according to the PDF specification, rather than an internal PDF.js enumeration value. The former should be much more useful for debugging purposes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1443140.
2018-06-24 16:53:32 +09:00
|
|
|
|
warn(`Skipping ${partialMsg}`);
|
2016-11-15 21:09:41 +09:00
|
|
|
|
if (args !== null) {
|
|
|
|
|
args.length = 0;
|
|
|
|
|
}
|
2014-06-19 19:47:00 +09:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else if (argsLength > numArgs) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
info(
|
|
|
|
|
`Command ${cmd}: expected [0, ${numArgs}] args, ` +
|
|
|
|
|
`but received ${argsLength} args.`
|
|
|
|
|
);
|
2014-06-19 19:47:00 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO figure out how to type-check vararg functions
|
|
|
|
|
this.preprocessCommand(fn, args);
|
|
|
|
|
|
|
|
|
|
operation.fn = fn;
|
|
|
|
|
operation.args = args;
|
|
|
|
|
return true;
|
2016-12-16 21:05:33 +09:00
|
|
|
|
}
|
2019-07-28 23:24:58 +09:00
|
|
|
|
if (obj === EOF) {
|
2016-12-16 21:05:33 +09:00
|
|
|
|
return false; // no more commands
|
|
|
|
|
}
|
|
|
|
|
// argument
|
|
|
|
|
if (obj !== null) {
|
|
|
|
|
if (args === null) {
|
|
|
|
|
args = [];
|
2014-01-17 22:16:52 +09:00
|
|
|
|
}
|
2016-12-16 21:05:33 +09:00
|
|
|
|
args.push(obj);
|
2017-07-20 21:04:54 +09:00
|
|
|
|
if (args.length > 33) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
throw new FormatError("Too many arguments");
|
2017-07-20 21:04:54 +09:00
|
|
|
|
}
|
2014-01-17 22:16:52 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2014-03-23 03:15:51 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(
|
|
|
|
|
fn,
|
|
|
|
|
args
|
|
|
|
|
) {
|
2014-01-17 22:16:52 +09:00
|
|
|
|
switch (fn | 0) {
|
|
|
|
|
case OPS.save:
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.stateManager.save();
|
2014-01-17 22:16:52 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.restore:
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.stateManager.restore();
|
2014-01-17 22:16:52 +09:00
|
|
|
|
break;
|
|
|
|
|
case OPS.transform:
|
2014-04-10 08:44:07 +09:00
|
|
|
|
this.stateManager.transform(args);
|
2014-01-17 22:16:52 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
|
},
|
2014-01-17 22:16:52 +09:00
|
|
|
|
};
|
|
|
|
|
return EvaluatorPreprocessor;
|
|
|
|
|
})();
|
2014-02-24 11:42:54 +09:00
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
export { PartialEvaluator };
|