Remove unnecessary closure in the src/core/font_renderer.js
file
With modern JavaScript modules, where you explicitly list the properties that should be exported, it's no longer necessary to wrap *all* of the code within one file into a top-level closure.[1] This patch reduces the size, of even the *built* `pdf.worker.js` file, since there's now a lot less unnecessary whitespace. --- [1] For files which contain *different* functionality, some closures may however still make sense in order to separate the code. It might be possible to remove some of those cases later, e.g. once private class fields becomes generally available/usable in browsers.
This commit is contained in:
parent
afb8c4fd25
commit
0a32ad3e42
@ -25,7 +25,6 @@ import { getGlyphsUnicode } from "./glyphlist.js";
|
||||
import { StandardEncoding } from "./encodings.js";
|
||||
import { Stream } from "./stream.js";
|
||||
|
||||
const FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
function getLong(data, offset) {
|
||||
return (
|
||||
(data[offset] << 24) |
|
||||
@ -220,8 +219,7 @@ const FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
scale01 = 0,
|
||||
scale10 = 0;
|
||||
if (flags & 0x08) {
|
||||
scaleX = scaleY =
|
||||
((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
|
||||
scaleX = scaleY = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
|
||||
i += 2;
|
||||
} else if (flags & 0x40) {
|
||||
scaleX = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
|
||||
@ -827,8 +825,8 @@ const FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
|
||||
class FontRendererFactory {
|
||||
static create(font, seacAnalysisEnabled) {
|
||||
const data = new Uint8Array(font.data);
|
||||
let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
|
||||
const numTables = getUshort(data, 4);
|
||||
@ -867,8 +865,7 @@ const FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
);
|
||||
}
|
||||
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
|
||||
},
|
||||
};
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
export { FontRendererFactory };
|
||||
|
Loading…
x
Reference in New Issue
Block a user