1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02: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.)
This commit is contained in:
Jonas Jenwald 2019-12-25 15:59:37 +01:00
parent 8ec1dfde49
commit de36b2aaba
205 changed files with 40024 additions and 31859 deletions

View file

@ -14,17 +14,25 @@
*/
import {
bytesToString, FONT_IDENTITY_MATRIX, FormatError, unreachable, warn
} from '../shared/util';
import { CFFParser } from './cff_parser';
import { getGlyphsUnicode } from './glyphlist';
import { StandardEncoding } from './encodings';
import { Stream } from './stream';
bytesToString,
FONT_IDENTITY_MATRIX,
FormatError,
unreachable,
warn,
} from "../shared/util";
import { CFFParser } from "./cff_parser";
import { getGlyphsUnicode } from "./glyphlist";
import { StandardEncoding } from "./encodings";
import { Stream } from "./stream";
var FontRendererFactory = (function FontRendererFactoryClosure() {
function getLong(data, offset) {
return (data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3];
return (
(data[offset] << 24) |
(data[offset + 1] << 16) |
(data[offset + 2] << 8) |
data[offset + 3]
);
}
function getUshort(data, offset) {
@ -32,8 +40,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
function parseCmap(data, start, end) {
var offset = (getUshort(data, start + 2) === 1 ?
getLong(data, start + 8) : getLong(data, start + 16));
var offset =
getUshort(data, start + 2) === 1
? getLong(data, start + 8)
: getLong(data, start + 16);
var format = getUshort(data, start + offset);
var ranges, p, i;
if (format === 4) {
@ -42,7 +52,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
p = start + offset + 14;
ranges = [];
for (i = 0; i < segCount; i++, p += 2) {
ranges[i] = { end: getUshort(data, p), };
ranges[i] = { end: getUshort(data, p) };
}
p += 2;
for (i = 0; i < segCount; i++, p += 2) {
@ -83,13 +93,18 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
function parseCff(data, start, end, seacAnalysisEnabled) {
var properties = {};
var parser = new CFFParser(new Stream(data, start, end - start),
properties, seacAnalysisEnabled);
var parser = new CFFParser(
new Stream(data, start, end - start),
properties,
seacAnalysisEnabled
);
var cff = parser.parse();
return {
glyphs: cff.charStrings.objects,
subrs: (cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex &&
cff.topDict.privateDict.subrsIndex.objects),
subrs:
cff.topDict.privateDict &&
cff.topDict.privateDict.subrsIndex &&
cff.topDict.privateDict.subrsIndex.objects,
gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects,
isCFFCIDFont: cff.isCIDFont,
fdSelect: cff.fdSelect,
@ -102,8 +117,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
if (isGlyphLocationsLong) {
itemSize = 4;
itemDecode = function fontItemDecodeLong(data, offset) {
return (data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3];
return (
(data[offset] << 24) |
(data[offset + 1] << 16) |
(data[offset + 2] << 8) |
data[offset + 3]
);
};
} else {
itemSize = 2;
@ -122,8 +141,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
function lookupCmap(ranges, unicode) {
var code = unicode.codePointAt(0), gid = 0;
var l = 0, r = ranges.length - 1;
var code = unicode.codePointAt(0),
gid = 0;
var l = 0,
r = ranges.length - 1;
while (l < r) {
var c = (l + r + 1) >> 1;
if (code < ranges[c].start) {
@ -133,8 +154,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
if (ranges[l].start <= code && code <= ranges[l].end) {
gid = (ranges[l].idDelta + (ranges[l].ids ?
ranges[l].ids[code - ranges[l].start] : code)) & 0xFFFF;
gid =
(ranges[l].idDelta +
(ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code)) &
0xffff;
}
return {
charCode: code,
@ -144,19 +167,20 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
function compileGlyf(code, cmds, font) {
function moveTo(x, y) {
cmds.push({ cmd: 'moveTo', args: [x, y], });
cmds.push({ cmd: "moveTo", args: [x, y] });
}
function lineTo(x, y) {
cmds.push({ cmd: 'lineTo', args: [x, y], });
cmds.push({ cmd: "lineTo", args: [x, y] });
}
function quadraticCurveTo(xa, ya, x, y) {
cmds.push({ cmd: 'quadraticCurveTo', args: [xa, ya, x, y], });
cmds.push({ cmd: "quadraticCurveTo", args: [xa, ya, x, y] });
}
var i = 0;
var numberOfContours = ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
var flags;
var x = 0, y = 0;
var x = 0,
y = 0;
i += 10;
if (numberOfContours < 0) {
// composite glyph
@ -165,29 +189,34 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
var glyphIndex = (code[i + 2] << 8) | code[i + 3];
i += 4;
var arg1, arg2;
if ((flags & 0x01)) {
if (flags & 0x01) {
arg1 = ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
arg2 = ((code[i + 2] << 24) | (code[i + 3] << 16)) >> 16;
i += 4;
} else {
arg1 = code[i++]; arg2 = code[i++];
arg1 = code[i++];
arg2 = code[i++];
}
if ((flags & 0x02)) {
x = arg1;
y = arg2;
if (flags & 0x02) {
x = arg1;
y = arg2;
} else {
x = 0; y = 0; // TODO "they are points" ?
x = 0;
y = 0; // TODO "they are points" ?
}
var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
if ((flags & 0x08)) {
scaleX =
scaleY = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
var scaleX = 1,
scaleY = 1,
scale01 = 0,
scale10 = 0;
if (flags & 0x08) {
scaleX = scaleY =
((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
i += 2;
} else if ((flags & 0x40)) {
} else if (flags & 0x40) {
scaleX = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
scaleY = ((code[i + 2] << 24) | (code[i + 3] << 16)) / 1073741824;
i += 4;
} else if ((flags & 0x80)) {
} else if (flags & 0x80) {
scaleX = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
scale01 = ((code[i + 2] << 24) | (code[i + 3] << 16)) / 1073741824;
scale10 = ((code[i + 4] << 24) | (code[i + 5] << 16)) / 1073741824;
@ -196,13 +225,15 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
var subglyph = font.glyphs[glyphIndex];
if (subglyph) {
cmds.push({ cmd: 'save', });
cmds.push({ cmd: 'transform',
args: [scaleX, scale01, scale10, scaleY, x, y], });
cmds.push({ cmd: "save" });
cmds.push({
cmd: "transform",
args: [scaleX, scale01, scale10, scaleY, x, y],
});
compileGlyf(subglyph, cmds, font);
cmds.push({ cmd: 'restore', });
cmds.push({ cmd: "restore" });
}
} while ((flags & 0x20));
} while (flags & 0x20);
} else {
// simple glyph
var endPtsOfContours = [];
@ -218,11 +249,11 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
while (points.length < numberOfPoints) {
flags = code[i++];
var repeat = 1;
if ((flags & 0x08)) {
if (flags & 0x08) {
repeat += code[i++];
}
while (repeat-- > 0) {
points.push({ flags, });
points.push({ flags });
}
}
for (j = 0; j < numberOfPoints; j++) {
@ -262,9 +293,9 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
// contours might have implicit points, which is located in the middle
// between two neighboring off-curve points
var contour = points.slice(startPoint, endPoint + 1);
if ((contour[0].flags & 1)) {
if (contour[0].flags & 1) {
contour.push(contour[0]); // using start point at the contour end
} else if ((contour[contour.length - 1].flags & 1)) {
} else if (contour[contour.length - 1].flags & 1) {
// first is off-curve point, trying to use one from the end
contour.unshift(contour[contour.length - 1]);
} else {
@ -279,16 +310,23 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
moveTo(contour[0].x, contour[0].y);
for (j = 1, jj = contour.length; j < jj; j++) {
if ((contour[j].flags & 1)) {
if (contour[j].flags & 1) {
lineTo(contour[j].x, contour[j].y);
} else if ((contour[j + 1].flags & 1)) {
quadraticCurveTo(contour[j].x, contour[j].y,
contour[j + 1].x, contour[j + 1].y);
} else if (contour[j + 1].flags & 1) {
quadraticCurveTo(
contour[j].x,
contour[j].y,
contour[j + 1].x,
contour[j + 1].y
);
j++;
} else {
quadraticCurveTo(contour[j].x, contour[j].y,
quadraticCurveTo(
contour[j].x,
contour[j].y,
(contour[j].x + contour[j + 1].x) / 2,
(contour[j].y + contour[j + 1].y) / 2);
(contour[j].y + contour[j + 1].y) / 2
);
}
}
startPoint = endPoint + 1;
@ -298,17 +336,18 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
function compileCharString(code, cmds, font, glyphId) {
var stack = [];
var x = 0, y = 0;
var x = 0,
y = 0;
var stems = 0;
function moveTo(x, y) {
cmds.push({ cmd: 'moveTo', args: [x, y], });
cmds.push({ cmd: "moveTo", args: [x, y] });
}
function lineTo(x, y) {
cmds.push({ cmd: 'lineTo', args: [x, y], });
cmds.push({ cmd: "lineTo", args: [x, y] });
}
function bezierCurveTo(x1, y1, x2, y2, x, y) {
cmds.push({ cmd: 'bezierCurveTo', args: [x1, y1, x2, y2, x, y], });
cmds.push({ cmd: "bezierCurveTo", args: [x1, y1, x2, y2, x, y] });
}
function parse(code) {
@ -362,9 +401,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
case 8: // rrcurveto
while (stack.length > 0) {
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
}
break;
@ -374,19 +416,19 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
if (font.isCFFCIDFont) {
let fdIndex = font.fdSelect.getFDIndex(glyphId);
if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
let fontDict = font.fdArray[fdIndex], subrs;
let fontDict = font.fdArray[fdIndex],
subrs;
if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
subrs = fontDict.privateDict.subrsIndex.objects;
}
if (subrs) {
let numSubrs = subrs.length;
// Add subroutine bias.
n += numSubrs < 1240 ? 107 :
(numSubrs < 33900 ? 1131 : 32768);
n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
subrCode = subrs[n];
}
} else {
warn('Invalid fd index for glyph index.');
warn("Invalid fd index for glyph index.");
}
} else {
subrCode = font.subrs[n + font.subrsBias];
@ -402,7 +444,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
switch (v) {
case 34: // flex
xa = x + stack.shift();
xb = xa + stack.shift(); y1 = y + stack.shift();
xb = xa + stack.shift();
y1 = y + stack.shift();
x = xb + stack.shift();
bezierCurveTo(xa, y, xb, y1, x, y1);
xa = x + stack.shift();
@ -411,35 +454,51 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
bezierCurveTo(xa, y1, xb, y, x, y);
break;
case 35: // flex
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
stack.pop(); // fd
break;
case 36: // hflex1
xa = x + stack.shift(); y1 = y + stack.shift();
xb = xa + stack.shift(); y2 = y1 + stack.shift();
xa = x + stack.shift();
y1 = y + stack.shift();
xb = xa + stack.shift();
y2 = y1 + stack.shift();
x = xb + stack.shift();
bezierCurveTo(xa, y1, xb, y2, x, y2);
xa = x + stack.shift();
xb = xa + stack.shift(); y3 = y2 + stack.shift();
xb = xa + stack.shift();
y3 = y2 + stack.shift();
x = xb + stack.shift();
bezierCurveTo(xa, y2, xb, y3, x, y);
break;
case 37: // flex1
var x0 = x, y0 = y;
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
var x0 = x,
y0 = y;
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb; y = yb;
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb;
y = yb;
if (Math.abs(x - x0) > Math.abs(y - y0)) {
x += stack.shift();
} else {
@ -457,18 +516,30 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
var bchar = stack.pop();
y = stack.pop();
x = stack.pop();
cmds.push({ cmd: 'save', });
cmds.push({ cmd: 'translate', args: [x, y], });
var cmap = lookupCmap(font.cmap, String.fromCharCode(
font.glyphNameMap[StandardEncoding[achar]]));
compileCharString(font.glyphs[cmap.glyphId], cmds, font,
cmap.glyphId);
cmds.push({ cmd: 'restore', });
cmds.push({ cmd: "save" });
cmds.push({ cmd: "translate", args: [x, y] });
var cmap = lookupCmap(
font.cmap,
String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]])
);
compileCharString(
font.glyphs[cmap.glyphId],
cmds,
font,
cmap.glyphId
);
cmds.push({ cmd: "restore" });
cmap = lookupCmap(font.cmap, String.fromCharCode(
font.glyphNameMap[StandardEncoding[bchar]]));
compileCharString(font.glyphs[cmap.glyphId], cmds, font,
cmap.glyphId);
cmap = lookupCmap(
font.cmap,
String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]])
);
compileCharString(
font.glyphs[cmap.glyphId],
cmds,
font,
cmap.glyphId
);
}
return;
case 18: // hstemhm
@ -502,9 +573,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
case 24: // rcurveline
while (stack.length > 2) {
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
}
x += stack.shift();
@ -517,9 +591,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
y += stack.shift();
lineTo(x, y);
}
xa = x + stack.shift(); ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb + stack.shift();
xa = x + stack.shift();
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
break;
case 26: // vvcurveto
@ -527,9 +604,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
x += stack.shift();
}
while (stack.length > 0) {
xa = x; ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb; y = yb + stack.shift();
xa = x;
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb;
y = yb + stack.shift();
bezierCurveTo(xa, ya, xb, yb, x, y);
}
break;
@ -538,9 +618,12 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
y += stack.shift();
}
while (stack.length > 0) {
xa = x + stack.shift(); ya = y;
xb = xa + stack.shift(); yb = ya + stack.shift();
x = xb + stack.shift(); y = yb;
xa = x + stack.shift();
ya = y;
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb;
bezierCurveTo(xa, ya, xb, yb, x, y);
}
break;
@ -557,8 +640,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
case 30: // vhcurveto
while (stack.length > 0) {
xa = x; ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
xa = x;
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
@ -566,8 +651,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
}
xa = x + stack.shift(); ya = y;
xb = xa + stack.shift(); yb = ya + stack.shift();
xa = x + stack.shift();
ya = y;
xb = xa + stack.shift();
yb = ya + stack.shift();
y = yb + stack.shift();
x = xb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
@ -575,8 +662,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
case 31: // hvcurveto
while (stack.length > 0) {
xa = x + stack.shift(); ya = y;
xb = xa + stack.shift(); yb = ya + stack.shift();
xa = x + stack.shift();
ya = y;
xb = xa + stack.shift();
yb = ya + stack.shift();
y = yb + stack.shift();
x = xb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
@ -584,8 +673,10 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
break;
}
xa = x; ya = y + stack.shift();
xb = xa + stack.shift(); yb = ya + stack.shift();
xa = x;
ya = y + stack.shift();
xb = xa + stack.shift();
yb = ya + stack.shift();
x = xb + stack.shift();
y = yb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
@ -602,8 +693,13 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
} else if (v < 255) {
stack.push(-(v - 251) * 256 - code[i++] - 108);
} else {
stack.push(((code[i] << 24) | (code[i + 1] << 16) |
(code[i + 2] << 8) | code[i + 3]) / 65536);
stack.push(
((code[i] << 24) |
(code[i + 1] << 16) |
(code[i + 2] << 8) |
code[i + 3]) /
65536
);
i += 4;
}
break;
@ -621,7 +717,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
class CompiledFont {
constructor(fontMatrix) {
if (this.constructor === CompiledFont) {
unreachable('Cannot initialize CompiledFont.');
unreachable("Cannot initialize CompiledFont.");
}
this.fontMatrix = fontMatrix;
@ -654,32 +750,34 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
let fdIndex = this.fdSelect.getFDIndex(glyphId);
if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
let fontDict = this.fdArray[fdIndex];
fontMatrix = fontDict.getByName('FontMatrix') || FONT_IDENTITY_MATRIX;
fontMatrix = fontDict.getByName("FontMatrix") || FONT_IDENTITY_MATRIX;
} else {
warn('Invalid fd index for glyph index.');
warn("Invalid fd index for glyph index.");
}
}
const cmds = [];
cmds.push({ cmd: 'save', });
cmds.push({ cmd: 'transform', args: fontMatrix.slice(), });
cmds.push({ cmd: 'scale', args: ['size', '-size'], });
cmds.push({ cmd: "save" });
cmds.push({ cmd: "transform", args: fontMatrix.slice() });
cmds.push({ cmd: "scale", args: ["size", "-size"] });
this.compileGlyphImpl(code, cmds, glyphId);
cmds.push({ cmd: 'restore', });
cmds.push({ cmd: "restore" });
return cmds;
}
compileGlyphImpl() {
unreachable('Children classes should implement this.');
unreachable("Children classes should implement this.");
}
hasBuiltPath(unicode) {
const cmap = lookupCmap(this.cmap, unicode);
return (this.compiledGlyphs[cmap.glyphId] !== undefined &&
this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined);
return (
this.compiledGlyphs[cmap.glyphId] !== undefined &&
this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined
);
}
}
@ -706,10 +804,18 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
this.cmap = cmap;
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
this.gsubrsBias = (this.gsubrs.length < 1240 ?
107 : (this.gsubrs.length < 33900 ? 1131 : 32768));
this.subrsBias = (this.subrs.length < 1240 ?
107 : (this.subrs.length < 33900 ? 1131 : 32768));
this.gsubrsBias =
this.gsubrs.length < 1240
? 107
: this.gsubrs.length < 33900
? 1131
: 32768;
this.subrsBias =
this.subrs.length < 1240
? 107
: this.subrs.length < 33900
? 1131
: 32768;
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
this.fdSelect = cffInfo.fdSelect;
@ -731,36 +837,38 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
var offset = getLong(data, p + 8);
var length = getLong(data, p + 12);
switch (tag) {
case 'cmap':
case "cmap":
cmap = parseCmap(data, offset, offset + length);
break;
case 'glyf':
case "glyf":
glyf = data.subarray(offset, offset + length);
break;
case 'loca':
case "loca":
loca = data.subarray(offset, offset + length);
break;
case 'head':
case "head":
unitsPerEm = getUshort(data, offset + 18);
indexToLocFormat = getUshort(data, offset + 50);
break;
case 'CFF ':
case "CFF ":
cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
break;
}
}
if (glyf) {
var fontMatrix = (!unitsPerEm ? font.fontMatrix :
[1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0]);
var fontMatrix = !unitsPerEm
? font.fontMatrix
: [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
return new TrueTypeCompiled(
parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
parseGlyfTable(glyf, loca, indexToLocFormat),
cmap,
fontMatrix
);
}
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
},
};
})();
export {
FontRendererFactory,
};
export { FontRendererFactory };