2013-09-26 02:32:04 +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.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
CMapCompressionType,
|
|
|
|
FormatError,
|
|
|
|
isString,
|
|
|
|
unreachable,
|
|
|
|
warn,
|
2020-01-02 20:00:16 +09:00
|
|
|
} from "../shared/util.js";
|
|
|
|
import { isCmd, isEOF, isName, isStream } from "./primitives.js";
|
|
|
|
import { Lexer } from "./parser.js";
|
|
|
|
import { MissingDataException } from "./core_utils.js";
|
|
|
|
import { Stream } from "./stream.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
2014-02-12 03:27:09 +09:00
|
|
|
var BUILT_IN_CMAPS = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
// << Start unicode maps.
|
|
|
|
"Adobe-GB1-UCS2",
|
|
|
|
"Adobe-CNS1-UCS2",
|
|
|
|
"Adobe-Japan1-UCS2",
|
|
|
|
"Adobe-Korea1-UCS2",
|
|
|
|
// >> End unicode maps.
|
|
|
|
"78-EUC-H",
|
|
|
|
"78-EUC-V",
|
|
|
|
"78-H",
|
|
|
|
"78-RKSJ-H",
|
|
|
|
"78-RKSJ-V",
|
|
|
|
"78-V",
|
|
|
|
"78ms-RKSJ-H",
|
|
|
|
"78ms-RKSJ-V",
|
|
|
|
"83pv-RKSJ-H",
|
|
|
|
"90ms-RKSJ-H",
|
|
|
|
"90ms-RKSJ-V",
|
|
|
|
"90msp-RKSJ-H",
|
|
|
|
"90msp-RKSJ-V",
|
|
|
|
"90pv-RKSJ-H",
|
|
|
|
"90pv-RKSJ-V",
|
|
|
|
"Add-H",
|
|
|
|
"Add-RKSJ-H",
|
|
|
|
"Add-RKSJ-V",
|
|
|
|
"Add-V",
|
|
|
|
"Adobe-CNS1-0",
|
|
|
|
"Adobe-CNS1-1",
|
|
|
|
"Adobe-CNS1-2",
|
|
|
|
"Adobe-CNS1-3",
|
|
|
|
"Adobe-CNS1-4",
|
|
|
|
"Adobe-CNS1-5",
|
|
|
|
"Adobe-CNS1-6",
|
|
|
|
"Adobe-GB1-0",
|
|
|
|
"Adobe-GB1-1",
|
|
|
|
"Adobe-GB1-2",
|
|
|
|
"Adobe-GB1-3",
|
|
|
|
"Adobe-GB1-4",
|
|
|
|
"Adobe-GB1-5",
|
|
|
|
"Adobe-Japan1-0",
|
|
|
|
"Adobe-Japan1-1",
|
|
|
|
"Adobe-Japan1-2",
|
|
|
|
"Adobe-Japan1-3",
|
|
|
|
"Adobe-Japan1-4",
|
|
|
|
"Adobe-Japan1-5",
|
|
|
|
"Adobe-Japan1-6",
|
|
|
|
"Adobe-Korea1-0",
|
|
|
|
"Adobe-Korea1-1",
|
|
|
|
"Adobe-Korea1-2",
|
|
|
|
"B5-H",
|
|
|
|
"B5-V",
|
|
|
|
"B5pc-H",
|
|
|
|
"B5pc-V",
|
|
|
|
"CNS-EUC-H",
|
|
|
|
"CNS-EUC-V",
|
|
|
|
"CNS1-H",
|
|
|
|
"CNS1-V",
|
|
|
|
"CNS2-H",
|
|
|
|
"CNS2-V",
|
|
|
|
"ETHK-B5-H",
|
|
|
|
"ETHK-B5-V",
|
|
|
|
"ETen-B5-H",
|
|
|
|
"ETen-B5-V",
|
|
|
|
"ETenms-B5-H",
|
|
|
|
"ETenms-B5-V",
|
|
|
|
"EUC-H",
|
|
|
|
"EUC-V",
|
|
|
|
"Ext-H",
|
|
|
|
"Ext-RKSJ-H",
|
|
|
|
"Ext-RKSJ-V",
|
|
|
|
"Ext-V",
|
|
|
|
"GB-EUC-H",
|
|
|
|
"GB-EUC-V",
|
|
|
|
"GB-H",
|
|
|
|
"GB-V",
|
|
|
|
"GBK-EUC-H",
|
|
|
|
"GBK-EUC-V",
|
|
|
|
"GBK2K-H",
|
|
|
|
"GBK2K-V",
|
|
|
|
"GBKp-EUC-H",
|
|
|
|
"GBKp-EUC-V",
|
|
|
|
"GBT-EUC-H",
|
|
|
|
"GBT-EUC-V",
|
|
|
|
"GBT-H",
|
|
|
|
"GBT-V",
|
|
|
|
"GBTpc-EUC-H",
|
|
|
|
"GBTpc-EUC-V",
|
|
|
|
"GBpc-EUC-H",
|
|
|
|
"GBpc-EUC-V",
|
|
|
|
"H",
|
|
|
|
"HKdla-B5-H",
|
|
|
|
"HKdla-B5-V",
|
|
|
|
"HKdlb-B5-H",
|
|
|
|
"HKdlb-B5-V",
|
|
|
|
"HKgccs-B5-H",
|
|
|
|
"HKgccs-B5-V",
|
|
|
|
"HKm314-B5-H",
|
|
|
|
"HKm314-B5-V",
|
|
|
|
"HKm471-B5-H",
|
|
|
|
"HKm471-B5-V",
|
|
|
|
"HKscs-B5-H",
|
|
|
|
"HKscs-B5-V",
|
|
|
|
"Hankaku",
|
|
|
|
"Hiragana",
|
|
|
|
"KSC-EUC-H",
|
|
|
|
"KSC-EUC-V",
|
|
|
|
"KSC-H",
|
|
|
|
"KSC-Johab-H",
|
|
|
|
"KSC-Johab-V",
|
|
|
|
"KSC-V",
|
|
|
|
"KSCms-UHC-H",
|
|
|
|
"KSCms-UHC-HW-H",
|
|
|
|
"KSCms-UHC-HW-V",
|
|
|
|
"KSCms-UHC-V",
|
|
|
|
"KSCpc-EUC-H",
|
|
|
|
"KSCpc-EUC-V",
|
|
|
|
"Katakana",
|
|
|
|
"NWP-H",
|
|
|
|
"NWP-V",
|
|
|
|
"RKSJ-H",
|
|
|
|
"RKSJ-V",
|
|
|
|
"Roman",
|
|
|
|
"UniCNS-UCS2-H",
|
|
|
|
"UniCNS-UCS2-V",
|
|
|
|
"UniCNS-UTF16-H",
|
|
|
|
"UniCNS-UTF16-V",
|
|
|
|
"UniCNS-UTF32-H",
|
|
|
|
"UniCNS-UTF32-V",
|
|
|
|
"UniCNS-UTF8-H",
|
|
|
|
"UniCNS-UTF8-V",
|
|
|
|
"UniGB-UCS2-H",
|
|
|
|
"UniGB-UCS2-V",
|
|
|
|
"UniGB-UTF16-H",
|
|
|
|
"UniGB-UTF16-V",
|
|
|
|
"UniGB-UTF32-H",
|
|
|
|
"UniGB-UTF32-V",
|
|
|
|
"UniGB-UTF8-H",
|
|
|
|
"UniGB-UTF8-V",
|
|
|
|
"UniJIS-UCS2-H",
|
|
|
|
"UniJIS-UCS2-HW-H",
|
|
|
|
"UniJIS-UCS2-HW-V",
|
|
|
|
"UniJIS-UCS2-V",
|
|
|
|
"UniJIS-UTF16-H",
|
|
|
|
"UniJIS-UTF16-V",
|
|
|
|
"UniJIS-UTF32-H",
|
|
|
|
"UniJIS-UTF32-V",
|
|
|
|
"UniJIS-UTF8-H",
|
|
|
|
"UniJIS-UTF8-V",
|
|
|
|
"UniJIS2004-UTF16-H",
|
|
|
|
"UniJIS2004-UTF16-V",
|
|
|
|
"UniJIS2004-UTF32-H",
|
|
|
|
"UniJIS2004-UTF32-V",
|
|
|
|
"UniJIS2004-UTF8-H",
|
|
|
|
"UniJIS2004-UTF8-V",
|
|
|
|
"UniJISPro-UCS2-HW-V",
|
|
|
|
"UniJISPro-UCS2-V",
|
|
|
|
"UniJISPro-UTF8-V",
|
|
|
|
"UniJISX0213-UTF32-H",
|
|
|
|
"UniJISX0213-UTF32-V",
|
|
|
|
"UniJISX02132004-UTF32-H",
|
|
|
|
"UniJISX02132004-UTF32-V",
|
|
|
|
"UniKS-UCS2-H",
|
|
|
|
"UniKS-UCS2-V",
|
|
|
|
"UniKS-UTF16-H",
|
|
|
|
"UniKS-UTF16-V",
|
|
|
|
"UniKS-UTF32-H",
|
|
|
|
"UniKS-UTF32-V",
|
|
|
|
"UniKS-UTF8-H",
|
|
|
|
"UniKS-UTF8-V",
|
|
|
|
"V",
|
|
|
|
"WP-Symbol",
|
|
|
|
];
|
2013-09-26 02:32:04 +09:00
|
|
|
|
|
|
|
// CMap, not to be confused with TrueType's cmap.
|
2018-07-09 05:41:52 +09:00
|
|
|
class CMap {
|
|
|
|
constructor(builtInCMap = false) {
|
2013-09-26 02:32:04 +09:00
|
|
|
// Codespace ranges are stored as follows:
|
|
|
|
// [[1BytePairs], [2BytePairs], [3BytePairs], [4BytePairs]]
|
|
|
|
// where nBytePairs are ranges e.g. [low1, high1, low2, high2, ...]
|
|
|
|
this.codespaceRanges = [[], [], [], []];
|
2014-02-12 03:27:09 +09:00
|
|
|
this.numCodespaceRanges = 0;
|
2014-08-01 15:46:37 +09:00
|
|
|
// Map entries have one of two forms.
|
|
|
|
// - cid chars are 16-bit unsigned integers, stored as integers.
|
|
|
|
// - bf chars are variable-length byte sequences, stored as strings, with
|
|
|
|
// one byte per character.
|
2014-07-30 12:30:16 +09:00
|
|
|
this._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
|
|
|
this.name = "";
|
2013-09-26 02:32:04 +09:00
|
|
|
this.vertical = false;
|
2014-02-12 03:27:09 +09:00
|
|
|
this.useCMap = null;
|
|
|
|
this.builtInCMap = builtInCMap;
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
addCodespaceRange(n, low, high) {
|
|
|
|
this.codespaceRanges[n - 1].push(low, high);
|
|
|
|
this.numCodespaceRanges++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mapCidRange(low, high, dstLow) {
|
|
|
|
while (low <= high) {
|
|
|
|
this._map[low++] = dstLow++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mapBfRange(low, high, dstLow) {
|
|
|
|
var lastByte = dstLow.length - 1;
|
|
|
|
while (low <= high) {
|
|
|
|
this._map[low++] = dstLow;
|
|
|
|
// Only the last byte has to be incremented.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
dstLow =
|
|
|
|
dstLow.substring(0, lastByte) +
|
|
|
|
String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mapBfRangeToArray(low, high, array) {
|
2020-01-24 21:21:16 +09:00
|
|
|
const ii = array.length;
|
|
|
|
let i = 0;
|
2018-07-09 05:41:52 +09:00
|
|
|
while (low <= high && i < ii) {
|
|
|
|
this._map[low] = array[i++];
|
|
|
|
++low;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is used for both bf and cid chars.
|
|
|
|
mapOne(src, dst) {
|
|
|
|
this._map[src] = dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
lookup(code) {
|
|
|
|
return this._map[code];
|
|
|
|
}
|
|
|
|
|
|
|
|
contains(code) {
|
|
|
|
return this._map[code] !== undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
forEach(callback) {
|
|
|
|
// Most maps have fewer than 65536 entries, and for those we use normal
|
|
|
|
// array iteration. But really sparse tables are possible -- e.g. with
|
|
|
|
// indices in the *billions*. For such tables we use for..in, which isn't
|
|
|
|
// ideal because it stringifies the indices for all present elements, but
|
|
|
|
// it does avoid iterating over every undefined entry.
|
2020-01-24 17:48:21 +09:00
|
|
|
const map = this._map;
|
|
|
|
const length = map.length;
|
2018-07-09 05:41:52 +09:00
|
|
|
if (length <= 0x10000) {
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
if (map[i] !== undefined) {
|
2014-07-30 12:33:43 +09:00
|
|
|
callback(i, map[i]);
|
|
|
|
}
|
2014-07-30 12:30:16 +09:00
|
|
|
}
|
2018-07-09 05:41:52 +09:00
|
|
|
} else {
|
2020-01-24 17:48:21 +09:00
|
|
|
for (const i in map) {
|
2018-07-09 05:41:52 +09:00
|
|
|
callback(i, map[i]);
|
2017-05-25 00:36:39 +09:00
|
|
|
}
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
charCodeOf(value) {
|
|
|
|
// `Array.prototype.indexOf` is *extremely* inefficient for arrays which
|
|
|
|
// are both very sparse and very large (see issue8372.pdf).
|
|
|
|
const map = this._map;
|
|
|
|
if (map.length <= 0x10000) {
|
|
|
|
return map.indexOf(value);
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
for (const charCode in map) {
|
2018-07-09 05:41:52 +09:00
|
|
|
if (map[charCode] === 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 charCode | 0;
|
2017-05-25 00:36:39 +09:00
|
|
|
}
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
getMap() {
|
|
|
|
return this._map;
|
|
|
|
}
|
|
|
|
|
|
|
|
readCharCode(str, offset, out) {
|
|
|
|
let c = 0;
|
|
|
|
const codespaceRanges = this.codespaceRanges;
|
|
|
|
// 9.7.6.2 CMap Mapping
|
|
|
|
// The code length is at most 4.
|
|
|
|
for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
|
|
|
|
c = ((c << 8) | str.charCodeAt(offset + n)) >>> 0;
|
|
|
|
// Check each codespace range to see if it falls within.
|
|
|
|
const codespaceRange = codespaceRanges[n];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
for (let k = 0, kk = codespaceRange.length; k < kk; ) {
|
2018-07-09 05:41:52 +09:00
|
|
|
const low = codespaceRange[k++];
|
|
|
|
const high = codespaceRange[k++];
|
|
|
|
if (c >= low && c <= high) {
|
|
|
|
out.charcode = c;
|
|
|
|
out.length = n + 1;
|
|
|
|
return;
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
}
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
out.charcode = 0;
|
|
|
|
out.length = 1;
|
|
|
|
}
|
2015-03-06 23:01:26 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
get length() {
|
|
|
|
return this._map.length;
|
|
|
|
}
|
2015-09-19 23:54:19 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
get isIdentityCMap() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 (!(this.name === "Identity-H" || this.name === "Identity-V")) {
|
2018-07-09 05:41:52 +09:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (this._map.length !== 0x10000) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < 0x10000; i++) {
|
|
|
|
if (this._map[i] !== i) {
|
2015-03-06 23:01:26 +09:00
|
|
|
return false;
|
|
|
|
}
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-09-26 02:32:04 +09:00
|
|
|
|
2014-08-05 15:38:43 +09:00
|
|
|
// A special case of CMap, where the _map array implicitly has a length of
|
2015-03-06 23:01:26 +09:00
|
|
|
// 65536 and each element is equal to its index.
|
2018-07-09 05:41:52 +09:00
|
|
|
class IdentityCMap extends CMap {
|
|
|
|
constructor(vertical, n) {
|
|
|
|
super();
|
|
|
|
|
2013-09-26 02:32:04 +09:00
|
|
|
this.vertical = vertical;
|
|
|
|
this.addCodespaceRange(n, 0, 0xffff);
|
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
mapCidRange(low, high, dstLow) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("should not call mapCidRange");
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
mapBfRange(low, high, dstLow) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("should not call mapBfRange");
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
mapBfRangeToArray(low, high, array) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("should not call mapBfRangeToArray");
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
mapOne(src, dst) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("should not call mapCidOne");
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
lookup(code) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 Number.isInteger(code) && code <= 0xffff ? code : undefined;
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
contains(code) {
|
|
|
|
return Number.isInteger(code) && code <= 0xffff;
|
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
forEach(callback) {
|
|
|
|
for (let i = 0; i <= 0xffff; i++) {
|
|
|
|
callback(i, i);
|
|
|
|
}
|
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
charCodeOf(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 Number.isInteger(value) && value <= 0xffff ? value : -1;
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
2015-03-06 23:01:26 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
getMap() {
|
|
|
|
// Sometimes identity maps must be instantiated, but it's rare.
|
|
|
|
const map = new Array(0x10000);
|
|
|
|
for (let i = 0; i <= 0xffff; i++) {
|
|
|
|
map[i] = i;
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
2015-09-19 23:54:19 +09:00
|
|
|
|
2018-07-09 05:41:52 +09:00
|
|
|
get length() {
|
|
|
|
return 0x10000;
|
|
|
|
}
|
2014-08-05 15:38:43 +09:00
|
|
|
|
2019-12-26 04:03:46 +09:00
|
|
|
// eslint-disable-next-line getter-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
|
|
|
get isIdentityCMap() {
|
|
|
|
unreachable("should not access .isIdentityCMap");
|
2018-07-09 05:41:52 +09:00
|
|
|
}
|
|
|
|
}
|
2013-09-26 02:32:04 +09:00
|
|
|
|
2014-03-15 03:22:02 +09:00
|
|
|
var BinaryCMapReader = (function BinaryCMapReaderClosure() {
|
|
|
|
function hexToInt(a, size) {
|
|
|
|
var n = 0;
|
|
|
|
for (var i = 0; i <= size; i++) {
|
|
|
|
n = (n << 8) | a[i];
|
|
|
|
}
|
|
|
|
return n >>> 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function hexToStr(a, size) {
|
2014-07-23 14:09:54 +09:00
|
|
|
// This code is hot. Special-case some common values to avoid creating an
|
|
|
|
// object with subarray().
|
2014-08-06 11:55:59 +09:00
|
|
|
if (size === 1) {
|
2014-07-23 14:09:54 +09:00
|
|
|
return String.fromCharCode(a[0], a[1]);
|
|
|
|
}
|
2014-08-06 11:55:59 +09:00
|
|
|
if (size === 3) {
|
2014-07-23 14:09:54 +09:00
|
|
|
return String.fromCharCode(a[0], a[1], a[2], a[3]);
|
|
|
|
}
|
2014-03-15 03:22:02 +09:00
|
|
|
return String.fromCharCode.apply(null, a.subarray(0, size + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
function addHex(a, b, size) {
|
|
|
|
var c = 0;
|
|
|
|
for (var i = size; i >= 0; i--) {
|
|
|
|
c += a[i] + b[i];
|
|
|
|
a[i] = c & 255;
|
|
|
|
c >>= 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function incHex(a, size) {
|
|
|
|
var c = 1;
|
|
|
|
for (var i = size; i >= 0 && c > 0; i--) {
|
|
|
|
c += a[i];
|
|
|
|
a[i] = c & 255;
|
|
|
|
c >>= 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var MAX_NUM_SIZE = 16;
|
|
|
|
var MAX_ENCODED_NUM_SIZE = 19; // ceil(MAX_NUM_SIZE * 7 / 8)
|
|
|
|
|
|
|
|
function BinaryCMapStream(data) {
|
|
|
|
this.buffer = data;
|
|
|
|
this.pos = 0;
|
|
|
|
this.end = data.length;
|
|
|
|
this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BinaryCMapStream.prototype = {
|
2017-04-27 19:58:44 +09:00
|
|
|
readByte() {
|
2014-03-15 03:22:02 +09:00
|
|
|
if (this.pos >= this.end) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return this.buffer[this.pos++];
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readNumber() {
|
2014-03-15 03:22:02 +09:00
|
|
|
var n = 0;
|
|
|
|
var last;
|
|
|
|
do {
|
|
|
|
var b = this.readByte();
|
|
|
|
if (b < 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
|
|
|
throw new FormatError("unexpected EOF in bcmap");
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
|
|
|
last = !(b & 0x80);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
n = (n << 7) | (b & 0x7f);
|
2014-03-15 03:22:02 +09:00
|
|
|
} while (!last);
|
|
|
|
return n;
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readSigned() {
|
2014-03-15 03:22:02 +09:00
|
|
|
var n = this.readNumber();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 n & 1 ? ~(n >>> 1) : n >>> 1;
|
2014-03-15 03:22:02 +09:00
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readHex(num, size) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
|
2014-03-15 03:22:02 +09:00
|
|
|
this.pos += size + 1;
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readHexNumber(num, size) {
|
2014-03-15 03:22:02 +09:00
|
|
|
var last;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 stack = this.tmpBuf,
|
|
|
|
sp = 0;
|
2014-03-15 03:22:02 +09:00
|
|
|
do {
|
|
|
|
var b = this.readByte();
|
|
|
|
if (b < 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
|
|
|
throw new FormatError("unexpected EOF in bcmap");
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
|
|
|
last = !(b & 0x80);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
stack[sp++] = b & 0x7f;
|
2014-03-15 03:22:02 +09:00
|
|
|
} while (!last);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 = size,
|
|
|
|
buffer = 0,
|
|
|
|
bufferSize = 0;
|
2014-03-15 03:22:02 +09:00
|
|
|
while (i >= 0) {
|
|
|
|
while (bufferSize < 8 && stack.length > 0) {
|
|
|
|
buffer = (stack[--sp] << bufferSize) | buffer;
|
|
|
|
bufferSize += 7;
|
|
|
|
}
|
|
|
|
num[i] = buffer & 255;
|
|
|
|
i--;
|
|
|
|
buffer >>= 8;
|
|
|
|
bufferSize -= 8;
|
|
|
|
}
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readHexSigned(num, size) {
|
2014-03-15 03:22:02 +09:00
|
|
|
this.readHexNumber(num, size);
|
|
|
|
var sign = num[size] & 1 ? 255 : 0;
|
|
|
|
var c = 0;
|
|
|
|
for (var i = 0; i <= size; i++) {
|
|
|
|
c = ((c & 1) << 8) | num[i];
|
|
|
|
num[i] = (c >> 1) ^ sign;
|
|
|
|
}
|
|
|
|
},
|
2017-04-27 19:58:44 +09:00
|
|
|
readString() {
|
2014-03-15 03:22:02 +09:00
|
|
|
var len = this.readNumber();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 s = "";
|
2014-03-15 03:22:02 +09:00
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
s += String.fromCharCode(this.readNumber());
|
|
|
|
}
|
|
|
|
return s;
|
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-03-15 03:22:02 +09:00
|
|
|
};
|
|
|
|
|
2017-02-12 23:54:41 +09:00
|
|
|
function processBinaryCMap(data, cMap, extend) {
|
2020-04-14 19:28:14 +09:00
|
|
|
return new Promise(function (resolve, reject) {
|
2016-02-29 01:20:29 +09:00
|
|
|
var stream = new BinaryCMapStream(data);
|
|
|
|
var header = stream.readByte();
|
|
|
|
cMap.vertical = !!(header & 1);
|
|
|
|
|
|
|
|
var useCMap = null;
|
|
|
|
var start = new Uint8Array(MAX_NUM_SIZE);
|
|
|
|
var end = new Uint8Array(MAX_NUM_SIZE);
|
|
|
|
var char = new Uint8Array(MAX_NUM_SIZE);
|
|
|
|
var charCode = new Uint8Array(MAX_NUM_SIZE);
|
|
|
|
var tmp = new Uint8Array(MAX_NUM_SIZE);
|
|
|
|
var code;
|
|
|
|
|
|
|
|
var b;
|
|
|
|
while ((b = stream.readByte()) >= 0) {
|
|
|
|
var type = b >> 5;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 === 7) {
|
|
|
|
// metadata, e.g. comment or usecmap
|
|
|
|
switch (b & 0x1f) {
|
2016-02-29 01:20:29 +09:00
|
|
|
case 0:
|
|
|
|
stream.readString(); // skipping comment
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
useCMap = stream.readString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
var sequence = !!(b & 0x10);
|
|
|
|
var dataSize = b & 15;
|
2014-03-15 03:22:02 +09:00
|
|
|
|
2017-07-20 21:04:54 +09:00
|
|
|
if (dataSize + 1 > MAX_NUM_SIZE) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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("processBinaryCMap: Invalid dataSize.");
|
2017-07-20 21:04:54 +09:00
|
|
|
}
|
2014-03-15 03:22:02 +09:00
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
var ucs2DataSize = 1;
|
|
|
|
var subitemsCount = stream.readNumber();
|
|
|
|
var i;
|
|
|
|
switch (type) {
|
|
|
|
case 0: // codespacerange
|
|
|
|
stream.readHex(start, dataSize);
|
2014-03-15 03:22:02 +09:00
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.addCodespaceRange(
|
|
|
|
dataSize + 1,
|
|
|
|
hexToInt(start, dataSize),
|
|
|
|
hexToInt(end, dataSize)
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(end, dataSize);
|
|
|
|
stream.readHexNumber(start, dataSize);
|
|
|
|
addHex(start, end, dataSize);
|
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.addCodespaceRange(
|
|
|
|
dataSize + 1,
|
|
|
|
hexToInt(start, dataSize),
|
|
|
|
hexToInt(end, dataSize)
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: // notdefrange
|
|
|
|
stream.readHex(start, dataSize);
|
2014-03-15 03:22:02 +09:00
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
2017-11-03 18:39:11 +09:00
|
|
|
stream.readNumber(); // code
|
2016-02-29 01:20:29 +09:00
|
|
|
// undefined range, skipping
|
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(end, dataSize);
|
2014-03-15 03:22:02 +09:00
|
|
|
stream.readHexNumber(start, dataSize);
|
|
|
|
addHex(start, end, dataSize);
|
2016-02-29 01:20:29 +09:00
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
2017-11-03 18:39:11 +09:00
|
|
|
stream.readNumber(); // code
|
2016-02-29 01:20:29 +09:00
|
|
|
// nop
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
break;
|
|
|
|
case 2: // cidchar
|
|
|
|
stream.readHex(char, dataSize);
|
|
|
|
code = stream.readNumber();
|
|
|
|
cMap.mapOne(hexToInt(char, dataSize), code);
|
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(char, dataSize);
|
|
|
|
if (!sequence) {
|
|
|
|
stream.readHexNumber(tmp, dataSize);
|
|
|
|
addHex(char, tmp, dataSize);
|
|
|
|
}
|
|
|
|
code = stream.readSigned() + (code + 1);
|
|
|
|
cMap.mapOne(hexToInt(char, dataSize), code);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: // cidrange
|
|
|
|
stream.readHex(start, dataSize);
|
2014-03-15 03:22:02 +09:00
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
|
|
|
code = stream.readNumber();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapCidRange(
|
|
|
|
hexToInt(start, dataSize),
|
|
|
|
hexToInt(end, dataSize),
|
|
|
|
code
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(end, dataSize);
|
|
|
|
if (!sequence) {
|
|
|
|
stream.readHexNumber(start, dataSize);
|
|
|
|
addHex(start, end, dataSize);
|
|
|
|
} else {
|
|
|
|
start.set(end);
|
|
|
|
}
|
|
|
|
stream.readHexNumber(end, dataSize);
|
|
|
|
addHex(end, start, dataSize);
|
|
|
|
code = stream.readNumber();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapCidRange(
|
|
|
|
hexToInt(start, dataSize),
|
|
|
|
hexToInt(end, dataSize),
|
|
|
|
code
|
|
|
|
);
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
break;
|
|
|
|
case 4: // bfchar
|
|
|
|
stream.readHex(char, ucs2DataSize);
|
|
|
|
stream.readHex(charCode, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapOne(
|
|
|
|
hexToInt(char, ucs2DataSize),
|
|
|
|
hexToStr(charCode, dataSize)
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(char, ucs2DataSize);
|
|
|
|
if (!sequence) {
|
|
|
|
stream.readHexNumber(tmp, ucs2DataSize);
|
|
|
|
addHex(char, tmp, ucs2DataSize);
|
|
|
|
}
|
|
|
|
incHex(charCode, dataSize);
|
|
|
|
stream.readHexSigned(tmp, dataSize);
|
|
|
|
addHex(charCode, tmp, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapOne(
|
|
|
|
hexToInt(char, ucs2DataSize),
|
|
|
|
hexToStr(charCode, dataSize)
|
|
|
|
);
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
break;
|
|
|
|
case 5: // bfrange
|
|
|
|
stream.readHex(start, ucs2DataSize);
|
2014-03-15 03:22:02 +09:00
|
|
|
stream.readHexNumber(end, ucs2DataSize);
|
|
|
|
addHex(end, start, ucs2DataSize);
|
|
|
|
stream.readHex(charCode, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapBfRange(
|
|
|
|
hexToInt(start, ucs2DataSize),
|
|
|
|
hexToInt(end, ucs2DataSize),
|
|
|
|
hexToStr(charCode, dataSize)
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
for (i = 1; i < subitemsCount; i++) {
|
|
|
|
incHex(end, ucs2DataSize);
|
|
|
|
if (!sequence) {
|
|
|
|
stream.readHexNumber(start, ucs2DataSize);
|
|
|
|
addHex(start, end, ucs2DataSize);
|
|
|
|
} else {
|
|
|
|
start.set(end);
|
|
|
|
}
|
|
|
|
stream.readHexNumber(end, ucs2DataSize);
|
|
|
|
addHex(end, start, ucs2DataSize);
|
|
|
|
stream.readHex(charCode, dataSize);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cMap.mapBfRange(
|
|
|
|
hexToInt(start, ucs2DataSize),
|
|
|
|
hexToInt(end, ucs2DataSize),
|
|
|
|
hexToStr(charCode, dataSize)
|
|
|
|
);
|
2016-02-29 01:20:29 +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
|
|
|
reject(new Error("processBinaryCMap: Unknown type: " + type));
|
2017-02-12 23:54:41 +09:00
|
|
|
return;
|
2016-02-29 01:20:29 +09:00
|
|
|
}
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
|
|
|
|
2016-02-29 01:20:29 +09:00
|
|
|
if (useCMap) {
|
2017-02-12 23:54:41 +09:00
|
|
|
resolve(extend(useCMap));
|
|
|
|
return;
|
2016-02-29 01:20:29 +09:00
|
|
|
}
|
2017-02-12 23:54:41 +09:00
|
|
|
resolve(cMap);
|
2016-02-29 01:20:29 +09:00
|
|
|
});
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2014-03-15 03:22:02 +09:00
|
|
|
function BinaryCMapReader() {}
|
|
|
|
|
|
|
|
BinaryCMapReader.prototype = {
|
2017-02-12 23:54:41 +09:00
|
|
|
process: processBinaryCMap,
|
2014-03-15 03:22:02 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
return BinaryCMapReader;
|
|
|
|
})();
|
|
|
|
|
2013-09-26 02:32:04 +09:00
|
|
|
var CMapFactory = (function CMapFactoryClosure() {
|
|
|
|
function strToInt(str) {
|
|
|
|
var a = 0;
|
|
|
|
for (var i = 0; i < str.length; i++) {
|
|
|
|
a = (a << 8) | str.charCodeAt(i);
|
|
|
|
}
|
|
|
|
return a >>> 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectString(obj) {
|
|
|
|
if (!isString(obj)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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("Malformed CMap: expected string.");
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectInt(obj) {
|
2017-09-01 23:52:50 +09:00
|
|
|
if (!Number.isInteger(obj)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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("Malformed CMap: expected int.");
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseBfChar(cMap, lexer) {
|
|
|
|
while (true) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
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
|
|
|
if (isCmd(obj, "endbfchar")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
expectString(obj);
|
|
|
|
var src = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
// TODO are /dstName used?
|
|
|
|
expectString(obj);
|
|
|
|
var dst = obj;
|
|
|
|
cMap.mapOne(src, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseBfRange(cMap, lexer) {
|
|
|
|
while (true) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
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
|
|
|
if (isCmd(obj, "endbfrange")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
expectString(obj);
|
|
|
|
var low = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
expectString(obj);
|
|
|
|
var high = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
2017-09-01 23:52:50 +09:00
|
|
|
if (Number.isInteger(obj) || isString(obj)) {
|
|
|
|
var dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
|
2014-08-01 15:46:37 +09:00
|
|
|
cMap.mapBfRange(low, high, dstLow);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 if (isCmd(obj, "[")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
obj = lexer.getObj();
|
|
|
|
var array = [];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
while (!isCmd(obj, "]") && !isEOF(obj)) {
|
2013-09-26 02:32:04 +09:00
|
|
|
array.push(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
}
|
2014-08-01 15:46:37 +09:00
|
|
|
cMap.mapBfRangeToArray(low, high, array);
|
2013-09-26 02:32:04 +09:00
|
|
|
} else {
|
|
|
|
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
|
|
|
throw new FormatError("Invalid bf range.");
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function parseCidChar(cMap, lexer) {
|
|
|
|
while (true) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
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
|
|
|
if (isCmd(obj, "endcidchar")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
expectString(obj);
|
|
|
|
var src = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
expectInt(obj);
|
2014-08-01 15:46:37 +09:00
|
|
|
var dst = obj;
|
2013-09-26 02:32:04 +09:00
|
|
|
cMap.mapOne(src, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseCidRange(cMap, lexer) {
|
|
|
|
while (true) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
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
|
|
|
if (isCmd(obj, "endcidrange")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
expectString(obj);
|
|
|
|
var low = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
expectString(obj);
|
|
|
|
var high = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
expectInt(obj);
|
2014-08-01 15:46:37 +09:00
|
|
|
var dstLow = obj;
|
|
|
|
cMap.mapCidRange(low, high, dstLow);
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseCodespaceRange(cMap, lexer) {
|
|
|
|
while (true) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
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
|
|
|
if (isCmd(obj, "endcodespacerange")) {
|
2013-09-26 02:32:04 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isString(obj)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
var low = strToInt(obj);
|
|
|
|
obj = lexer.getObj();
|
|
|
|
if (!isString(obj)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
var high = strToInt(obj);
|
|
|
|
cMap.addCodespaceRange(obj.length, low, high);
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 codespace range.");
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
|
2014-02-12 03:27:09 +09:00
|
|
|
function parseWMode(cMap, lexer) {
|
|
|
|
var obj = lexer.getObj();
|
2017-09-01 23:52:50 +09:00
|
|
|
if (Number.isInteger(obj)) {
|
2014-02-12 03:27:09 +09:00
|
|
|
cMap.vertical = !!obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-06 23:01:26 +09:00
|
|
|
function parseCMapName(cMap, lexer) {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isName(obj) && isString(obj.name)) {
|
|
|
|
cMap.name = obj.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 23:54:41 +09:00
|
|
|
function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
|
2014-02-12 03:27:09 +09:00
|
|
|
var previous;
|
2018-04-02 06:20:41 +09:00
|
|
|
var embeddedUseCMap;
|
2013-09-26 02:32:04 +09:00
|
|
|
objLoop: while (true) {
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
try {
|
|
|
|
var obj = lexer.getObj();
|
|
|
|
if (isEOF(obj)) {
|
|
|
|
break;
|
|
|
|
} else if (isName(obj)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 (obj.name === "WMode") {
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseWMode(cMap, 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
|
|
|
} else if (obj.name === "CMapName") {
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseCMapName(cMap, lexer);
|
|
|
|
}
|
|
|
|
previous = obj;
|
|
|
|
} else if (isCmd(obj)) {
|
|
|
|
switch (obj.cmd) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 "endcmap":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
break objLoop;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 "usecmap":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
if (isName(previous)) {
|
2018-04-02 06:20:41 +09:00
|
|
|
embeddedUseCMap = previous.name;
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +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 "begincodespacerange":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseCodespaceRange(cMap, lexer);
|
|
|
|
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 "beginbfchar":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseBfChar(cMap, lexer);
|
|
|
|
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 "begincidchar":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseCidChar(cMap, lexer);
|
|
|
|
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 "beginbfrange":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseBfRange(cMap, lexer);
|
|
|
|
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 "begincidrange":
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
parseCidRange(cMap, lexer);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
} catch (ex) {
|
|
|
|
if (ex instanceof MissingDataException) {
|
|
|
|
throw ex;
|
2013-09-26 02: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
|
|
|
warn("Invalid cMap data: " + ex);
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
continue;
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
2018-04-02 06:20:41 +09:00
|
|
|
if (!useCMap && embeddedUseCMap) {
|
|
|
|
// Load the useCMap definition from the file only if there wasn't one
|
2014-02-12 03:27:09 +09:00
|
|
|
// specified.
|
2018-04-02 06:20:41 +09:00
|
|
|
useCMap = embeddedUseCMap;
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
|
|
|
if (useCMap) {
|
2017-02-12 23:54:41 +09:00
|
|
|
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
Catch errors and continue parsing in `parseCMap` (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.
The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.
Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.
Fixes 7492.
2016-07-18 23:01:02 +09:00
|
|
|
return Promise.resolve(cMap);
|
2014-03-15 03:22:02 +09:00
|
|
|
}
|
|
|
|
|
2017-02-12 23:54:41 +09:00
|
|
|
function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
|
2020-04-14 19:28:14 +09:00
|
|
|
return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (
|
|
|
|
newCMap
|
|
|
|
) {
|
2016-02-29 01:20:29 +09:00
|
|
|
cMap.useCMap = newCMap;
|
|
|
|
// If there aren't any code space ranges defined clone all the parent ones
|
|
|
|
// into this cMap.
|
|
|
|
if (cMap.numCodespaceRanges === 0) {
|
|
|
|
var useCodespaceRanges = cMap.useCMap.codespaceRanges;
|
|
|
|
for (var i = 0; i < useCodespaceRanges.length; i++) {
|
|
|
|
cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
|
|
|
|
}
|
|
|
|
cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
2016-02-29 01:20:29 +09:00
|
|
|
// Merge the map into the current one, making sure not to override
|
|
|
|
// any previously defined entries.
|
2020-04-14 19:28:14 +09:00
|
|
|
cMap.useCMap.forEach(function (key, value) {
|
2016-02-29 01:20:29 +09:00
|
|
|
if (!cMap.contains(key)) {
|
|
|
|
cMap.mapOne(key, cMap.useCMap.lookup(key));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return cMap;
|
2014-07-30 12:30:16 +09:00
|
|
|
});
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
|
|
|
|
2017-02-12 23:54:41 +09:00
|
|
|
function createBuiltInCMap(name, fetchBuiltInCMap) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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 (name === "Identity-H") {
|
2016-02-29 01:20:29 +09:00
|
|
|
return Promise.resolve(new IdentityCMap(false, 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
|
|
|
} else if (name === "Identity-V") {
|
2016-02-29 01:20:29 +09:00
|
|
|
return Promise.resolve(new IdentityCMap(true, 2));
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
2018-02-04 22:50:58 +09:00
|
|
|
if (!BUILT_IN_CMAPS.includes(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 Promise.reject(new Error("Unknown CMap name: " + name));
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
2017-07-20 21:04:54 +09:00
|
|
|
if (!fetchBuiltInCMap) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *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.reject(
|
|
|
|
new Error("Built-in CMap parameters are not provided.")
|
|
|
|
);
|
2017-07-20 21:04:54 +09:00
|
|
|
}
|
2014-03-15 03:22:02 +09:00
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
return fetchBuiltInCMap(name).then(function (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
|
|
|
var cMapData = data.cMapData,
|
|
|
|
compressionType = data.compressionType;
|
2017-02-12 23:54:41 +09:00
|
|
|
var cMap = new CMap(true);
|
2014-02-12 03:27:09 +09:00
|
|
|
|
2017-02-12 23:54:41 +09:00
|
|
|
if (compressionType === CMapCompressionType.BINARY) {
|
2020-04-14 19:28:14 +09:00
|
|
|
return new BinaryCMapReader().process(cMapData, cMap, function (
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
useCMap
|
|
|
|
) {
|
2017-02-12 23:54:41 +09:00
|
|
|
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
|
|
|
|
});
|
|
|
|
}
|
2017-07-20 21:04:54 +09:00
|
|
|
if (compressionType === CMapCompressionType.NONE) {
|
|
|
|
var lexer = new Lexer(new Stream(cMapData));
|
|
|
|
return parseCMap(cMap, lexer, fetchBuiltInCMap, 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 Promise.reject(
|
|
|
|
new Error(
|
|
|
|
"TODO: Only BINARY/NONE CMap compression is currently supported."
|
|
|
|
)
|
|
|
|
);
|
2016-02-29 01:20:29 +09:00
|
|
|
});
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
2013-09-26 02:32:04 +09:00
|
|
|
return {
|
2020-01-30 21:13:51 +09:00
|
|
|
async create(params) {
|
2017-02-12 23:54:41 +09:00
|
|
|
var encoding = params.encoding;
|
|
|
|
var fetchBuiltInCMap = params.fetchBuiltInCMap;
|
|
|
|
var useCMap = params.useCMap;
|
|
|
|
|
2013-09-26 02:32:04 +09:00
|
|
|
if (isName(encoding)) {
|
2017-02-12 23:54:41 +09:00
|
|
|
return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
|
2013-09-26 02:32:04 +09:00
|
|
|
} else if (isStream(encoding)) {
|
|
|
|
var cMap = new CMap();
|
|
|
|
var lexer = new Lexer(encoding);
|
2020-04-14 19:28:14 +09:00
|
|
|
return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
parsedCMap
|
|
|
|
) {
|
2016-02-29 01:20:29 +09:00
|
|
|
if (parsedCMap.isIdentityCMap) {
|
2017-02-12 23:54:41 +09:00
|
|
|
return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
|
2016-02-29 01:20:29 +09:00
|
|
|
}
|
|
|
|
return parsedCMap;
|
|
|
|
});
|
2013-09-26 02:32:04 +09:00
|
|
|
}
|
2020-01-30 21:13:51 +09:00
|
|
|
throw new Error("Encoding required.");
|
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-26 02:32:04 +09:00
|
|
|
};
|
|
|
|
})();
|
2015-11-22 01:32:47 +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 { CMap, IdentityCMap, CMapFactory };
|