@chialab/pdfjs-lib 1.0.0-alpha.29 → 1.0.0-alpha.30
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.
- package/dist/browser/{chunk-W35PJZ6L.js → chunk-R7G44NYV.js} +521 -3
- package/dist/browser/index.js +2329 -969
- package/dist/browser/openjpeg-Q27OVS4T.js +9 -0
- package/dist/browser/worker.js +594 -609
- package/dist/index.d.ts +1 -1
- package/dist/lib/TextLayer.d.ts +4 -0
- package/dist/node/{NodeUtils-ZPPZPJWD.js → NodeUtils-PVXQMWFJ.js} +2 -2
- package/dist/node/{chunk-GWGW2EKY.js → chunk-4Y7OZIIX.js} +520 -2
- package/dist/node/{chunk-D4U3W2CD.js → chunk-O74KGUUC.js} +451 -1
- package/dist/node/{chunk-FHASHZBJ.js → chunk-T2JWSGAF.js} +2 -2
- package/dist/node/index.js +1896 -972
- package/dist/node/openjpeg-QFJSFVSJ.js +9 -0
- package/dist/node/worker.js +595 -610
- package/dist/pdf.js/external/openjpeg/openjpeg.d.ts +1 -1
- package/dist/pdf.js/src/core/fonts.d.ts +7 -1
- package/dist/pdf.js/src/display/annotation_layer.d.ts +28 -6
- package/dist/pdf.js/src/display/annotation_storage.d.ts +2 -0
- package/dist/pdf.js/src/display/api.d.ts +13 -7
- package/dist/pdf.js/src/display/canvas.d.ts +1 -1
- package/dist/pdf.js/src/display/canvas_dependency_tracker.d.ts +36 -20
- package/dist/pdf.js/src/display/display_utils.d.ts +22 -0
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +4 -2
- package/dist/pdf.js/src/display/editor/comment.d.ts +20 -5
- package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/drawers/highlight.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/editor.d.ts +67 -15
- package/dist/pdf.js/src/display/editor/freetext.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +3 -1
- package/dist/pdf.js/src/display/editor/ink.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/signature.d.ts +0 -5
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +3 -1
- package/dist/pdf.js/src/display/editor/tools.d.ts +21 -3
- package/dist/pdf.js/src/display/font_loader.d.ts +27 -1
- package/dist/pdf.js/src/display/pattern_helper.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +5 -1
- package/dist/pdf.js/src/shared/obj-bin-transform.d.ts +64 -0
- package/dist/pdf.js/web/comment_manager.d.ts +20 -0
- package/package.json +1 -1
- package/dist/browser/openjpeg-QLA762TL.js +0 -9
- package/dist/node/openjpeg-TRZ4ANDN.js +0 -9
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
__privateAdd,
|
|
3
3
|
__privateGet,
|
|
4
4
|
__privateMethod,
|
|
5
|
-
__privateSet
|
|
5
|
+
__privateSet,
|
|
6
|
+
__publicField
|
|
6
7
|
} from "./chunk-7YYVRRNF.js";
|
|
7
8
|
|
|
8
9
|
// src/lib/polyfills.ts
|
|
@@ -348,12 +349,12 @@ function getVerbosityLevel() {
|
|
|
348
349
|
}
|
|
349
350
|
function info(msg) {
|
|
350
351
|
if (verbosity >= VerbosityLevel.INFOS) {
|
|
351
|
-
console.
|
|
352
|
+
console.info(`Info: ${msg}`);
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
355
|
function warn(msg) {
|
|
355
356
|
if (verbosity >= VerbosityLevel.WARNINGS) {
|
|
356
|
-
console.
|
|
357
|
+
console.warn(`Warning: ${msg}`);
|
|
357
358
|
}
|
|
358
359
|
}
|
|
359
360
|
function unreachable(msg) {
|
|
@@ -1658,6 +1659,522 @@ deleteStreamController_fn = async function(streamController, streamId) {
|
|
|
1658
1659
|
delete this.streamControllers[streamId];
|
|
1659
1660
|
};
|
|
1660
1661
|
|
|
1662
|
+
// src/pdf.js/src/shared/obj-bin-transform.js
|
|
1663
|
+
var _buffer, _view, _decoder, _CssFontInfo_instances, readString_fn;
|
|
1664
|
+
var _CssFontInfo = class _CssFontInfo {
|
|
1665
|
+
constructor(buffer) {
|
|
1666
|
+
__privateAdd(this, _CssFontInfo_instances);
|
|
1667
|
+
__privateAdd(this, _buffer);
|
|
1668
|
+
__privateAdd(this, _view);
|
|
1669
|
+
__privateAdd(this, _decoder);
|
|
1670
|
+
__privateSet(this, _buffer, buffer);
|
|
1671
|
+
__privateSet(this, _view, new DataView(__privateGet(this, _buffer)));
|
|
1672
|
+
__privateSet(this, _decoder, new TextDecoder());
|
|
1673
|
+
}
|
|
1674
|
+
static write(info2) {
|
|
1675
|
+
const encoder = new TextEncoder();
|
|
1676
|
+
const encodedStrings = {};
|
|
1677
|
+
let stringsLength = 0;
|
|
1678
|
+
for (const prop of _CssFontInfo.strings) {
|
|
1679
|
+
const encoded = encoder.encode(info2[prop]);
|
|
1680
|
+
encodedStrings[prop] = encoded;
|
|
1681
|
+
stringsLength += 4 + encoded.length;
|
|
1682
|
+
}
|
|
1683
|
+
const buffer = new ArrayBuffer(stringsLength);
|
|
1684
|
+
const data = new Uint8Array(buffer);
|
|
1685
|
+
const view = new DataView(buffer);
|
|
1686
|
+
let offset = 0;
|
|
1687
|
+
for (const prop of _CssFontInfo.strings) {
|
|
1688
|
+
const encoded = encodedStrings[prop];
|
|
1689
|
+
const length = encoded.length;
|
|
1690
|
+
view.setUint32(offset, length);
|
|
1691
|
+
data.set(encoded, offset + 4);
|
|
1692
|
+
offset += 4 + length;
|
|
1693
|
+
}
|
|
1694
|
+
assert(offset === buffer.byteLength, "CssFontInfo.write: Buffer overflow");
|
|
1695
|
+
return buffer;
|
|
1696
|
+
}
|
|
1697
|
+
get fontFamily() {
|
|
1698
|
+
return __privateMethod(this, _CssFontInfo_instances, readString_fn).call(this, 0);
|
|
1699
|
+
}
|
|
1700
|
+
get fontWeight() {
|
|
1701
|
+
return __privateMethod(this, _CssFontInfo_instances, readString_fn).call(this, 1);
|
|
1702
|
+
}
|
|
1703
|
+
get italicAngle() {
|
|
1704
|
+
return __privateMethod(this, _CssFontInfo_instances, readString_fn).call(this, 2);
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
_buffer = new WeakMap();
|
|
1708
|
+
_view = new WeakMap();
|
|
1709
|
+
_decoder = new WeakMap();
|
|
1710
|
+
_CssFontInfo_instances = new WeakSet();
|
|
1711
|
+
readString_fn = function(index) {
|
|
1712
|
+
assert(index < _CssFontInfo.strings.length, "Invalid string index");
|
|
1713
|
+
let offset = 0;
|
|
1714
|
+
for (let i = 0; i < index; i++) {
|
|
1715
|
+
offset += __privateGet(this, _view).getUint32(offset) + 4;
|
|
1716
|
+
}
|
|
1717
|
+
const length = __privateGet(this, _view).getUint32(offset);
|
|
1718
|
+
return __privateGet(this, _decoder).decode(
|
|
1719
|
+
new Uint8Array(__privateGet(this, _buffer), offset + 4, length)
|
|
1720
|
+
);
|
|
1721
|
+
};
|
|
1722
|
+
__publicField(_CssFontInfo, "strings", ["fontFamily", "fontWeight", "italicAngle"]);
|
|
1723
|
+
var CssFontInfo = _CssFontInfo;
|
|
1724
|
+
var _buffer2, _view2, _decoder2, _SystemFontInfo_instances, readString_fn2;
|
|
1725
|
+
var _SystemFontInfo = class _SystemFontInfo {
|
|
1726
|
+
constructor(buffer) {
|
|
1727
|
+
__privateAdd(this, _SystemFontInfo_instances);
|
|
1728
|
+
__privateAdd(this, _buffer2);
|
|
1729
|
+
__privateAdd(this, _view2);
|
|
1730
|
+
__privateAdd(this, _decoder2);
|
|
1731
|
+
__privateSet(this, _buffer2, buffer);
|
|
1732
|
+
__privateSet(this, _view2, new DataView(__privateGet(this, _buffer2)));
|
|
1733
|
+
__privateSet(this, _decoder2, new TextDecoder());
|
|
1734
|
+
}
|
|
1735
|
+
static write(info2) {
|
|
1736
|
+
const encoder = new TextEncoder();
|
|
1737
|
+
const encodedStrings = {};
|
|
1738
|
+
let stringsLength = 0;
|
|
1739
|
+
for (const prop of _SystemFontInfo.strings) {
|
|
1740
|
+
const encoded = encoder.encode(info2[prop]);
|
|
1741
|
+
encodedStrings[prop] = encoded;
|
|
1742
|
+
stringsLength += 4 + encoded.length;
|
|
1743
|
+
}
|
|
1744
|
+
stringsLength += 4;
|
|
1745
|
+
let encodedStyleStyle, encodedStyleWeight, lengthEstimate = 1 + stringsLength;
|
|
1746
|
+
if (info2.style) {
|
|
1747
|
+
encodedStyleStyle = encoder.encode(info2.style.style);
|
|
1748
|
+
encodedStyleWeight = encoder.encode(info2.style.weight);
|
|
1749
|
+
lengthEstimate += 4 + encodedStyleStyle.length + 4 + encodedStyleWeight.length;
|
|
1750
|
+
}
|
|
1751
|
+
const buffer = new ArrayBuffer(lengthEstimate);
|
|
1752
|
+
const data = new Uint8Array(buffer);
|
|
1753
|
+
const view = new DataView(buffer);
|
|
1754
|
+
let offset = 0;
|
|
1755
|
+
view.setUint8(offset++, info2.guessFallback ? 1 : 0);
|
|
1756
|
+
view.setUint32(offset, 0);
|
|
1757
|
+
offset += 4;
|
|
1758
|
+
stringsLength = 0;
|
|
1759
|
+
for (const prop of _SystemFontInfo.strings) {
|
|
1760
|
+
const encoded = encodedStrings[prop];
|
|
1761
|
+
const length = encoded.length;
|
|
1762
|
+
stringsLength += 4 + length;
|
|
1763
|
+
view.setUint32(offset, length);
|
|
1764
|
+
data.set(encoded, offset + 4);
|
|
1765
|
+
offset += 4 + length;
|
|
1766
|
+
}
|
|
1767
|
+
view.setUint32(offset - stringsLength - 4, stringsLength);
|
|
1768
|
+
if (info2.style) {
|
|
1769
|
+
view.setUint32(offset, encodedStyleStyle.length);
|
|
1770
|
+
data.set(encodedStyleStyle, offset + 4);
|
|
1771
|
+
offset += 4 + encodedStyleStyle.length;
|
|
1772
|
+
view.setUint32(offset, encodedStyleWeight.length);
|
|
1773
|
+
data.set(encodedStyleWeight, offset + 4);
|
|
1774
|
+
offset += 4 + encodedStyleWeight.length;
|
|
1775
|
+
}
|
|
1776
|
+
assert(
|
|
1777
|
+
offset <= buffer.byteLength,
|
|
1778
|
+
"SubstitionInfo.write: Buffer overflow"
|
|
1779
|
+
);
|
|
1780
|
+
return buffer.transferToFixedLength(offset);
|
|
1781
|
+
}
|
|
1782
|
+
get guessFallback() {
|
|
1783
|
+
return __privateGet(this, _view2).getUint8(0) !== 0;
|
|
1784
|
+
}
|
|
1785
|
+
get css() {
|
|
1786
|
+
return __privateMethod(this, _SystemFontInfo_instances, readString_fn2).call(this, 0);
|
|
1787
|
+
}
|
|
1788
|
+
get loadedName() {
|
|
1789
|
+
return __privateMethod(this, _SystemFontInfo_instances, readString_fn2).call(this, 1);
|
|
1790
|
+
}
|
|
1791
|
+
get baseFontName() {
|
|
1792
|
+
return __privateMethod(this, _SystemFontInfo_instances, readString_fn2).call(this, 2);
|
|
1793
|
+
}
|
|
1794
|
+
get src() {
|
|
1795
|
+
return __privateMethod(this, _SystemFontInfo_instances, readString_fn2).call(this, 3);
|
|
1796
|
+
}
|
|
1797
|
+
get style() {
|
|
1798
|
+
let offset = 1;
|
|
1799
|
+
offset += 4 + __privateGet(this, _view2).getUint32(offset);
|
|
1800
|
+
const styleLength = __privateGet(this, _view2).getUint32(offset);
|
|
1801
|
+
const style = __privateGet(this, _decoder2).decode(
|
|
1802
|
+
new Uint8Array(__privateGet(this, _buffer2), offset + 4, styleLength)
|
|
1803
|
+
);
|
|
1804
|
+
offset += 4 + styleLength;
|
|
1805
|
+
const weightLength = __privateGet(this, _view2).getUint32(offset);
|
|
1806
|
+
const weight = __privateGet(this, _decoder2).decode(
|
|
1807
|
+
new Uint8Array(__privateGet(this, _buffer2), offset + 4, weightLength)
|
|
1808
|
+
);
|
|
1809
|
+
return { style, weight };
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
_buffer2 = new WeakMap();
|
|
1813
|
+
_view2 = new WeakMap();
|
|
1814
|
+
_decoder2 = new WeakMap();
|
|
1815
|
+
_SystemFontInfo_instances = new WeakSet();
|
|
1816
|
+
readString_fn2 = function(index) {
|
|
1817
|
+
assert(index < _SystemFontInfo.strings.length, "Invalid string index");
|
|
1818
|
+
let offset = 5;
|
|
1819
|
+
for (let i = 0; i < index; i++) {
|
|
1820
|
+
offset += __privateGet(this, _view2).getUint32(offset) + 4;
|
|
1821
|
+
}
|
|
1822
|
+
const length = __privateGet(this, _view2).getUint32(offset);
|
|
1823
|
+
return __privateGet(this, _decoder2).decode(
|
|
1824
|
+
new Uint8Array(__privateGet(this, _buffer2), offset + 4, length)
|
|
1825
|
+
);
|
|
1826
|
+
};
|
|
1827
|
+
__publicField(_SystemFontInfo, "strings", ["css", "loadedName", "baseFontName", "src"]);
|
|
1828
|
+
var SystemFontInfo = _SystemFontInfo;
|
|
1829
|
+
var _OFFSET_NUMBERS, _OFFSET_BBOX, _OFFSET_FONT_MATRIX, _OFFSET_DEFAULT_VMETRICS, _OFFSET_STRINGS, _buffer3, _decoder3, _view3, _FontInfo_instances, readBoolean_fn, readNumber_fn, readString_fn3;
|
|
1830
|
+
var _FontInfo = class _FontInfo {
|
|
1831
|
+
constructor({ data, extra }) {
|
|
1832
|
+
__privateAdd(this, _FontInfo_instances);
|
|
1833
|
+
__privateAdd(this, _buffer3);
|
|
1834
|
+
__privateAdd(this, _decoder3);
|
|
1835
|
+
__privateAdd(this, _view3);
|
|
1836
|
+
__privateSet(this, _buffer3, data);
|
|
1837
|
+
__privateSet(this, _decoder3, new TextDecoder());
|
|
1838
|
+
__privateSet(this, _view3, new DataView(__privateGet(this, _buffer3)));
|
|
1839
|
+
if (extra) {
|
|
1840
|
+
Object.assign(this, extra);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
get black() {
|
|
1844
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 0);
|
|
1845
|
+
}
|
|
1846
|
+
get bold() {
|
|
1847
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 1);
|
|
1848
|
+
}
|
|
1849
|
+
get disableFontFace() {
|
|
1850
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 2);
|
|
1851
|
+
}
|
|
1852
|
+
get fontExtraProperties() {
|
|
1853
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 3);
|
|
1854
|
+
}
|
|
1855
|
+
get isInvalidPDFjsFont() {
|
|
1856
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 4);
|
|
1857
|
+
}
|
|
1858
|
+
get isType3Font() {
|
|
1859
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 5);
|
|
1860
|
+
}
|
|
1861
|
+
get italic() {
|
|
1862
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 6);
|
|
1863
|
+
}
|
|
1864
|
+
get missingFile() {
|
|
1865
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 7);
|
|
1866
|
+
}
|
|
1867
|
+
get remeasure() {
|
|
1868
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 8);
|
|
1869
|
+
}
|
|
1870
|
+
get vertical() {
|
|
1871
|
+
return __privateMethod(this, _FontInfo_instances, readBoolean_fn).call(this, 9);
|
|
1872
|
+
}
|
|
1873
|
+
get ascent() {
|
|
1874
|
+
return __privateMethod(this, _FontInfo_instances, readNumber_fn).call(this, 0);
|
|
1875
|
+
}
|
|
1876
|
+
get defaultWidth() {
|
|
1877
|
+
return __privateMethod(this, _FontInfo_instances, readNumber_fn).call(this, 1);
|
|
1878
|
+
}
|
|
1879
|
+
get descent() {
|
|
1880
|
+
return __privateMethod(this, _FontInfo_instances, readNumber_fn).call(this, 2);
|
|
1881
|
+
}
|
|
1882
|
+
get bbox() {
|
|
1883
|
+
let offset = __privateGet(_FontInfo, _OFFSET_BBOX);
|
|
1884
|
+
const numCoords = __privateGet(this, _view3).getUint8(offset);
|
|
1885
|
+
if (numCoords === 0) {
|
|
1886
|
+
return void 0;
|
|
1887
|
+
}
|
|
1888
|
+
offset += 1;
|
|
1889
|
+
const bbox = [];
|
|
1890
|
+
for (let i = 0; i < 4; i++) {
|
|
1891
|
+
bbox.push(__privateGet(this, _view3).getInt16(offset, true));
|
|
1892
|
+
offset += 2;
|
|
1893
|
+
}
|
|
1894
|
+
return bbox;
|
|
1895
|
+
}
|
|
1896
|
+
get fontMatrix() {
|
|
1897
|
+
let offset = __privateGet(_FontInfo, _OFFSET_FONT_MATRIX);
|
|
1898
|
+
const numPoints = __privateGet(this, _view3).getUint8(offset);
|
|
1899
|
+
if (numPoints === 0) {
|
|
1900
|
+
return void 0;
|
|
1901
|
+
}
|
|
1902
|
+
offset += 1;
|
|
1903
|
+
const fontMatrix = [];
|
|
1904
|
+
for (let i = 0; i < 6; i++) {
|
|
1905
|
+
fontMatrix.push(__privateGet(this, _view3).getFloat64(offset, true));
|
|
1906
|
+
offset += 8;
|
|
1907
|
+
}
|
|
1908
|
+
return fontMatrix;
|
|
1909
|
+
}
|
|
1910
|
+
get defaultVMetrics() {
|
|
1911
|
+
let offset = __privateGet(_FontInfo, _OFFSET_DEFAULT_VMETRICS);
|
|
1912
|
+
const numMetrics = __privateGet(this, _view3).getUint8(offset);
|
|
1913
|
+
if (numMetrics === 0) {
|
|
1914
|
+
return void 0;
|
|
1915
|
+
}
|
|
1916
|
+
offset += 1;
|
|
1917
|
+
const defaultVMetrics = [];
|
|
1918
|
+
for (let i = 0; i < 3; i++) {
|
|
1919
|
+
defaultVMetrics.push(__privateGet(this, _view3).getInt16(offset, true));
|
|
1920
|
+
offset += 2;
|
|
1921
|
+
}
|
|
1922
|
+
return defaultVMetrics;
|
|
1923
|
+
}
|
|
1924
|
+
get fallbackName() {
|
|
1925
|
+
return __privateMethod(this, _FontInfo_instances, readString_fn3).call(this, 0);
|
|
1926
|
+
}
|
|
1927
|
+
get loadedName() {
|
|
1928
|
+
return __privateMethod(this, _FontInfo_instances, readString_fn3).call(this, 1);
|
|
1929
|
+
}
|
|
1930
|
+
get mimetype() {
|
|
1931
|
+
return __privateMethod(this, _FontInfo_instances, readString_fn3).call(this, 2);
|
|
1932
|
+
}
|
|
1933
|
+
get name() {
|
|
1934
|
+
return __privateMethod(this, _FontInfo_instances, readString_fn3).call(this, 3);
|
|
1935
|
+
}
|
|
1936
|
+
get data() {
|
|
1937
|
+
let offset = __privateGet(_FontInfo, _OFFSET_STRINGS);
|
|
1938
|
+
const stringsLength = __privateGet(this, _view3).getUint32(offset);
|
|
1939
|
+
offset += 4 + stringsLength;
|
|
1940
|
+
const systemFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1941
|
+
offset += 4 + systemFontInfoLength;
|
|
1942
|
+
const cssFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1943
|
+
offset += 4 + cssFontInfoLength;
|
|
1944
|
+
const length = __privateGet(this, _view3).getUint32(offset);
|
|
1945
|
+
if (length === 0) {
|
|
1946
|
+
return void 0;
|
|
1947
|
+
}
|
|
1948
|
+
return new Uint8Array(__privateGet(this, _buffer3), offset + 4, length);
|
|
1949
|
+
}
|
|
1950
|
+
clearData() {
|
|
1951
|
+
let offset = __privateGet(_FontInfo, _OFFSET_STRINGS);
|
|
1952
|
+
const stringsLength = __privateGet(this, _view3).getUint32(offset);
|
|
1953
|
+
offset += 4 + stringsLength;
|
|
1954
|
+
const systemFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1955
|
+
offset += 4 + systemFontInfoLength;
|
|
1956
|
+
const cssFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1957
|
+
offset += 4 + cssFontInfoLength;
|
|
1958
|
+
const length = __privateGet(this, _view3).getUint32(offset);
|
|
1959
|
+
const data = new Uint8Array(__privateGet(this, _buffer3), offset + 4, length);
|
|
1960
|
+
data.fill(0);
|
|
1961
|
+
__privateGet(this, _view3).setUint32(offset, 0);
|
|
1962
|
+
}
|
|
1963
|
+
get cssFontInfo() {
|
|
1964
|
+
let offset = __privateGet(_FontInfo, _OFFSET_STRINGS);
|
|
1965
|
+
const stringsLength = __privateGet(this, _view3).getUint32(offset);
|
|
1966
|
+
offset += 4 + stringsLength;
|
|
1967
|
+
const systemFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1968
|
+
offset += 4 + systemFontInfoLength;
|
|
1969
|
+
const cssFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1970
|
+
if (cssFontInfoLength === 0) {
|
|
1971
|
+
return null;
|
|
1972
|
+
}
|
|
1973
|
+
const cssFontInfoData = new Uint8Array(cssFontInfoLength);
|
|
1974
|
+
cssFontInfoData.set(
|
|
1975
|
+
new Uint8Array(__privateGet(this, _buffer3), offset + 4, cssFontInfoLength)
|
|
1976
|
+
);
|
|
1977
|
+
return new CssFontInfo(cssFontInfoData.buffer);
|
|
1978
|
+
}
|
|
1979
|
+
get systemFontInfo() {
|
|
1980
|
+
let offset = __privateGet(_FontInfo, _OFFSET_STRINGS);
|
|
1981
|
+
const stringsLength = __privateGet(this, _view3).getUint32(offset);
|
|
1982
|
+
offset += 4 + stringsLength;
|
|
1983
|
+
const systemFontInfoLength = __privateGet(this, _view3).getUint32(offset);
|
|
1984
|
+
if (systemFontInfoLength === 0) {
|
|
1985
|
+
return null;
|
|
1986
|
+
}
|
|
1987
|
+
const systemFontInfoData = new Uint8Array(systemFontInfoLength);
|
|
1988
|
+
systemFontInfoData.set(
|
|
1989
|
+
new Uint8Array(__privateGet(this, _buffer3), offset + 4, systemFontInfoLength)
|
|
1990
|
+
);
|
|
1991
|
+
return new SystemFontInfo(systemFontInfoData.buffer);
|
|
1992
|
+
}
|
|
1993
|
+
static write(font) {
|
|
1994
|
+
const systemFontInfoBuffer = font.systemFontInfo ? SystemFontInfo.write(font.systemFontInfo) : null;
|
|
1995
|
+
const cssFontInfoBuffer = font.cssFontInfo ? CssFontInfo.write(font.cssFontInfo) : null;
|
|
1996
|
+
const encoder = new TextEncoder();
|
|
1997
|
+
const encodedStrings = {};
|
|
1998
|
+
let stringsLength = 0;
|
|
1999
|
+
for (const prop of _FontInfo.strings) {
|
|
2000
|
+
encodedStrings[prop] = encoder.encode(font[prop]);
|
|
2001
|
+
stringsLength += 4 + encodedStrings[prop].length;
|
|
2002
|
+
}
|
|
2003
|
+
const lengthEstimate = __privateGet(_FontInfo, _OFFSET_STRINGS) + 4 + stringsLength + 4 + (systemFontInfoBuffer ? systemFontInfoBuffer.byteLength : 0) + 4 + (cssFontInfoBuffer ? cssFontInfoBuffer.byteLength : 0) + 4 + (font.data ? font.data.length : 0);
|
|
2004
|
+
const buffer = new ArrayBuffer(lengthEstimate);
|
|
2005
|
+
const data = new Uint8Array(buffer);
|
|
2006
|
+
const view = new DataView(buffer);
|
|
2007
|
+
let offset = 0;
|
|
2008
|
+
const numBools = _FontInfo.bools.length;
|
|
2009
|
+
let boolByte = 0, boolBit = 0;
|
|
2010
|
+
for (let i = 0; i < numBools; i++) {
|
|
2011
|
+
const value = font[_FontInfo.bools[i]];
|
|
2012
|
+
const bits = value === void 0 ? 0 : value ? 2 : 1;
|
|
2013
|
+
boolByte |= bits << boolBit;
|
|
2014
|
+
boolBit += 2;
|
|
2015
|
+
if (boolBit === 8 || i === numBools - 1) {
|
|
2016
|
+
view.setUint8(offset++, boolByte);
|
|
2017
|
+
boolByte = 0;
|
|
2018
|
+
boolBit = 0;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
assert(
|
|
2022
|
+
offset === __privateGet(_FontInfo, _OFFSET_NUMBERS),
|
|
2023
|
+
"FontInfo.write: Boolean properties offset mismatch"
|
|
2024
|
+
);
|
|
2025
|
+
for (const prop of _FontInfo.numbers) {
|
|
2026
|
+
view.setFloat64(offset, font[prop]);
|
|
2027
|
+
offset += 8;
|
|
2028
|
+
}
|
|
2029
|
+
assert(
|
|
2030
|
+
offset === __privateGet(_FontInfo, _OFFSET_BBOX),
|
|
2031
|
+
"FontInfo.write: Number properties offset mismatch"
|
|
2032
|
+
);
|
|
2033
|
+
if (font.bbox) {
|
|
2034
|
+
view.setUint8(offset++, 4);
|
|
2035
|
+
for (const coord of font.bbox) {
|
|
2036
|
+
view.setInt16(offset, coord, true);
|
|
2037
|
+
offset += 2;
|
|
2038
|
+
}
|
|
2039
|
+
} else {
|
|
2040
|
+
view.setUint8(offset++, 0);
|
|
2041
|
+
offset += 2 * 4;
|
|
2042
|
+
}
|
|
2043
|
+
assert(
|
|
2044
|
+
offset === __privateGet(_FontInfo, _OFFSET_FONT_MATRIX),
|
|
2045
|
+
"FontInfo.write: BBox properties offset mismatch"
|
|
2046
|
+
);
|
|
2047
|
+
if (font.fontMatrix) {
|
|
2048
|
+
view.setUint8(offset++, 6);
|
|
2049
|
+
for (const point of font.fontMatrix) {
|
|
2050
|
+
view.setFloat64(offset, point, true);
|
|
2051
|
+
offset += 8;
|
|
2052
|
+
}
|
|
2053
|
+
} else {
|
|
2054
|
+
view.setUint8(offset++, 0);
|
|
2055
|
+
offset += 8 * 6;
|
|
2056
|
+
}
|
|
2057
|
+
assert(
|
|
2058
|
+
offset === __privateGet(_FontInfo, _OFFSET_DEFAULT_VMETRICS),
|
|
2059
|
+
"FontInfo.write: FontMatrix properties offset mismatch"
|
|
2060
|
+
);
|
|
2061
|
+
if (font.defaultVMetrics) {
|
|
2062
|
+
view.setUint8(offset++, 1);
|
|
2063
|
+
for (const metric of font.defaultVMetrics) {
|
|
2064
|
+
view.setInt16(offset, metric, true);
|
|
2065
|
+
offset += 2;
|
|
2066
|
+
}
|
|
2067
|
+
} else {
|
|
2068
|
+
view.setUint8(offset++, 0);
|
|
2069
|
+
offset += 3 * 2;
|
|
2070
|
+
}
|
|
2071
|
+
assert(
|
|
2072
|
+
offset === __privateGet(_FontInfo, _OFFSET_STRINGS),
|
|
2073
|
+
"FontInfo.write: DefaultVMetrics properties offset mismatch"
|
|
2074
|
+
);
|
|
2075
|
+
view.setUint32(__privateGet(_FontInfo, _OFFSET_STRINGS), 0);
|
|
2076
|
+
offset += 4;
|
|
2077
|
+
for (const prop of _FontInfo.strings) {
|
|
2078
|
+
const encoded = encodedStrings[prop];
|
|
2079
|
+
const length = encoded.length;
|
|
2080
|
+
view.setUint32(offset, length);
|
|
2081
|
+
data.set(encoded, offset + 4);
|
|
2082
|
+
offset += 4 + length;
|
|
2083
|
+
}
|
|
2084
|
+
view.setUint32(
|
|
2085
|
+
__privateGet(_FontInfo, _OFFSET_STRINGS),
|
|
2086
|
+
offset - __privateGet(_FontInfo, _OFFSET_STRINGS) - 4
|
|
2087
|
+
);
|
|
2088
|
+
if (!systemFontInfoBuffer) {
|
|
2089
|
+
view.setUint32(offset, 0);
|
|
2090
|
+
offset += 4;
|
|
2091
|
+
} else {
|
|
2092
|
+
const length = systemFontInfoBuffer.byteLength;
|
|
2093
|
+
view.setUint32(offset, length);
|
|
2094
|
+
assert(
|
|
2095
|
+
offset + 4 + length <= buffer.byteLength,
|
|
2096
|
+
"FontInfo.write: Buffer overflow at systemFontInfo"
|
|
2097
|
+
);
|
|
2098
|
+
data.set(new Uint8Array(systemFontInfoBuffer), offset + 4);
|
|
2099
|
+
offset += 4 + length;
|
|
2100
|
+
}
|
|
2101
|
+
if (!cssFontInfoBuffer) {
|
|
2102
|
+
view.setUint32(offset, 0);
|
|
2103
|
+
offset += 4;
|
|
2104
|
+
} else {
|
|
2105
|
+
const length = cssFontInfoBuffer.byteLength;
|
|
2106
|
+
view.setUint32(offset, length);
|
|
2107
|
+
assert(
|
|
2108
|
+
offset + 4 + length <= buffer.byteLength,
|
|
2109
|
+
"FontInfo.write: Buffer overflow at cssFontInfo"
|
|
2110
|
+
);
|
|
2111
|
+
data.set(new Uint8Array(cssFontInfoBuffer), offset + 4);
|
|
2112
|
+
offset += 4 + length;
|
|
2113
|
+
}
|
|
2114
|
+
if (font.data === void 0) {
|
|
2115
|
+
view.setUint32(offset, 0);
|
|
2116
|
+
offset += 4;
|
|
2117
|
+
} else {
|
|
2118
|
+
view.setUint32(offset, font.data.length);
|
|
2119
|
+
data.set(font.data, offset + 4);
|
|
2120
|
+
offset += 4 + font.data.length;
|
|
2121
|
+
}
|
|
2122
|
+
assert(offset <= buffer.byteLength, "FontInfo.write: Buffer overflow");
|
|
2123
|
+
return buffer.transferToFixedLength(offset);
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
_OFFSET_NUMBERS = new WeakMap();
|
|
2127
|
+
_OFFSET_BBOX = new WeakMap();
|
|
2128
|
+
_OFFSET_FONT_MATRIX = new WeakMap();
|
|
2129
|
+
_OFFSET_DEFAULT_VMETRICS = new WeakMap();
|
|
2130
|
+
_OFFSET_STRINGS = new WeakMap();
|
|
2131
|
+
_buffer3 = new WeakMap();
|
|
2132
|
+
_decoder3 = new WeakMap();
|
|
2133
|
+
_view3 = new WeakMap();
|
|
2134
|
+
_FontInfo_instances = new WeakSet();
|
|
2135
|
+
readBoolean_fn = function(index) {
|
|
2136
|
+
assert(index < _FontInfo.bools.length, "Invalid boolean index");
|
|
2137
|
+
const byteOffset = Math.floor(index / 4);
|
|
2138
|
+
const bitOffset = index * 2 % 8;
|
|
2139
|
+
const value = __privateGet(this, _view3).getUint8(byteOffset) >> bitOffset & 3;
|
|
2140
|
+
return value === 0 ? void 0 : value === 2;
|
|
2141
|
+
};
|
|
2142
|
+
readNumber_fn = function(index) {
|
|
2143
|
+
assert(index < _FontInfo.numbers.length, "Invalid number index");
|
|
2144
|
+
return __privateGet(this, _view3).getFloat64(__privateGet(_FontInfo, _OFFSET_NUMBERS) + index * 8);
|
|
2145
|
+
};
|
|
2146
|
+
readString_fn3 = function(index) {
|
|
2147
|
+
assert(index < _FontInfo.strings.length, "Invalid string index");
|
|
2148
|
+
let offset = __privateGet(_FontInfo, _OFFSET_STRINGS) + 4;
|
|
2149
|
+
for (let i = 0; i < index; i++) {
|
|
2150
|
+
offset += __privateGet(this, _view3).getUint32(offset) + 4;
|
|
2151
|
+
}
|
|
2152
|
+
const length = __privateGet(this, _view3).getUint32(offset);
|
|
2153
|
+
const stringData = new Uint8Array(length);
|
|
2154
|
+
stringData.set(new Uint8Array(__privateGet(this, _buffer3), offset + 4, length));
|
|
2155
|
+
return __privateGet(this, _decoder3).decode(stringData);
|
|
2156
|
+
};
|
|
2157
|
+
__publicField(_FontInfo, "bools", [
|
|
2158
|
+
"black",
|
|
2159
|
+
"bold",
|
|
2160
|
+
"disableFontFace",
|
|
2161
|
+
"fontExtraProperties",
|
|
2162
|
+
"isInvalidPDFjsFont",
|
|
2163
|
+
"isType3Font",
|
|
2164
|
+
"italic",
|
|
2165
|
+
"missingFile",
|
|
2166
|
+
"remeasure",
|
|
2167
|
+
"vertical"
|
|
2168
|
+
]);
|
|
2169
|
+
__publicField(_FontInfo, "numbers", ["ascent", "defaultWidth", "descent"]);
|
|
2170
|
+
__publicField(_FontInfo, "strings", ["fallbackName", "loadedName", "mimetype", "name"]);
|
|
2171
|
+
__privateAdd(_FontInfo, _OFFSET_NUMBERS, Math.ceil(_FontInfo.bools.length * 2 / 8));
|
|
2172
|
+
__privateAdd(_FontInfo, _OFFSET_BBOX, __privateGet(_FontInfo, _OFFSET_NUMBERS) + _FontInfo.numbers.length * 8);
|
|
2173
|
+
__privateAdd(_FontInfo, _OFFSET_FONT_MATRIX, __privateGet(_FontInfo, _OFFSET_BBOX) + 1 + 2 * 4);
|
|
2174
|
+
__privateAdd(_FontInfo, _OFFSET_DEFAULT_VMETRICS, __privateGet(_FontInfo, _OFFSET_FONT_MATRIX) + 1 + 8 * 6);
|
|
2175
|
+
__privateAdd(_FontInfo, _OFFSET_STRINGS, __privateGet(_FontInfo, _OFFSET_DEFAULT_VMETRICS) + 1 + 2 * 3);
|
|
2176
|
+
var FontInfo = _FontInfo;
|
|
2177
|
+
|
|
1661
2178
|
// src/pdf.js/src/shared/scripting_utils.js
|
|
1662
2179
|
function makeColorComp(n) {
|
|
1663
2180
|
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
@@ -2001,6 +2518,7 @@ export {
|
|
|
2001
2518
|
convertToRGBA,
|
|
2002
2519
|
convertBlackAndWhiteToRGBA,
|
|
2003
2520
|
grayToRGBA,
|
|
2521
|
+
FontInfo,
|
|
2004
2522
|
ColorConverters,
|
|
2005
2523
|
DateFormats,
|
|
2006
2524
|
TimeFormats
|