pdfjs-dist 2.0.487 → 2.1.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +15564 -9476
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +46644 -36309
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11430 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +406 -131
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +376 -53
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +387 -149
- package/lib/core/cmap.js +310 -75
- package/lib/core/colorspace.js +874 -594
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +545 -260
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +725 -147
- package/lib/core/font_renderer.js +360 -91
- package/lib/core/fonts.js +791 -186
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +3 -2
- package/lib/core/image.js +168 -61
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +252 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +4 -4
- package/lib/core/murmurhash3.js +24 -6
- package/lib/core/obj.js +1137 -475
- package/lib/core/operator_list.js +108 -6
- package/lib/core/parser.js +321 -68
- package/lib/core/pattern.js +145 -13
- package/lib/core/pdf_manager.js +321 -133
- package/lib/core/primitives.js +75 -22
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +10 -10
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +31 -4
- package/lib/core/worker.js +210 -66
- package/lib/display/annotation_layer.js +361 -123
- package/lib/display/api.js +1454 -729
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +324 -29
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/dom_utils.js +226 -41
- package/lib/display/fetch_stream.js +208 -84
- package/lib/display/font_loader.js +465 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +216 -51
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +352 -169
- package/lib/display/pattern_helper.js +58 -7
- package/lib/display/svg.js +242 -29
- package/lib/display/text_layer.js +132 -18
- package/lib/display/transport_stream.js +171 -42
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +57 -4
- package/lib/pdf.js +21 -4
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +295 -650
- package/lib/test/unit/annotation_spec.js +629 -345
- package/lib/test/unit/api_spec.js +555 -253
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +40 -11
- package/lib/test/unit/clitests_helper.js +9 -7
- package/lib/test/unit/cmap_spec.js +80 -26
- package/lib/test/unit/colorspace_spec.js +99 -52
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +41 -53
- package/lib/test/unit/display_svg_spec.js +33 -17
- package/lib/test/unit/document_spec.js +3 -3
- package/lib/test/unit/dom_utils_spec.js +9 -9
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +34 -9
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +31 -18
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +20 -5
- package/lib/test/unit/network_utils_spec.js +41 -14
- package/lib/test/unit/node_stream_spec.js +51 -27
- package/lib/test/unit/parser_spec.js +35 -8
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +24 -4
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +90 -27
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +452 -14
- package/lib/test/unit/unicode_spec.js +14 -11
- package/lib/test/unit/util_spec.js +131 -9
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1240 -582
- package/lib/web/app_options.js +71 -41
- package/lib/web/base_viewer.js +508 -179
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -13
- package/lib/web/firefox_print_service.js +17 -9
- package/lib/web/firefoxcom.js +283 -79
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +26 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +21 -13
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +80 -30
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +137 -76
- package/lib/web/pdf_outline_viewer.js +73 -22
- package/lib/web/pdf_page_view.js +196 -63
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +57 -11
- package/lib/web/pdf_rendering_queue.js +27 -5
- package/lib/web/pdf_sidebar.js +120 -67
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +103 -32
- package/lib/web/pdf_thumbnail_viewer.js +64 -24
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +275 -80
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +162 -65
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +58 -1
- package/web/pdf_viewer.js +6346 -3919
- package/web/pdf_viewer.js.map +1 -1
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2018 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,66 +19,99 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.FontRendererFactory =
|
27
|
+
exports.FontRendererFactory = void 0;
|
28
28
|
|
29
|
-
var _util = require(
|
29
|
+
var _util = require("../shared/util");
|
30
30
|
|
31
|
-
var _cff_parser = require(
|
31
|
+
var _cff_parser = require("./cff_parser");
|
32
32
|
|
33
|
-
var _glyphlist = require(
|
33
|
+
var _glyphlist = require("./glyphlist");
|
34
34
|
|
35
|
-
var _encodings = require(
|
35
|
+
var _encodings = require("./encodings");
|
36
36
|
|
37
|
-
var _stream = require(
|
37
|
+
var _stream = require("./stream");
|
38
|
+
|
39
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
40
|
+
|
41
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
42
|
+
|
43
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
44
|
+
|
45
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
46
|
+
|
47
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
48
|
+
|
49
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
50
|
+
|
51
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
52
|
+
|
53
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
54
|
+
|
55
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
38
56
|
|
39
57
|
var FontRendererFactory = function FontRendererFactoryClosure() {
|
40
58
|
function getLong(data, offset) {
|
41
59
|
return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
|
42
60
|
}
|
61
|
+
|
43
62
|
function getUshort(data, offset) {
|
44
63
|
return data[offset] << 8 | data[offset + 1];
|
45
64
|
}
|
65
|
+
|
46
66
|
function parseCmap(data, start, end) {
|
47
67
|
var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
|
48
68
|
var format = getUshort(data, start + offset);
|
49
69
|
var ranges, p, i;
|
70
|
+
|
50
71
|
if (format === 4) {
|
51
72
|
getUshort(data, start + offset + 2);
|
52
73
|
var segCount = getUshort(data, start + offset + 6) >> 1;
|
53
74
|
p = start + offset + 14;
|
54
75
|
ranges = [];
|
76
|
+
|
55
77
|
for (i = 0; i < segCount; i++, p += 2) {
|
56
|
-
ranges[i] = {
|
78
|
+
ranges[i] = {
|
79
|
+
end: getUshort(data, p)
|
80
|
+
};
|
57
81
|
}
|
82
|
+
|
58
83
|
p += 2;
|
84
|
+
|
59
85
|
for (i = 0; i < segCount; i++, p += 2) {
|
60
86
|
ranges[i].start = getUshort(data, p);
|
61
87
|
}
|
88
|
+
|
62
89
|
for (i = 0; i < segCount; i++, p += 2) {
|
63
90
|
ranges[i].idDelta = getUshort(data, p);
|
64
91
|
}
|
92
|
+
|
65
93
|
for (i = 0; i < segCount; i++, p += 2) {
|
66
94
|
var idOffset = getUshort(data, p);
|
95
|
+
|
67
96
|
if (idOffset === 0) {
|
68
97
|
continue;
|
69
98
|
}
|
99
|
+
|
70
100
|
ranges[i].ids = [];
|
101
|
+
|
71
102
|
for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
|
72
103
|
ranges[i].ids[j] = getUshort(data, p + idOffset);
|
73
104
|
idOffset += 2;
|
74
105
|
}
|
75
106
|
}
|
107
|
+
|
76
108
|
return ranges;
|
77
109
|
} else if (format === 12) {
|
78
110
|
getLong(data, start + offset + 4);
|
79
111
|
var groups = getLong(data, start + offset + 12);
|
80
112
|
p = start + offset + 16;
|
81
113
|
ranges = [];
|
114
|
+
|
82
115
|
for (i = 0; i < groups; i++) {
|
83
116
|
ranges.push({
|
84
117
|
start: getLong(data, p),
|
@@ -87,10 +120,13 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
87
120
|
});
|
88
121
|
p += 12;
|
89
122
|
}
|
123
|
+
|
90
124
|
return ranges;
|
91
125
|
}
|
92
|
-
|
126
|
+
|
127
|
+
throw new _util.FormatError("unsupported cmap: ".concat(format));
|
93
128
|
}
|
129
|
+
|
94
130
|
function parseCff(data, start, end, seacAnalysisEnabled) {
|
95
131
|
var properties = {};
|
96
132
|
var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
|
@@ -98,52 +134,68 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
98
134
|
return {
|
99
135
|
glyphs: cff.charStrings.objects,
|
100
136
|
subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
|
101
|
-
gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
|
137
|
+
gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects,
|
138
|
+
isCFFCIDFont: cff.isCIDFont,
|
139
|
+
fdSelect: cff.fdSelect,
|
140
|
+
fdArray: cff.fdArray
|
102
141
|
};
|
103
142
|
}
|
143
|
+
|
104
144
|
function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
|
105
145
|
var itemSize, itemDecode;
|
146
|
+
|
106
147
|
if (isGlyphLocationsLong) {
|
107
148
|
itemSize = 4;
|
149
|
+
|
108
150
|
itemDecode = function fontItemDecodeLong(data, offset) {
|
109
151
|
return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
|
110
152
|
};
|
111
153
|
} else {
|
112
154
|
itemSize = 2;
|
155
|
+
|
113
156
|
itemDecode = function fontItemDecode(data, offset) {
|
114
157
|
return data[offset] << 9 | data[offset + 1] << 1;
|
115
158
|
};
|
116
159
|
}
|
160
|
+
|
117
161
|
var glyphs = [];
|
118
162
|
var startOffset = itemDecode(loca, 0);
|
163
|
+
|
119
164
|
for (var j = itemSize; j < loca.length; j += itemSize) {
|
120
165
|
var endOffset = itemDecode(loca, j);
|
121
166
|
glyphs.push(glyf.subarray(startOffset, endOffset));
|
122
167
|
startOffset = endOffset;
|
123
168
|
}
|
169
|
+
|
124
170
|
return glyphs;
|
125
171
|
}
|
172
|
+
|
126
173
|
function lookupCmap(ranges, unicode) {
|
127
|
-
var code = unicode.
|
174
|
+
var code = unicode.codePointAt(0),
|
128
175
|
gid = 0;
|
129
176
|
var l = 0,
|
130
177
|
r = ranges.length - 1;
|
178
|
+
|
131
179
|
while (l < r) {
|
132
180
|
var c = l + r + 1 >> 1;
|
181
|
+
|
133
182
|
if (code < ranges[c].start) {
|
134
183
|
r = c - 1;
|
135
184
|
} else {
|
136
185
|
l = c;
|
137
186
|
}
|
138
187
|
}
|
188
|
+
|
139
189
|
if (ranges[l].start <= code && code <= ranges[l].end) {
|
140
190
|
gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
|
141
191
|
}
|
192
|
+
|
142
193
|
return {
|
143
194
|
charCode: code,
|
144
195
|
glyphId: gid
|
145
196
|
};
|
146
197
|
}
|
198
|
+
|
147
199
|
function compileGlyf(code, cmds, font) {
|
148
200
|
function moveTo(x, y) {
|
149
201
|
cmds.push({
|
@@ -151,30 +203,35 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
151
203
|
args: [x, y]
|
152
204
|
});
|
153
205
|
}
|
206
|
+
|
154
207
|
function lineTo(x, y) {
|
155
208
|
cmds.push({
|
156
209
|
cmd: 'lineTo',
|
157
210
|
args: [x, y]
|
158
211
|
});
|
159
212
|
}
|
213
|
+
|
160
214
|
function quadraticCurveTo(xa, ya, x, y) {
|
161
215
|
cmds.push({
|
162
216
|
cmd: 'quadraticCurveTo',
|
163
217
|
args: [xa, ya, x, y]
|
164
218
|
});
|
165
219
|
}
|
220
|
+
|
166
221
|
var i = 0;
|
167
222
|
var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
|
168
223
|
var flags;
|
169
224
|
var x = 0,
|
170
225
|
y = 0;
|
171
226
|
i += 10;
|
227
|
+
|
172
228
|
if (numberOfContours < 0) {
|
173
229
|
do {
|
174
230
|
flags = code[i] << 8 | code[i + 1];
|
175
231
|
var glyphIndex = code[i + 2] << 8 | code[i + 3];
|
176
232
|
i += 4;
|
177
233
|
var arg1, arg2;
|
234
|
+
|
178
235
|
if (flags & 0x01) {
|
179
236
|
arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
|
180
237
|
arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
|
@@ -183,6 +240,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
183
240
|
arg1 = code[i++];
|
184
241
|
arg2 = code[i++];
|
185
242
|
}
|
243
|
+
|
186
244
|
if (flags & 0x02) {
|
187
245
|
x = arg1;
|
188
246
|
y = arg2;
|
@@ -190,10 +248,12 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
190
248
|
x = 0;
|
191
249
|
y = 0;
|
192
250
|
}
|
251
|
+
|
193
252
|
var scaleX = 1,
|
194
253
|
scaleY = 1,
|
195
254
|
scale01 = 0,
|
196
255
|
scale10 = 0;
|
256
|
+
|
197
257
|
if (flags & 0x08) {
|
198
258
|
scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
|
199
259
|
i += 2;
|
@@ -208,72 +268,96 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
208
268
|
scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
|
209
269
|
i += 8;
|
210
270
|
}
|
271
|
+
|
211
272
|
var subglyph = font.glyphs[glyphIndex];
|
273
|
+
|
212
274
|
if (subglyph) {
|
213
|
-
cmds.push({
|
275
|
+
cmds.push({
|
276
|
+
cmd: 'save'
|
277
|
+
});
|
214
278
|
cmds.push({
|
215
279
|
cmd: 'transform',
|
216
280
|
args: [scaleX, scale01, scale10, scaleY, x, y]
|
217
281
|
});
|
218
282
|
compileGlyf(subglyph, cmds, font);
|
219
|
-
cmds.push({
|
283
|
+
cmds.push({
|
284
|
+
cmd: 'restore'
|
285
|
+
});
|
220
286
|
}
|
221
287
|
} while (flags & 0x20);
|
222
288
|
} else {
|
223
289
|
var endPtsOfContours = [];
|
224
290
|
var j, jj;
|
291
|
+
|
225
292
|
for (j = 0; j < numberOfContours; j++) {
|
226
293
|
endPtsOfContours.push(code[i] << 8 | code[i + 1]);
|
227
294
|
i += 2;
|
228
295
|
}
|
296
|
+
|
229
297
|
var instructionLength = code[i] << 8 | code[i + 1];
|
230
298
|
i += 2 + instructionLength;
|
231
299
|
var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
|
232
300
|
var points = [];
|
301
|
+
|
233
302
|
while (points.length < numberOfPoints) {
|
234
303
|
flags = code[i++];
|
235
304
|
var repeat = 1;
|
305
|
+
|
236
306
|
if (flags & 0x08) {
|
237
307
|
repeat += code[i++];
|
238
308
|
}
|
309
|
+
|
239
310
|
while (repeat-- > 0) {
|
240
|
-
points.push({
|
311
|
+
points.push({
|
312
|
+
flags: flags
|
313
|
+
});
|
241
314
|
}
|
242
315
|
}
|
316
|
+
|
243
317
|
for (j = 0; j < numberOfPoints; j++) {
|
244
318
|
switch (points[j].flags & 0x12) {
|
245
319
|
case 0x00:
|
246
320
|
x += (code[i] << 24 | code[i + 1] << 16) >> 16;
|
247
321
|
i += 2;
|
248
322
|
break;
|
323
|
+
|
249
324
|
case 0x02:
|
250
325
|
x -= code[i++];
|
251
326
|
break;
|
327
|
+
|
252
328
|
case 0x12:
|
253
329
|
x += code[i++];
|
254
330
|
break;
|
255
331
|
}
|
332
|
+
|
256
333
|
points[j].x = x;
|
257
334
|
}
|
335
|
+
|
258
336
|
for (j = 0; j < numberOfPoints; j++) {
|
259
337
|
switch (points[j].flags & 0x24) {
|
260
338
|
case 0x00:
|
261
339
|
y += (code[i] << 24 | code[i + 1] << 16) >> 16;
|
262
340
|
i += 2;
|
263
341
|
break;
|
342
|
+
|
264
343
|
case 0x04:
|
265
344
|
y -= code[i++];
|
266
345
|
break;
|
346
|
+
|
267
347
|
case 0x24:
|
268
348
|
y += code[i++];
|
269
349
|
break;
|
270
350
|
}
|
351
|
+
|
271
352
|
points[j].y = y;
|
272
353
|
}
|
354
|
+
|
273
355
|
var startPoint = 0;
|
356
|
+
|
274
357
|
for (i = 0; i < numberOfContours; i++) {
|
275
358
|
var endPoint = endPtsOfContours[i];
|
276
359
|
var contour = points.slice(startPoint, endPoint + 1);
|
360
|
+
|
277
361
|
if (contour[0].flags & 1) {
|
278
362
|
contour.push(contour[0]);
|
279
363
|
} else if (contour[contour.length - 1].flags & 1) {
|
@@ -287,7 +371,9 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
287
371
|
contour.unshift(p);
|
288
372
|
contour.push(p);
|
289
373
|
}
|
374
|
+
|
290
375
|
moveTo(contour[0].x, contour[0].y);
|
376
|
+
|
291
377
|
for (j = 1, jj = contour.length; j < jj; j++) {
|
292
378
|
if (contour[j].flags & 1) {
|
293
379
|
lineTo(contour[j].x, contour[j].y);
|
@@ -298,82 +384,103 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
298
384
|
quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
|
299
385
|
}
|
300
386
|
}
|
387
|
+
|
301
388
|
startPoint = endPoint + 1;
|
302
389
|
}
|
303
390
|
}
|
304
391
|
}
|
305
|
-
|
392
|
+
|
393
|
+
function compileCharString(code, cmds, font, glyphId) {
|
306
394
|
var stack = [];
|
307
395
|
var x = 0,
|
308
396
|
y = 0;
|
309
397
|
var stems = 0;
|
398
|
+
|
310
399
|
function moveTo(x, y) {
|
311
400
|
cmds.push({
|
312
401
|
cmd: 'moveTo',
|
313
402
|
args: [x, y]
|
314
403
|
});
|
315
404
|
}
|
405
|
+
|
316
406
|
function lineTo(x, y) {
|
317
407
|
cmds.push({
|
318
408
|
cmd: 'lineTo',
|
319
409
|
args: [x, y]
|
320
410
|
});
|
321
411
|
}
|
412
|
+
|
322
413
|
function bezierCurveTo(x1, y1, x2, y2, x, y) {
|
323
414
|
cmds.push({
|
324
415
|
cmd: 'bezierCurveTo',
|
325
416
|
args: [x1, y1, x2, y2, x, y]
|
326
417
|
});
|
327
418
|
}
|
419
|
+
|
328
420
|
function parse(code) {
|
329
421
|
var i = 0;
|
422
|
+
|
330
423
|
while (i < code.length) {
|
331
424
|
var stackClean = false;
|
332
425
|
var v = code[i++];
|
333
426
|
var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
|
427
|
+
|
334
428
|
switch (v) {
|
335
429
|
case 1:
|
336
430
|
stems += stack.length >> 1;
|
337
431
|
stackClean = true;
|
338
432
|
break;
|
433
|
+
|
339
434
|
case 3:
|
340
435
|
stems += stack.length >> 1;
|
341
436
|
stackClean = true;
|
342
437
|
break;
|
438
|
+
|
343
439
|
case 4:
|
344
440
|
y += stack.pop();
|
345
441
|
moveTo(x, y);
|
346
442
|
stackClean = true;
|
347
443
|
break;
|
444
|
+
|
348
445
|
case 5:
|
349
446
|
while (stack.length > 0) {
|
350
447
|
x += stack.shift();
|
351
448
|
y += stack.shift();
|
352
449
|
lineTo(x, y);
|
353
450
|
}
|
451
|
+
|
354
452
|
break;
|
453
|
+
|
355
454
|
case 6:
|
356
455
|
while (stack.length > 0) {
|
357
456
|
x += stack.shift();
|
358
457
|
lineTo(x, y);
|
458
|
+
|
359
459
|
if (stack.length === 0) {
|
360
460
|
break;
|
361
461
|
}
|
462
|
+
|
362
463
|
y += stack.shift();
|
363
464
|
lineTo(x, y);
|
364
465
|
}
|
466
|
+
|
365
467
|
break;
|
468
|
+
|
366
469
|
case 7:
|
367
470
|
while (stack.length > 0) {
|
368
471
|
y += stack.shift();
|
369
472
|
lineTo(x, y);
|
473
|
+
|
370
474
|
if (stack.length === 0) {
|
371
475
|
break;
|
372
476
|
}
|
477
|
+
|
373
478
|
x += stack.shift();
|
374
479
|
lineTo(x, y);
|
375
480
|
}
|
481
|
+
|
376
482
|
break;
|
483
|
+
|
377
484
|
case 8:
|
378
485
|
while (stack.length > 0) {
|
379
486
|
xa = x + stack.shift();
|
@@ -384,18 +491,48 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
384
491
|
y = yb + stack.shift();
|
385
492
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
386
493
|
}
|
494
|
+
|
387
495
|
break;
|
496
|
+
|
388
497
|
case 10:
|
389
|
-
n = stack.pop()
|
390
|
-
subrCode =
|
498
|
+
n = stack.pop();
|
499
|
+
subrCode = null;
|
500
|
+
|
501
|
+
if (font.isCFFCIDFont) {
|
502
|
+
var fdIndex = font.fdSelect.getFDIndex(glyphId);
|
503
|
+
|
504
|
+
if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
|
505
|
+
var fontDict = font.fdArray[fdIndex],
|
506
|
+
subrs = void 0;
|
507
|
+
|
508
|
+
if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
|
509
|
+
subrs = fontDict.privateDict.subrsIndex.objects;
|
510
|
+
}
|
511
|
+
|
512
|
+
if (subrs) {
|
513
|
+
var numSubrs = subrs.length;
|
514
|
+
n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
|
515
|
+
subrCode = subrs[n];
|
516
|
+
}
|
517
|
+
} else {
|
518
|
+
(0, _util.warn)('Invalid fd index for glyph index.');
|
519
|
+
}
|
520
|
+
} else {
|
521
|
+
subrCode = font.subrs[n + font.subrsBias];
|
522
|
+
}
|
523
|
+
|
391
524
|
if (subrCode) {
|
392
525
|
parse(subrCode);
|
393
526
|
}
|
527
|
+
|
394
528
|
break;
|
529
|
+
|
395
530
|
case 11:
|
396
531
|
return;
|
532
|
+
|
397
533
|
case 12:
|
398
534
|
v = code[i++];
|
535
|
+
|
399
536
|
switch (v) {
|
400
537
|
case 34:
|
401
538
|
xa = x + stack.shift();
|
@@ -408,6 +545,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
408
545
|
x = xb + stack.shift();
|
409
546
|
bezierCurveTo(xa, y1, xb, y, x, y);
|
410
547
|
break;
|
548
|
+
|
411
549
|
case 35:
|
412
550
|
xa = x + stack.shift();
|
413
551
|
ya = y + stack.shift();
|
@@ -425,6 +563,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
425
563
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
426
564
|
stack.pop();
|
427
565
|
break;
|
566
|
+
|
428
567
|
case 36:
|
429
568
|
xa = x + stack.shift();
|
430
569
|
y1 = y + stack.shift();
|
@@ -438,6 +577,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
438
577
|
x = xb + stack.shift();
|
439
578
|
bezierCurveTo(xa, y2, xb, y3, x, y);
|
440
579
|
break;
|
580
|
+
|
441
581
|
case 37:
|
442
582
|
var x0 = x,
|
443
583
|
y0 = y;
|
@@ -454,64 +594,81 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
454
594
|
yb = ya + stack.shift();
|
455
595
|
x = xb;
|
456
596
|
y = yb;
|
597
|
+
|
457
598
|
if (Math.abs(x - x0) > Math.abs(y - y0)) {
|
458
599
|
x += stack.shift();
|
459
600
|
} else {
|
460
601
|
y += stack.shift();
|
461
602
|
}
|
603
|
+
|
462
604
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
463
605
|
break;
|
606
|
+
|
464
607
|
default:
|
465
|
-
throw new _util.FormatError(
|
608
|
+
throw new _util.FormatError("unknown operator: 12 ".concat(v));
|
466
609
|
}
|
610
|
+
|
467
611
|
break;
|
612
|
+
|
468
613
|
case 14:
|
469
614
|
if (stack.length >= 4) {
|
470
615
|
var achar = stack.pop();
|
471
616
|
var bchar = stack.pop();
|
472
617
|
y = stack.pop();
|
473
618
|
x = stack.pop();
|
474
|
-
cmds.push({
|
619
|
+
cmds.push({
|
620
|
+
cmd: 'save'
|
621
|
+
});
|
475
622
|
cmds.push({
|
476
623
|
cmd: 'translate',
|
477
624
|
args: [x, y]
|
478
625
|
});
|
479
626
|
var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
|
480
|
-
compileCharString(font.glyphs[cmap.glyphId], cmds, font);
|
481
|
-
cmds.push({
|
627
|
+
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
|
628
|
+
cmds.push({
|
629
|
+
cmd: 'restore'
|
630
|
+
});
|
482
631
|
cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
|
483
|
-
compileCharString(font.glyphs[cmap.glyphId], cmds, font);
|
632
|
+
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
|
484
633
|
}
|
634
|
+
|
485
635
|
return;
|
636
|
+
|
486
637
|
case 18:
|
487
638
|
stems += stack.length >> 1;
|
488
639
|
stackClean = true;
|
489
640
|
break;
|
641
|
+
|
490
642
|
case 19:
|
491
643
|
stems += stack.length >> 1;
|
492
644
|
i += stems + 7 >> 3;
|
493
645
|
stackClean = true;
|
494
646
|
break;
|
647
|
+
|
495
648
|
case 20:
|
496
649
|
stems += stack.length >> 1;
|
497
650
|
i += stems + 7 >> 3;
|
498
651
|
stackClean = true;
|
499
652
|
break;
|
653
|
+
|
500
654
|
case 21:
|
501
655
|
y += stack.pop();
|
502
656
|
x += stack.pop();
|
503
657
|
moveTo(x, y);
|
504
658
|
stackClean = true;
|
505
659
|
break;
|
660
|
+
|
506
661
|
case 22:
|
507
662
|
x += stack.pop();
|
508
663
|
moveTo(x, y);
|
509
664
|
stackClean = true;
|
510
665
|
break;
|
666
|
+
|
511
667
|
case 23:
|
512
668
|
stems += stack.length >> 1;
|
513
669
|
stackClean = true;
|
514
670
|
break;
|
671
|
+
|
515
672
|
case 24:
|
516
673
|
while (stack.length > 2) {
|
517
674
|
xa = x + stack.shift();
|
@@ -522,16 +679,19 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
522
679
|
y = yb + stack.shift();
|
523
680
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
524
681
|
}
|
682
|
+
|
525
683
|
x += stack.shift();
|
526
684
|
y += stack.shift();
|
527
685
|
lineTo(x, y);
|
528
686
|
break;
|
687
|
+
|
529
688
|
case 25:
|
530
689
|
while (stack.length > 6) {
|
531
690
|
x += stack.shift();
|
532
691
|
y += stack.shift();
|
533
692
|
lineTo(x, y);
|
534
693
|
}
|
694
|
+
|
535
695
|
xa = x + stack.shift();
|
536
696
|
ya = y + stack.shift();
|
537
697
|
xb = xa + stack.shift();
|
@@ -540,10 +700,12 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
540
700
|
y = yb + stack.shift();
|
541
701
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
542
702
|
break;
|
703
|
+
|
543
704
|
case 26:
|
544
705
|
if (stack.length % 2) {
|
545
706
|
x += stack.shift();
|
546
707
|
}
|
708
|
+
|
547
709
|
while (stack.length > 0) {
|
548
710
|
xa = x;
|
549
711
|
ya = y + stack.shift();
|
@@ -553,11 +715,14 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
553
715
|
y = yb + stack.shift();
|
554
716
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
555
717
|
}
|
718
|
+
|
556
719
|
break;
|
720
|
+
|
557
721
|
case 27:
|
558
722
|
if (stack.length % 2) {
|
559
723
|
y += stack.shift();
|
560
724
|
}
|
725
|
+
|
561
726
|
while (stack.length > 0) {
|
562
727
|
xa = x + stack.shift();
|
563
728
|
ya = y;
|
@@ -567,18 +732,24 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
567
732
|
y = yb;
|
568
733
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
569
734
|
}
|
735
|
+
|
570
736
|
break;
|
737
|
+
|
571
738
|
case 28:
|
572
739
|
stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
|
573
740
|
i += 2;
|
574
741
|
break;
|
742
|
+
|
575
743
|
case 29:
|
576
744
|
n = stack.pop() + font.gsubrsBias;
|
577
745
|
subrCode = font.gsubrs[n];
|
746
|
+
|
578
747
|
if (subrCode) {
|
579
748
|
parse(subrCode);
|
580
749
|
}
|
750
|
+
|
581
751
|
break;
|
752
|
+
|
582
753
|
case 30:
|
583
754
|
while (stack.length > 0) {
|
584
755
|
xa = x;
|
@@ -588,9 +759,11 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
588
759
|
x = xb + stack.shift();
|
589
760
|
y = yb + (stack.length === 1 ? stack.shift() : 0);
|
590
761
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
762
|
+
|
591
763
|
if (stack.length === 0) {
|
592
764
|
break;
|
593
765
|
}
|
766
|
+
|
594
767
|
xa = x + stack.shift();
|
595
768
|
ya = y;
|
596
769
|
xb = xa + stack.shift();
|
@@ -599,7 +772,9 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
599
772
|
x = xb + (stack.length === 1 ? stack.shift() : 0);
|
600
773
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
601
774
|
}
|
775
|
+
|
602
776
|
break;
|
777
|
+
|
603
778
|
case 31:
|
604
779
|
while (stack.length > 0) {
|
605
780
|
xa = x + stack.shift();
|
@@ -609,9 +784,11 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
609
784
|
y = yb + stack.shift();
|
610
785
|
x = xb + (stack.length === 1 ? stack.shift() : 0);
|
611
786
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
787
|
+
|
612
788
|
if (stack.length === 0) {
|
613
789
|
break;
|
614
790
|
}
|
791
|
+
|
615
792
|
xa = x;
|
616
793
|
ya = y + stack.shift();
|
617
794
|
xb = xa + stack.shift();
|
@@ -620,11 +797,14 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
620
797
|
y = yb + (stack.length === 1 ? stack.shift() : 0);
|
621
798
|
bezierCurveTo(xa, ya, xb, yb, x, y);
|
622
799
|
}
|
800
|
+
|
623
801
|
break;
|
802
|
+
|
624
803
|
default:
|
625
804
|
if (v < 32) {
|
626
|
-
throw new _util.FormatError(
|
805
|
+
throw new _util.FormatError("unknown operator: ".concat(v));
|
627
806
|
}
|
807
|
+
|
628
808
|
if (v < 247) {
|
629
809
|
stack.push(v - 139);
|
630
810
|
} else if (v < 251) {
|
@@ -635,121 +815,210 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
635
815
|
stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
|
636
816
|
i += 4;
|
637
817
|
}
|
818
|
+
|
638
819
|
break;
|
639
820
|
}
|
821
|
+
|
640
822
|
if (stackClean) {
|
641
823
|
stack.length = 0;
|
642
824
|
}
|
643
825
|
}
|
644
826
|
}
|
827
|
+
|
645
828
|
parse(code);
|
646
829
|
}
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
830
|
+
|
831
|
+
var NOOP = [];
|
832
|
+
|
833
|
+
var CompiledFont =
|
834
|
+
/*#__PURE__*/
|
835
|
+
function () {
|
836
|
+
function CompiledFont(fontMatrix) {
|
837
|
+
_classCallCheck(this, CompiledFont);
|
838
|
+
|
839
|
+
if (this.constructor === CompiledFont) {
|
840
|
+
(0, _util.unreachable)('Cannot initialize CompiledFont.');
|
841
|
+
}
|
842
|
+
|
843
|
+
this.fontMatrix = fontMatrix;
|
844
|
+
this.compiledGlyphs = Object.create(null);
|
845
|
+
this.compiledCharCodeToGlyphId = Object.create(null);
|
846
|
+
}
|
847
|
+
|
848
|
+
_createClass(CompiledFont, [{
|
849
|
+
key: "getPathJs",
|
850
|
+
value: function getPathJs(unicode) {
|
851
|
+
var cmap = lookupCmap(this.cmap, unicode);
|
852
|
+
var fn = this.compiledGlyphs[cmap.glyphId];
|
853
|
+
|
854
|
+
if (!fn) {
|
855
|
+
fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
|
856
|
+
this.compiledGlyphs[cmap.glyphId] = fn;
|
857
|
+
}
|
858
|
+
|
859
|
+
if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
|
860
|
+
this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
|
861
|
+
}
|
862
|
+
|
863
|
+
return fn;
|
660
864
|
}
|
661
|
-
|
662
|
-
|
865
|
+
}, {
|
866
|
+
key: "compileGlyph",
|
867
|
+
value: function compileGlyph(code, glyphId) {
|
868
|
+
if (!code || code.length === 0 || code[0] === 14) {
|
869
|
+
return NOOP;
|
870
|
+
}
|
871
|
+
|
872
|
+
var fontMatrix = this.fontMatrix;
|
873
|
+
|
874
|
+
if (this.isCFFCIDFont) {
|
875
|
+
var fdIndex = this.fdSelect.getFDIndex(glyphId);
|
876
|
+
|
877
|
+
if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
|
878
|
+
var fontDict = this.fdArray[fdIndex];
|
879
|
+
fontMatrix = fontDict.getByName('FontMatrix') || _util.FONT_IDENTITY_MATRIX;
|
880
|
+
} else {
|
881
|
+
(0, _util.warn)('Invalid fd index for glyph index.');
|
882
|
+
}
|
883
|
+
}
|
884
|
+
|
885
|
+
var cmds = [];
|
886
|
+
cmds.push({
|
887
|
+
cmd: 'save'
|
888
|
+
});
|
889
|
+
cmds.push({
|
890
|
+
cmd: 'transform',
|
891
|
+
args: fontMatrix.slice()
|
892
|
+
});
|
893
|
+
cmds.push({
|
894
|
+
cmd: 'scale',
|
895
|
+
args: ['size', '-size']
|
896
|
+
});
|
897
|
+
this.compileGlyphImpl(code, cmds, glyphId);
|
898
|
+
cmds.push({
|
899
|
+
cmd: 'restore'
|
900
|
+
});
|
901
|
+
return cmds;
|
663
902
|
}
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
return noop;
|
903
|
+
}, {
|
904
|
+
key: "compileGlyphImpl",
|
905
|
+
value: function compileGlyphImpl() {
|
906
|
+
(0, _util.unreachable)('Children classes should implement this.');
|
669
907
|
}
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
}
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
this.glyphs = glyphs;
|
696
|
-
this.cmap = cmap;
|
697
|
-
}
|
698
|
-
_util.Util.inherit(TrueTypeCompiled, CompiledFont, {
|
699
|
-
compileGlyphImpl: function compileGlyphImpl(code, cmds) {
|
700
|
-
compileGlyf(code, cmds, this);
|
908
|
+
}, {
|
909
|
+
key: "hasBuiltPath",
|
910
|
+
value: function hasBuiltPath(unicode) {
|
911
|
+
var cmap = lookupCmap(this.cmap, unicode);
|
912
|
+
return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
|
913
|
+
}
|
914
|
+
}]);
|
915
|
+
|
916
|
+
return CompiledFont;
|
917
|
+
}();
|
918
|
+
|
919
|
+
var TrueTypeCompiled =
|
920
|
+
/*#__PURE__*/
|
921
|
+
function (_CompiledFont) {
|
922
|
+
_inherits(TrueTypeCompiled, _CompiledFont);
|
923
|
+
|
924
|
+
function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
|
925
|
+
var _this;
|
926
|
+
|
927
|
+
_classCallCheck(this, TrueTypeCompiled);
|
928
|
+
|
929
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(TrueTypeCompiled).call(this, fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]));
|
930
|
+
_this.glyphs = glyphs;
|
931
|
+
_this.cmap = cmap;
|
932
|
+
return _this;
|
701
933
|
}
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
934
|
+
|
935
|
+
_createClass(TrueTypeCompiled, [{
|
936
|
+
key: "compileGlyphImpl",
|
937
|
+
value: function compileGlyphImpl(code, cmds) {
|
938
|
+
compileGlyf(code, cmds, this);
|
939
|
+
}
|
940
|
+
}]);
|
941
|
+
|
942
|
+
return TrueTypeCompiled;
|
943
|
+
}(CompiledFont);
|
944
|
+
|
945
|
+
var Type2Compiled =
|
946
|
+
/*#__PURE__*/
|
947
|
+
function (_CompiledFont2) {
|
948
|
+
_inherits(Type2Compiled, _CompiledFont2);
|
949
|
+
|
950
|
+
function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
|
951
|
+
var _this2;
|
952
|
+
|
953
|
+
_classCallCheck(this, Type2Compiled);
|
954
|
+
|
955
|
+
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(Type2Compiled).call(this, fontMatrix || [0.001, 0, 0, 0.001, 0, 0]));
|
956
|
+
_this2.glyphs = cffInfo.glyphs;
|
957
|
+
_this2.gsubrs = cffInfo.gsubrs || [];
|
958
|
+
_this2.subrs = cffInfo.subrs || [];
|
959
|
+
_this2.cmap = cmap;
|
960
|
+
_this2.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
|
961
|
+
_this2.gsubrsBias = _this2.gsubrs.length < 1240 ? 107 : _this2.gsubrs.length < 33900 ? 1131 : 32768;
|
962
|
+
_this2.subrsBias = _this2.subrs.length < 1240 ? 107 : _this2.subrs.length < 33900 ? 1131 : 32768;
|
963
|
+
_this2.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
964
|
+
_this2.fdSelect = cffInfo.fdSelect;
|
965
|
+
_this2.fdArray = cffInfo.fdArray;
|
966
|
+
return _this2;
|
717
967
|
}
|
718
|
-
|
968
|
+
|
969
|
+
_createClass(Type2Compiled, [{
|
970
|
+
key: "compileGlyphImpl",
|
971
|
+
value: function compileGlyphImpl(code, cmds, glyphId) {
|
972
|
+
compileCharString(code, cmds, this, glyphId);
|
973
|
+
}
|
974
|
+
}]);
|
975
|
+
|
976
|
+
return Type2Compiled;
|
977
|
+
}(CompiledFont);
|
978
|
+
|
719
979
|
return {
|
720
980
|
create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
|
721
981
|
var data = new Uint8Array(font.data);
|
722
982
|
var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
|
723
983
|
var numTables = getUshort(data, 4);
|
984
|
+
|
724
985
|
for (var i = 0, p = 12; i < numTables; i++, p += 16) {
|
725
986
|
var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
|
726
987
|
var offset = getLong(data, p + 8);
|
727
988
|
var length = getLong(data, p + 12);
|
989
|
+
|
728
990
|
switch (tag) {
|
729
991
|
case 'cmap':
|
730
992
|
cmap = parseCmap(data, offset, offset + length);
|
731
993
|
break;
|
994
|
+
|
732
995
|
case 'glyf':
|
733
996
|
glyf = data.subarray(offset, offset + length);
|
734
997
|
break;
|
998
|
+
|
735
999
|
case 'loca':
|
736
1000
|
loca = data.subarray(offset, offset + length);
|
737
1001
|
break;
|
1002
|
+
|
738
1003
|
case 'head':
|
739
1004
|
unitsPerEm = getUshort(data, offset + 18);
|
740
1005
|
indexToLocFormat = getUshort(data, offset + 50);
|
741
1006
|
break;
|
1007
|
+
|
742
1008
|
case 'CFF ':
|
743
1009
|
cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
|
744
1010
|
break;
|
745
1011
|
}
|
746
1012
|
}
|
1013
|
+
|
747
1014
|
if (glyf) {
|
748
1015
|
var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
|
749
1016
|
return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
|
750
1017
|
}
|
1018
|
+
|
751
1019
|
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
|
752
1020
|
}
|
753
1021
|
};
|
754
1022
|
}();
|
1023
|
+
|
755
1024
|
exports.FontRendererFactory = FontRendererFactory;
|