Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/embedpre.../assets/pdf/build
File: pdf.worker.js
continue;
[37000] Fix | Delete
}
[37001] Fix | Delete
break;
[37002] Fix | Delete
}
[37003] Fix | Delete
if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
[37004] Fix | Delete
if (baseEncodingName && code === +charcode) {
[37005] Fix | Delete
const baseEncoding = getEncoding(baseEncodingName);
[37006] Fix | Delete
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
[37007] Fix | Delete
toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
[37008] Fix | Delete
continue;
[37009] Fix | Delete
}
[37010] Fix | Delete
}
[37011] Fix | Delete
toUnicode[charcode] = String.fromCodePoint(code);
[37012] Fix | Delete
}
[37013] Fix | Delete
}
[37014] Fix | Delete
return toUnicode;
[37015] Fix | Delete
}
[37016] Fix | Delete
async buildToUnicode(properties) {
[37017] Fix | Delete
properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0;
[37018] Fix | Delete
if (properties.hasIncludedToUnicodeMap) {
[37019] Fix | Delete
if (!properties.composite && properties.hasEncoding) {
[37020] Fix | Delete
properties.fallbackToUnicode = this._simpleFontToUnicode(properties);
[37021] Fix | Delete
}
[37022] Fix | Delete
return properties.toUnicode;
[37023] Fix | Delete
}
[37024] Fix | Delete
if (!properties.composite) {
[37025] Fix | Delete
return new ToUnicodeMap(this._simpleFontToUnicode(properties));
[37026] Fix | Delete
}
[37027] Fix | Delete
if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo?.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
[37028] Fix | Delete
const {
[37029] Fix | Delete
registry,
[37030] Fix | Delete
ordering
[37031] Fix | Delete
} = properties.cidSystemInfo;
[37032] Fix | Delete
const ucs2CMapName = Name.get(`${registry}-${ordering}-UCS2`);
[37033] Fix | Delete
const ucs2CMap = await CMapFactory.create({
[37034] Fix | Delete
encoding: ucs2CMapName,
[37035] Fix | Delete
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
[37036] Fix | Delete
useCMap: null
[37037] Fix | Delete
});
[37038] Fix | Delete
const toUnicode = [],
[37039] Fix | Delete
buf = [];
[37040] Fix | Delete
properties.cMap.forEach(function (charcode, cid) {
[37041] Fix | Delete
if (cid > 0xffff) {
[37042] Fix | Delete
throw new FormatError("Max size of CID is 65,535");
[37043] Fix | Delete
}
[37044] Fix | Delete
const ucs2 = ucs2CMap.lookup(cid);
[37045] Fix | Delete
if (ucs2) {
[37046] Fix | Delete
buf.length = 0;
[37047] Fix | Delete
for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
[37048] Fix | Delete
buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1));
[37049] Fix | Delete
}
[37050] Fix | Delete
toUnicode[charcode] = String.fromCharCode(...buf);
[37051] Fix | Delete
}
[37052] Fix | Delete
});
[37053] Fix | Delete
return new ToUnicodeMap(toUnicode);
[37054] Fix | Delete
}
[37055] Fix | Delete
return new IdentityToUnicodeMap(properties.firstChar, properties.lastChar);
[37056] Fix | Delete
}
[37057] Fix | Delete
async readToUnicode(cmapObj) {
[37058] Fix | Delete
if (!cmapObj) {
[37059] Fix | Delete
return null;
[37060] Fix | Delete
}
[37061] Fix | Delete
if (cmapObj instanceof Name) {
[37062] Fix | Delete
const cmap = await CMapFactory.create({
[37063] Fix | Delete
encoding: cmapObj,
[37064] Fix | Delete
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
[37065] Fix | Delete
useCMap: null
[37066] Fix | Delete
});
[37067] Fix | Delete
if (cmap instanceof IdentityCMap) {
[37068] Fix | Delete
return new IdentityToUnicodeMap(0, 0xffff);
[37069] Fix | Delete
}
[37070] Fix | Delete
return new ToUnicodeMap(cmap.getMap());
[37071] Fix | Delete
}
[37072] Fix | Delete
if (cmapObj instanceof BaseStream) {
[37073] Fix | Delete
try {
[37074] Fix | Delete
const cmap = await CMapFactory.create({
[37075] Fix | Delete
encoding: cmapObj,
[37076] Fix | Delete
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
[37077] Fix | Delete
useCMap: null
[37078] Fix | Delete
});
[37079] Fix | Delete
if (cmap instanceof IdentityCMap) {
[37080] Fix | Delete
return new IdentityToUnicodeMap(0, 0xffff);
[37081] Fix | Delete
}
[37082] Fix | Delete
const map = new Array(cmap.length);
[37083] Fix | Delete
cmap.forEach(function (charCode, token) {
[37084] Fix | Delete
if (typeof token === "number") {
[37085] Fix | Delete
map[charCode] = String.fromCodePoint(token);
[37086] Fix | Delete
return;
[37087] Fix | Delete
}
[37088] Fix | Delete
const str = [];
[37089] Fix | Delete
for (let k = 0; k < token.length; k += 2) {
[37090] Fix | Delete
const w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
[37091] Fix | Delete
if ((w1 & 0xf800) !== 0xd800) {
[37092] Fix | Delete
str.push(w1);
[37093] Fix | Delete
continue;
[37094] Fix | Delete
}
[37095] Fix | Delete
k += 2;
[37096] Fix | Delete
const w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
[37097] Fix | Delete
str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
[37098] Fix | Delete
}
[37099] Fix | Delete
map[charCode] = String.fromCodePoint(...str);
[37100] Fix | Delete
});
[37101] Fix | Delete
return new ToUnicodeMap(map);
[37102] Fix | Delete
} catch (reason) {
[37103] Fix | Delete
if (reason instanceof AbortException) {
[37104] Fix | Delete
return null;
[37105] Fix | Delete
}
[37106] Fix | Delete
if (this.options.ignoreErrors) {
[37107] Fix | Delete
warn(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
[37108] Fix | Delete
return null;
[37109] Fix | Delete
}
[37110] Fix | Delete
throw reason;
[37111] Fix | Delete
}
[37112] Fix | Delete
}
[37113] Fix | Delete
return null;
[37114] Fix | Delete
}
[37115] Fix | Delete
readCidToGidMap(glyphsData, toUnicode) {
[37116] Fix | Delete
const result = [];
[37117] Fix | Delete
for (let j = 0, jj = glyphsData.length; j < jj; j++) {
[37118] Fix | Delete
const glyphID = glyphsData[j++] << 8 | glyphsData[j];
[37119] Fix | Delete
const code = j >> 1;
[37120] Fix | Delete
if (glyphID === 0 && !toUnicode.has(code)) {
[37121] Fix | Delete
continue;
[37122] Fix | Delete
}
[37123] Fix | Delete
result[code] = glyphID;
[37124] Fix | Delete
}
[37125] Fix | Delete
return result;
[37126] Fix | Delete
}
[37127] Fix | Delete
extractWidths(dict, descriptor, properties) {
[37128] Fix | Delete
const xref = this.xref;
[37129] Fix | Delete
let glyphsWidths = [];
[37130] Fix | Delete
let defaultWidth = 0;
[37131] Fix | Delete
const glyphsVMetrics = [];
[37132] Fix | Delete
let defaultVMetrics;
[37133] Fix | Delete
if (properties.composite) {
[37134] Fix | Delete
const dw = dict.get("DW");
[37135] Fix | Delete
defaultWidth = Number.isInteger(dw) ? dw : 1000;
[37136] Fix | Delete
const widths = dict.get("W");
[37137] Fix | Delete
if (Array.isArray(widths)) {
[37138] Fix | Delete
for (let i = 0, ii = widths.length; i < ii; i++) {
[37139] Fix | Delete
let start = xref.fetchIfRef(widths[i++]);
[37140] Fix | Delete
if (!Number.isInteger(start)) {
[37141] Fix | Delete
break;
[37142] Fix | Delete
}
[37143] Fix | Delete
const code = xref.fetchIfRef(widths[i]);
[37144] Fix | Delete
if (Array.isArray(code)) {
[37145] Fix | Delete
for (const c of code) {
[37146] Fix | Delete
const width = xref.fetchIfRef(c);
[37147] Fix | Delete
if (typeof width === "number") {
[37148] Fix | Delete
glyphsWidths[start] = width;
[37149] Fix | Delete
}
[37150] Fix | Delete
start++;
[37151] Fix | Delete
}
[37152] Fix | Delete
} else if (Number.isInteger(code)) {
[37153] Fix | Delete
const width = xref.fetchIfRef(widths[++i]);
[37154] Fix | Delete
if (typeof width !== "number") {
[37155] Fix | Delete
continue;
[37156] Fix | Delete
}
[37157] Fix | Delete
for (let j = start; j <= code; j++) {
[37158] Fix | Delete
glyphsWidths[j] = width;
[37159] Fix | Delete
}
[37160] Fix | Delete
} else {
[37161] Fix | Delete
break;
[37162] Fix | Delete
}
[37163] Fix | Delete
}
[37164] Fix | Delete
}
[37165] Fix | Delete
if (properties.vertical) {
[37166] Fix | Delete
const dw2 = dict.getArray("DW2");
[37167] Fix | Delete
let vmetrics = isNumberArray(dw2, 2) ? dw2 : [880, -1000];
[37168] Fix | Delete
defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
[37169] Fix | Delete
vmetrics = dict.get("W2");
[37170] Fix | Delete
if (Array.isArray(vmetrics)) {
[37171] Fix | Delete
for (let i = 0, ii = vmetrics.length; i < ii; i++) {
[37172] Fix | Delete
let start = xref.fetchIfRef(vmetrics[i++]);
[37173] Fix | Delete
if (!Number.isInteger(start)) {
[37174] Fix | Delete
break;
[37175] Fix | Delete
}
[37176] Fix | Delete
const code = xref.fetchIfRef(vmetrics[i]);
[37177] Fix | Delete
if (Array.isArray(code)) {
[37178] Fix | Delete
for (let j = 0, jj = code.length; j < jj; j++) {
[37179] Fix | Delete
const vmetric = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
[37180] Fix | Delete
if (isNumberArray(vmetric, null)) {
[37181] Fix | Delete
glyphsVMetrics[start] = vmetric;
[37182] Fix | Delete
}
[37183] Fix | Delete
start++;
[37184] Fix | Delete
}
[37185] Fix | Delete
} else if (Number.isInteger(code)) {
[37186] Fix | Delete
const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
[37187] Fix | Delete
if (!isNumberArray(vmetric, null)) {
[37188] Fix | Delete
continue;
[37189] Fix | Delete
}
[37190] Fix | Delete
for (let j = start; j <= code; j++) {
[37191] Fix | Delete
glyphsVMetrics[j] = vmetric;
[37192] Fix | Delete
}
[37193] Fix | Delete
} else {
[37194] Fix | Delete
break;
[37195] Fix | Delete
}
[37196] Fix | Delete
}
[37197] Fix | Delete
}
[37198] Fix | Delete
}
[37199] Fix | Delete
} else {
[37200] Fix | Delete
const widths = dict.get("Widths");
[37201] Fix | Delete
if (Array.isArray(widths)) {
[37202] Fix | Delete
let j = properties.firstChar;
[37203] Fix | Delete
for (const w of widths) {
[37204] Fix | Delete
const width = xref.fetchIfRef(w);
[37205] Fix | Delete
if (typeof width === "number") {
[37206] Fix | Delete
glyphsWidths[j] = width;
[37207] Fix | Delete
}
[37208] Fix | Delete
j++;
[37209] Fix | Delete
}
[37210] Fix | Delete
const missingWidth = descriptor.get("MissingWidth");
[37211] Fix | Delete
defaultWidth = typeof missingWidth === "number" ? missingWidth : 0;
[37212] Fix | Delete
} else {
[37213] Fix | Delete
const baseFontName = dict.get("BaseFont");
[37214] Fix | Delete
if (baseFontName instanceof Name) {
[37215] Fix | Delete
const metrics = this.getBaseFontMetrics(baseFontName.name);
[37216] Fix | Delete
glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
[37217] Fix | Delete
defaultWidth = metrics.defaultWidth;
[37218] Fix | Delete
}
[37219] Fix | Delete
}
[37220] Fix | Delete
}
[37221] Fix | Delete
let isMonospace = true;
[37222] Fix | Delete
let firstWidth = defaultWidth;
[37223] Fix | Delete
for (const glyph in glyphsWidths) {
[37224] Fix | Delete
const glyphWidth = glyphsWidths[glyph];
[37225] Fix | Delete
if (!glyphWidth) {
[37226] Fix | Delete
continue;
[37227] Fix | Delete
}
[37228] Fix | Delete
if (!firstWidth) {
[37229] Fix | Delete
firstWidth = glyphWidth;
[37230] Fix | Delete
continue;
[37231] Fix | Delete
}
[37232] Fix | Delete
if (firstWidth !== glyphWidth) {
[37233] Fix | Delete
isMonospace = false;
[37234] Fix | Delete
break;
[37235] Fix | Delete
}
[37236] Fix | Delete
}
[37237] Fix | Delete
if (isMonospace) {
[37238] Fix | Delete
properties.flags |= FontFlags.FixedPitch;
[37239] Fix | Delete
} else {
[37240] Fix | Delete
properties.flags &= ~FontFlags.FixedPitch;
[37241] Fix | Delete
}
[37242] Fix | Delete
properties.defaultWidth = defaultWidth;
[37243] Fix | Delete
properties.widths = glyphsWidths;
[37244] Fix | Delete
properties.defaultVMetrics = defaultVMetrics;
[37245] Fix | Delete
properties.vmetrics = glyphsVMetrics;
[37246] Fix | Delete
}
[37247] Fix | Delete
isSerifFont(baseFontName) {
[37248] Fix | Delete
const fontNameWoStyle = baseFontName.split("-", 1)[0];
[37249] Fix | Delete
return fontNameWoStyle in getSerifFonts() || /serif/gi.test(fontNameWoStyle);
[37250] Fix | Delete
}
[37251] Fix | Delete
getBaseFontMetrics(name) {
[37252] Fix | Delete
let defaultWidth = 0;
[37253] Fix | Delete
let widths = Object.create(null);
[37254] Fix | Delete
let monospace = false;
[37255] Fix | Delete
const stdFontMap = getStdFontMap();
[37256] Fix | Delete
let lookupName = stdFontMap[name] || name;
[37257] Fix | Delete
const Metrics = getMetrics();
[37258] Fix | Delete
if (!(lookupName in Metrics)) {
[37259] Fix | Delete
lookupName = this.isSerifFont(name) ? "Times-Roman" : "Helvetica";
[37260] Fix | Delete
}
[37261] Fix | Delete
const glyphWidths = Metrics[lookupName];
[37262] Fix | Delete
if (typeof glyphWidths === "number") {
[37263] Fix | Delete
defaultWidth = glyphWidths;
[37264] Fix | Delete
monospace = true;
[37265] Fix | Delete
} else {
[37266] Fix | Delete
widths = glyphWidths();
[37267] Fix | Delete
}
[37268] Fix | Delete
return {
[37269] Fix | Delete
defaultWidth,
[37270] Fix | Delete
monospace,
[37271] Fix | Delete
widths
[37272] Fix | Delete
};
[37273] Fix | Delete
}
[37274] Fix | Delete
buildCharCodeToWidth(widthsByGlyphName, properties) {
[37275] Fix | Delete
const widths = Object.create(null);
[37276] Fix | Delete
const differences = properties.differences;
[37277] Fix | Delete
const encoding = properties.defaultEncoding;
[37278] Fix | Delete
for (let charCode = 0; charCode < 256; charCode++) {
[37279] Fix | Delete
if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
[37280] Fix | Delete
widths[charCode] = widthsByGlyphName[differences[charCode]];
[37281] Fix | Delete
continue;
[37282] Fix | Delete
}
[37283] Fix | Delete
if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
[37284] Fix | Delete
widths[charCode] = widthsByGlyphName[encoding[charCode]];
[37285] Fix | Delete
continue;
[37286] Fix | Delete
}
[37287] Fix | Delete
}
[37288] Fix | Delete
return widths;
[37289] Fix | Delete
}
[37290] Fix | Delete
preEvaluateFont(dict) {
[37291] Fix | Delete
const baseDict = dict;
[37292] Fix | Delete
let type = dict.get("Subtype");
[37293] Fix | Delete
if (!(type instanceof Name)) {
[37294] Fix | Delete
throw new FormatError("invalid font Subtype");
[37295] Fix | Delete
}
[37296] Fix | Delete
let composite = false;
[37297] Fix | Delete
let hash;
[37298] Fix | Delete
if (type.name === "Type0") {
[37299] Fix | Delete
const df = dict.get("DescendantFonts");
[37300] Fix | Delete
if (!df) {
[37301] Fix | Delete
throw new FormatError("Descendant fonts are not specified");
[37302] Fix | Delete
}
[37303] Fix | Delete
dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
[37304] Fix | Delete
if (!(dict instanceof Dict)) {
[37305] Fix | Delete
throw new FormatError("Descendant font is not a dictionary.");
[37306] Fix | Delete
}
[37307] Fix | Delete
type = dict.get("Subtype");
[37308] Fix | Delete
if (!(type instanceof Name)) {
[37309] Fix | Delete
throw new FormatError("invalid font Subtype");
[37310] Fix | Delete
}
[37311] Fix | Delete
composite = true;
[37312] Fix | Delete
}
[37313] Fix | Delete
let firstChar = dict.get("FirstChar");
[37314] Fix | Delete
if (!Number.isInteger(firstChar)) {
[37315] Fix | Delete
firstChar = 0;
[37316] Fix | Delete
}
[37317] Fix | Delete
let lastChar = dict.get("LastChar");
[37318] Fix | Delete
if (!Number.isInteger(lastChar)) {
[37319] Fix | Delete
lastChar = composite ? 0xffff : 0xff;
[37320] Fix | Delete
}
[37321] Fix | Delete
const descriptor = dict.get("FontDescriptor");
[37322] Fix | Delete
const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
[37323] Fix | Delete
if (descriptor) {
[37324] Fix | Delete
hash = new MurmurHash3_64();
[37325] Fix | Delete
const encoding = baseDict.getRaw("Encoding");
[37326] Fix | Delete
if (encoding instanceof Name) {
[37327] Fix | Delete
hash.update(encoding.name);
[37328] Fix | Delete
} else if (encoding instanceof Ref) {
[37329] Fix | Delete
hash.update(encoding.toString());
[37330] Fix | Delete
} else if (encoding instanceof Dict) {
[37331] Fix | Delete
for (const entry of encoding.getRawValues()) {
[37332] Fix | Delete
if (entry instanceof Name) {
[37333] Fix | Delete
hash.update(entry.name);
[37334] Fix | Delete
} else if (entry instanceof Ref) {
[37335] Fix | Delete
hash.update(entry.toString());
[37336] Fix | Delete
} else if (Array.isArray(entry)) {
[37337] Fix | Delete
const diffLength = entry.length,
[37338] Fix | Delete
diffBuf = new Array(diffLength);
[37339] Fix | Delete
for (let j = 0; j < diffLength; j++) {
[37340] Fix | Delete
const diffEntry = entry[j];
[37341] Fix | Delete
if (diffEntry instanceof Name) {
[37342] Fix | Delete
diffBuf[j] = diffEntry.name;
[37343] Fix | Delete
} else if (typeof diffEntry === "number" || diffEntry instanceof Ref) {
[37344] Fix | Delete
diffBuf[j] = diffEntry.toString();
[37345] Fix | Delete
}
[37346] Fix | Delete
}
[37347] Fix | Delete
hash.update(diffBuf.join());
[37348] Fix | Delete
}
[37349] Fix | Delete
}
[37350] Fix | Delete
}
[37351] Fix | Delete
hash.update(`${firstChar}-${lastChar}`);
[37352] Fix | Delete
if (toUnicode instanceof BaseStream) {
[37353] Fix | Delete
const stream = toUnicode.str || toUnicode;
[37354] Fix | Delete
const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
[37355] Fix | Delete
hash.update(uint8array);
[37356] Fix | Delete
} else if (toUnicode instanceof Name) {
[37357] Fix | Delete
hash.update(toUnicode.name);
[37358] Fix | Delete
}
[37359] Fix | Delete
const widths = dict.get("Widths") || baseDict.get("Widths");
[37360] Fix | Delete
if (Array.isArray(widths)) {
[37361] Fix | Delete
const widthsBuf = [];
[37362] Fix | Delete
for (const entry of widths) {
[37363] Fix | Delete
if (typeof entry === "number" || entry instanceof Ref) {
[37364] Fix | Delete
widthsBuf.push(entry.toString());
[37365] Fix | Delete
}
[37366] Fix | Delete
}
[37367] Fix | Delete
hash.update(widthsBuf.join());
[37368] Fix | Delete
}
[37369] Fix | Delete
if (composite) {
[37370] Fix | Delete
hash.update("compositeFont");
[37371] Fix | Delete
const compositeWidths = dict.get("W") || baseDict.get("W");
[37372] Fix | Delete
if (Array.isArray(compositeWidths)) {
[37373] Fix | Delete
const widthsBuf = [];
[37374] Fix | Delete
for (const entry of compositeWidths) {
[37375] Fix | Delete
if (typeof entry === "number" || entry instanceof Ref) {
[37376] Fix | Delete
widthsBuf.push(entry.toString());
[37377] Fix | Delete
} else if (Array.isArray(entry)) {
[37378] Fix | Delete
const subWidthsBuf = [];
[37379] Fix | Delete
for (const element of entry) {
[37380] Fix | Delete
if (typeof element === "number" || element instanceof Ref) {
[37381] Fix | Delete
subWidthsBuf.push(element.toString());
[37382] Fix | Delete
}
[37383] Fix | Delete
}
[37384] Fix | Delete
widthsBuf.push(`[${subWidthsBuf.join()}]`);
[37385] Fix | Delete
}
[37386] Fix | Delete
}
[37387] Fix | Delete
hash.update(widthsBuf.join());
[37388] Fix | Delete
}
[37389] Fix | Delete
const cidToGidMap = dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap");
[37390] Fix | Delete
if (cidToGidMap instanceof Name) {
[37391] Fix | Delete
hash.update(cidToGidMap.name);
[37392] Fix | Delete
} else if (cidToGidMap instanceof Ref) {
[37393] Fix | Delete
hash.update(cidToGidMap.toString());
[37394] Fix | Delete
} else if (cidToGidMap instanceof BaseStream) {
[37395] Fix | Delete
hash.update(cidToGidMap.peekBytes());
[37396] Fix | Delete
}
[37397] Fix | Delete
}
[37398] Fix | Delete
}
[37399] Fix | Delete
return {
[37400] Fix | Delete
descriptor,
[37401] Fix | Delete
dict,
[37402] Fix | Delete
baseDict,
[37403] Fix | Delete
composite,
[37404] Fix | Delete
type: type.name,
[37405] Fix | Delete
firstChar,
[37406] Fix | Delete
lastChar,
[37407] Fix | Delete
toUnicode,
[37408] Fix | Delete
hash: hash ? hash.hexdigest() : ""
[37409] Fix | Delete
};
[37410] Fix | Delete
}
[37411] Fix | Delete
async translateFont({
[37412] Fix | Delete
descriptor,
[37413] Fix | Delete
dict,
[37414] Fix | Delete
baseDict,
[37415] Fix | Delete
composite,
[37416] Fix | Delete
type,
[37417] Fix | Delete
firstChar,
[37418] Fix | Delete
lastChar,
[37419] Fix | Delete
toUnicode,
[37420] Fix | Delete
cssFontInfo
[37421] Fix | Delete
}) {
[37422] Fix | Delete
const isType3Font = type === "Type3";
[37423] Fix | Delete
if (!descriptor) {
[37424] Fix | Delete
if (isType3Font) {
[37425] Fix | Delete
const bbox = lookupNormalRect(dict.getArray("FontBBox"), [0, 0, 0, 0]);
[37426] Fix | Delete
descriptor = new Dict(null);
[37427] Fix | Delete
descriptor.set("FontName", Name.get(type));
[37428] Fix | Delete
descriptor.set("FontBBox", bbox);
[37429] Fix | Delete
} else {
[37430] Fix | Delete
let baseFontName = dict.get("BaseFont");
[37431] Fix | Delete
if (!(baseFontName instanceof Name)) {
[37432] Fix | Delete
throw new FormatError("Base font is not specified");
[37433] Fix | Delete
}
[37434] Fix | Delete
baseFontName = baseFontName.name.replaceAll(/[,_]/g, "-");
[37435] Fix | Delete
const metrics = this.getBaseFontMetrics(baseFontName);
[37436] Fix | Delete
const fontNameWoStyle = baseFontName.split("-", 1)[0];
[37437] Fix | Delete
const flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
[37438] Fix | Delete
const properties = {
[37439] Fix | Delete
type,
[37440] Fix | Delete
name: baseFontName,
[37441] Fix | Delete
loadedName: baseDict.loadedName,
[37442] Fix | Delete
systemFontInfo: null,
[37443] Fix | Delete
widths: metrics.widths,
[37444] Fix | Delete
defaultWidth: metrics.defaultWidth,
[37445] Fix | Delete
isSimulatedFlags: true,
[37446] Fix | Delete
flags,
[37447] Fix | Delete
firstChar,
[37448] Fix | Delete
lastChar,
[37449] Fix | Delete
toUnicode,
[37450] Fix | Delete
xHeight: 0,
[37451] Fix | Delete
capHeight: 0,
[37452] Fix | Delete
italicAngle: 0,
[37453] Fix | Delete
isType3Font
[37454] Fix | Delete
};
[37455] Fix | Delete
const widths = dict.get("Widths");
[37456] Fix | Delete
const standardFontName = getStandardFontName(baseFontName);
[37457] Fix | Delete
let file = null;
[37458] Fix | Delete
if (standardFontName) {
[37459] Fix | Delete
file = await this.fetchStandardFontData(standardFontName);
[37460] Fix | Delete
properties.isInternalFont = !!file;
[37461] Fix | Delete
}
[37462] Fix | Delete
if (!properties.isInternalFont && this.options.useSystemFonts) {
[37463] Fix | Delete
properties.systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName, type);
[37464] Fix | Delete
}
[37465] Fix | Delete
const newProperties = await this.extractDataStructures(dict, properties);
[37466] Fix | Delete
if (Array.isArray(widths)) {
[37467] Fix | Delete
const glyphWidths = [];
[37468] Fix | Delete
let j = firstChar;
[37469] Fix | Delete
for (const w of widths) {
[37470] Fix | Delete
const width = this.xref.fetchIfRef(w);
[37471] Fix | Delete
if (typeof width === "number") {
[37472] Fix | Delete
glyphWidths[j] = width;
[37473] Fix | Delete
}
[37474] Fix | Delete
j++;
[37475] Fix | Delete
}
[37476] Fix | Delete
newProperties.widths = glyphWidths;
[37477] Fix | Delete
} else {
[37478] Fix | Delete
newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
[37479] Fix | Delete
}
[37480] Fix | Delete
return new Font(baseFontName, file, newProperties);
[37481] Fix | Delete
}
[37482] Fix | Delete
}
[37483] Fix | Delete
let fontName = descriptor.get("FontName");
[37484] Fix | Delete
let baseFont = dict.get("BaseFont");
[37485] Fix | Delete
if (typeof fontName === "string") {
[37486] Fix | Delete
fontName = Name.get(fontName);
[37487] Fix | Delete
}
[37488] Fix | Delete
if (typeof baseFont === "string") {
[37489] Fix | Delete
baseFont = Name.get(baseFont);
[37490] Fix | Delete
}
[37491] Fix | Delete
const fontNameStr = fontName?.name;
[37492] Fix | Delete
const baseFontStr = baseFont?.name;
[37493] Fix | Delete
if (!isType3Font && fontNameStr !== baseFontStr) {
[37494] Fix | Delete
info(`The FontDescriptor's FontName is "${fontNameStr}" but ` + `should be the same as the Font's BaseFont "${baseFontStr}".`);
[37495] Fix | Delete
if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr))) {
[37496] Fix | Delete
fontName = null;
[37497] Fix | Delete
}
[37498] Fix | Delete
}
[37499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function