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
}
[29000] Fix | Delete
foldTTTable(table, content);
[29001] Fix | Delete
}
[29002] Fix | Delete
function checkInvalidFunctions(ttContext, maxFunctionDefs) {
[29003] Fix | Delete
if (ttContext.tooComplexToFollowFunctions) {
[29004] Fix | Delete
return;
[29005] Fix | Delete
}
[29006] Fix | Delete
if (ttContext.functionsDefined.length > maxFunctionDefs) {
[29007] Fix | Delete
warn("TT: more functions defined than expected");
[29008] Fix | Delete
ttContext.hintsValid = false;
[29009] Fix | Delete
return;
[29010] Fix | Delete
}
[29011] Fix | Delete
for (let j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
[29012] Fix | Delete
if (j > maxFunctionDefs) {
[29013] Fix | Delete
warn("TT: invalid function id: " + j);
[29014] Fix | Delete
ttContext.hintsValid = false;
[29015] Fix | Delete
return;
[29016] Fix | Delete
}
[29017] Fix | Delete
if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
[29018] Fix | Delete
warn("TT: undefined function: " + j);
[29019] Fix | Delete
ttContext.hintsValid = false;
[29020] Fix | Delete
return;
[29021] Fix | Delete
}
[29022] Fix | Delete
}
[29023] Fix | Delete
}
[29024] Fix | Delete
function foldTTTable(table, content) {
[29025] Fix | Delete
if (content.length > 1) {
[29026] Fix | Delete
let newLength = 0;
[29027] Fix | Delete
let j, jj;
[29028] Fix | Delete
for (j = 0, jj = content.length; j < jj; j++) {
[29029] Fix | Delete
newLength += content[j].length;
[29030] Fix | Delete
}
[29031] Fix | Delete
newLength = newLength + 3 & ~3;
[29032] Fix | Delete
const result = new Uint8Array(newLength);
[29033] Fix | Delete
let pos = 0;
[29034] Fix | Delete
for (j = 0, jj = content.length; j < jj; j++) {
[29035] Fix | Delete
result.set(content[j], pos);
[29036] Fix | Delete
pos += content[j].length;
[29037] Fix | Delete
}
[29038] Fix | Delete
table.data = result;
[29039] Fix | Delete
table.length = newLength;
[29040] Fix | Delete
}
[29041] Fix | Delete
}
[29042] Fix | Delete
function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
[29043] Fix | Delete
const ttContext = {
[29044] Fix | Delete
functionsDefined: [],
[29045] Fix | Delete
functionsUsed: [],
[29046] Fix | Delete
functionsStackDeltas: [],
[29047] Fix | Delete
tooComplexToFollowFunctions: false,
[29048] Fix | Delete
hintsValid: true
[29049] Fix | Delete
};
[29050] Fix | Delete
if (fpgm) {
[29051] Fix | Delete
sanitizeTTProgram(fpgm, ttContext);
[29052] Fix | Delete
}
[29053] Fix | Delete
if (prep) {
[29054] Fix | Delete
sanitizeTTProgram(prep, ttContext);
[29055] Fix | Delete
}
[29056] Fix | Delete
if (fpgm) {
[29057] Fix | Delete
checkInvalidFunctions(ttContext, maxFunctionDefs);
[29058] Fix | Delete
}
[29059] Fix | Delete
if (cvt && cvt.length & 1) {
[29060] Fix | Delete
const cvtData = new Uint8Array(cvt.length + 1);
[29061] Fix | Delete
cvtData.set(cvt.data);
[29062] Fix | Delete
cvt.data = cvtData;
[29063] Fix | Delete
}
[29064] Fix | Delete
return ttContext.hintsValid;
[29065] Fix | Delete
}
[29066] Fix | Delete
font = new Stream(new Uint8Array(font.getBytes()));
[29067] Fix | Delete
let header, tables;
[29068] Fix | Delete
if (isTrueTypeCollectionFile(font)) {
[29069] Fix | Delete
const ttcData = readTrueTypeCollectionData(font, this.name);
[29070] Fix | Delete
header = ttcData.header;
[29071] Fix | Delete
tables = ttcData.tables;
[29072] Fix | Delete
} else {
[29073] Fix | Delete
header = readOpenTypeHeader(font);
[29074] Fix | Delete
tables = readTables(font, header.numTables);
[29075] Fix | Delete
}
[29076] Fix | Delete
let cff, cffFile;
[29077] Fix | Delete
const isTrueType = !tables["CFF "];
[29078] Fix | Delete
if (!isTrueType) {
[29079] Fix | Delete
const isComposite = properties.composite && (properties.cidToGidMap?.length > 0 || !(properties.cMap instanceof IdentityCMap));
[29080] Fix | Delete
if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
[29081] Fix | Delete
cffFile = new Stream(tables["CFF "].data);
[29082] Fix | Delete
cff = new CFFFont(cffFile, properties);
[29083] Fix | Delete
adjustWidths(properties);
[29084] Fix | Delete
return this.convert(name, cff, properties);
[29085] Fix | Delete
}
[29086] Fix | Delete
delete tables.glyf;
[29087] Fix | Delete
delete tables.loca;
[29088] Fix | Delete
delete tables.fpgm;
[29089] Fix | Delete
delete tables.prep;
[29090] Fix | Delete
delete tables["cvt "];
[29091] Fix | Delete
this.isOpenType = true;
[29092] Fix | Delete
} else {
[29093] Fix | Delete
if (!tables.loca) {
[29094] Fix | Delete
throw new FormatError('Required "loca" table is not found');
[29095] Fix | Delete
}
[29096] Fix | Delete
if (!tables.glyf) {
[29097] Fix | Delete
warn('Required "glyf" table is not found -- trying to recover.');
[29098] Fix | Delete
tables.glyf = {
[29099] Fix | Delete
tag: "glyf",
[29100] Fix | Delete
data: new Uint8Array(0)
[29101] Fix | Delete
};
[29102] Fix | Delete
}
[29103] Fix | Delete
this.isOpenType = false;
[29104] Fix | Delete
}
[29105] Fix | Delete
if (!tables.maxp) {
[29106] Fix | Delete
throw new FormatError('Required "maxp" table is not found');
[29107] Fix | Delete
}
[29108] Fix | Delete
font.pos = (font.start || 0) + tables.maxp.offset;
[29109] Fix | Delete
let version = font.getInt32();
[29110] Fix | Delete
const numGlyphs = font.getUint16();
[29111] Fix | Delete
if (version !== 0x00010000 && version !== 0x00005000) {
[29112] Fix | Delete
if (tables.maxp.length === 6) {
[29113] Fix | Delete
version = 0x0005000;
[29114] Fix | Delete
} else if (tables.maxp.length >= 32) {
[29115] Fix | Delete
version = 0x00010000;
[29116] Fix | Delete
} else {
[29117] Fix | Delete
throw new FormatError(`"maxp" table has a wrong version number`);
[29118] Fix | Delete
}
[29119] Fix | Delete
writeUint32(tables.maxp.data, 0, version);
[29120] Fix | Delete
}
[29121] Fix | Delete
if (properties.scaleFactors?.length === numGlyphs && isTrueType) {
[29122] Fix | Delete
const {
[29123] Fix | Delete
scaleFactors
[29124] Fix | Delete
} = properties;
[29125] Fix | Delete
const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
[29126] Fix | Delete
const glyphs = new GlyfTable({
[29127] Fix | Delete
glyfTable: tables.glyf.data,
[29128] Fix | Delete
isGlyphLocationsLong,
[29129] Fix | Delete
locaTable: tables.loca.data,
[29130] Fix | Delete
numGlyphs
[29131] Fix | Delete
});
[29132] Fix | Delete
glyphs.scale(scaleFactors);
[29133] Fix | Delete
const {
[29134] Fix | Delete
glyf,
[29135] Fix | Delete
loca,
[29136] Fix | Delete
isLocationLong
[29137] Fix | Delete
} = glyphs.write();
[29138] Fix | Delete
tables.glyf.data = glyf;
[29139] Fix | Delete
tables.loca.data = loca;
[29140] Fix | Delete
if (isLocationLong !== !!isGlyphLocationsLong) {
[29141] Fix | Delete
tables.head.data[50] = 0;
[29142] Fix | Delete
tables.head.data[51] = isLocationLong ? 1 : 0;
[29143] Fix | Delete
}
[29144] Fix | Delete
const metrics = tables.hmtx.data;
[29145] Fix | Delete
for (let i = 0; i < numGlyphs; i++) {
[29146] Fix | Delete
const j = 4 * i;
[29147] Fix | Delete
const advanceWidth = Math.round(scaleFactors[i] * int16(metrics[j], metrics[j + 1]));
[29148] Fix | Delete
metrics[j] = advanceWidth >> 8 & 0xff;
[29149] Fix | Delete
metrics[j + 1] = advanceWidth & 0xff;
[29150] Fix | Delete
const lsb = Math.round(scaleFactors[i] * signedInt16(metrics[j + 2], metrics[j + 3]));
[29151] Fix | Delete
writeSignedInt16(metrics, j + 2, lsb);
[29152] Fix | Delete
}
[29153] Fix | Delete
}
[29154] Fix | Delete
let numGlyphsOut = numGlyphs + 1;
[29155] Fix | Delete
let dupFirstEntry = true;
[29156] Fix | Delete
if (numGlyphsOut > 0xffff) {
[29157] Fix | Delete
dupFirstEntry = false;
[29158] Fix | Delete
numGlyphsOut = numGlyphs;
[29159] Fix | Delete
warn("Not enough space in glyfs to duplicate first glyph.");
[29160] Fix | Delete
}
[29161] Fix | Delete
let maxFunctionDefs = 0;
[29162] Fix | Delete
let maxSizeOfInstructions = 0;
[29163] Fix | Delete
if (version >= 0x00010000 && tables.maxp.length >= 32) {
[29164] Fix | Delete
font.pos += 8;
[29165] Fix | Delete
const maxZones = font.getUint16();
[29166] Fix | Delete
if (maxZones > 2) {
[29167] Fix | Delete
tables.maxp.data[14] = 0;
[29168] Fix | Delete
tables.maxp.data[15] = 2;
[29169] Fix | Delete
}
[29170] Fix | Delete
font.pos += 4;
[29171] Fix | Delete
maxFunctionDefs = font.getUint16();
[29172] Fix | Delete
font.pos += 4;
[29173] Fix | Delete
maxSizeOfInstructions = font.getUint16();
[29174] Fix | Delete
}
[29175] Fix | Delete
tables.maxp.data[4] = numGlyphsOut >> 8;
[29176] Fix | Delete
tables.maxp.data[5] = numGlyphsOut & 255;
[29177] Fix | Delete
const hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
[29178] Fix | Delete
if (!hintsValid) {
[29179] Fix | Delete
delete tables.fpgm;
[29180] Fix | Delete
delete tables.prep;
[29181] Fix | Delete
delete tables["cvt "];
[29182] Fix | Delete
}
[29183] Fix | Delete
sanitizeMetrics(font, tables.hhea, tables.hmtx, tables.head, numGlyphsOut, dupFirstEntry);
[29184] Fix | Delete
if (!tables.head) {
[29185] Fix | Delete
throw new FormatError('Required "head" table is not found');
[29186] Fix | Delete
}
[29187] Fix | Delete
sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
[29188] Fix | Delete
let missingGlyphs = Object.create(null);
[29189] Fix | Delete
if (isTrueType) {
[29190] Fix | Delete
const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
[29191] Fix | Delete
const glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
[29192] Fix | Delete
missingGlyphs = glyphsInfo.missingGlyphs;
[29193] Fix | Delete
if (version >= 0x00010000 && tables.maxp.length >= 32) {
[29194] Fix | Delete
tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
[29195] Fix | Delete
tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
[29196] Fix | Delete
}
[29197] Fix | Delete
}
[29198] Fix | Delete
if (!tables.hhea) {
[29199] Fix | Delete
throw new FormatError('Required "hhea" table is not found');
[29200] Fix | Delete
}
[29201] Fix | Delete
if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
[29202] Fix | Delete
tables.hhea.data[10] = 0xff;
[29203] Fix | Delete
tables.hhea.data[11] = 0xff;
[29204] Fix | Delete
}
[29205] Fix | Delete
const metricsOverride = {
[29206] Fix | Delete
unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
[29207] Fix | Delete
yMax: signedInt16(tables.head.data[42], tables.head.data[43]),
[29208] Fix | Delete
yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
[29209] Fix | Delete
ascent: signedInt16(tables.hhea.data[4], tables.hhea.data[5]),
[29210] Fix | Delete
descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7]),
[29211] Fix | Delete
lineGap: signedInt16(tables.hhea.data[8], tables.hhea.data[9])
[29212] Fix | Delete
};
[29213] Fix | Delete
this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
[29214] Fix | Delete
this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
[29215] Fix | Delete
this.lineGap = metricsOverride.lineGap / metricsOverride.unitsPerEm;
[29216] Fix | Delete
if (this.cssFontInfo?.lineHeight) {
[29217] Fix | Delete
this.lineHeight = this.cssFontInfo.metrics.lineHeight;
[29218] Fix | Delete
this.lineGap = this.cssFontInfo.metrics.lineGap;
[29219] Fix | Delete
} else {
[29220] Fix | Delete
this.lineHeight = this.ascent - this.descent + this.lineGap;
[29221] Fix | Delete
}
[29222] Fix | Delete
if (tables.post) {
[29223] Fix | Delete
readPostScriptTable(tables.post, properties, numGlyphs);
[29224] Fix | Delete
}
[29225] Fix | Delete
tables.post = {
[29226] Fix | Delete
tag: "post",
[29227] Fix | Delete
data: createPostTable(properties)
[29228] Fix | Delete
};
[29229] Fix | Delete
const charCodeToGlyphId = Object.create(null);
[29230] Fix | Delete
function hasGlyph(glyphId) {
[29231] Fix | Delete
return !missingGlyphs[glyphId];
[29232] Fix | Delete
}
[29233] Fix | Delete
if (properties.composite) {
[29234] Fix | Delete
const cidToGidMap = properties.cidToGidMap || [];
[29235] Fix | Delete
const isCidToGidMapEmpty = cidToGidMap.length === 0;
[29236] Fix | Delete
properties.cMap.forEach(function (charCode, cid) {
[29237] Fix | Delete
if (typeof cid === "string") {
[29238] Fix | Delete
cid = convertCidString(charCode, cid, true);
[29239] Fix | Delete
}
[29240] Fix | Delete
if (cid > 0xffff) {
[29241] Fix | Delete
throw new FormatError("Max size of CID is 65,535");
[29242] Fix | Delete
}
[29243] Fix | Delete
let glyphId = -1;
[29244] Fix | Delete
if (isCidToGidMapEmpty) {
[29245] Fix | Delete
glyphId = cid;
[29246] Fix | Delete
} else if (cidToGidMap[cid] !== undefined) {
[29247] Fix | Delete
glyphId = cidToGidMap[cid];
[29248] Fix | Delete
}
[29249] Fix | Delete
if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
[29250] Fix | Delete
charCodeToGlyphId[charCode] = glyphId;
[29251] Fix | Delete
}
[29252] Fix | Delete
});
[29253] Fix | Delete
} else {
[29254] Fix | Delete
const cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
[29255] Fix | Delete
const cmapPlatformId = cmapTable.platformId;
[29256] Fix | Delete
const cmapEncodingId = cmapTable.encodingId;
[29257] Fix | Delete
const cmapMappings = cmapTable.mappings;
[29258] Fix | Delete
let baseEncoding = [],
[29259] Fix | Delete
forcePostTable = false;
[29260] Fix | Delete
if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
[29261] Fix | Delete
baseEncoding = getEncoding(properties.baseEncodingName);
[29262] Fix | Delete
}
[29263] Fix | Delete
if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
[29264] Fix | Delete
const glyphsUnicodeMap = getGlyphsUnicode();
[29265] Fix | Delete
for (let charCode = 0; charCode < 256; charCode++) {
[29266] Fix | Delete
let glyphName;
[29267] Fix | Delete
if (this.differences[charCode] !== undefined) {
[29268] Fix | Delete
glyphName = this.differences[charCode];
[29269] Fix | Delete
} else if (baseEncoding.length && baseEncoding[charCode] !== "") {
[29270] Fix | Delete
glyphName = baseEncoding[charCode];
[29271] Fix | Delete
} else {
[29272] Fix | Delete
glyphName = StandardEncoding[charCode];
[29273] Fix | Delete
}
[29274] Fix | Delete
if (!glyphName) {
[29275] Fix | Delete
continue;
[29276] Fix | Delete
}
[29277] Fix | Delete
const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
[29278] Fix | Delete
let unicodeOrCharCode;
[29279] Fix | Delete
if (cmapPlatformId === 3 && cmapEncodingId === 1) {
[29280] Fix | Delete
unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
[29281] Fix | Delete
} else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
[29282] Fix | Delete
unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
[29283] Fix | Delete
}
[29284] Fix | Delete
if (unicodeOrCharCode === undefined) {
[29285] Fix | Delete
if (!properties.glyphNames && properties.hasIncludedToUnicodeMap && !(this.toUnicode instanceof IdentityToUnicodeMap)) {
[29286] Fix | Delete
const unicode = this.toUnicode.get(charCode);
[29287] Fix | Delete
if (unicode) {
[29288] Fix | Delete
unicodeOrCharCode = unicode.codePointAt(0);
[29289] Fix | Delete
}
[29290] Fix | Delete
}
[29291] Fix | Delete
if (unicodeOrCharCode === undefined) {
[29292] Fix | Delete
continue;
[29293] Fix | Delete
}
[29294] Fix | Delete
}
[29295] Fix | Delete
for (const mapping of cmapMappings) {
[29296] Fix | Delete
if (mapping.charCode !== unicodeOrCharCode) {
[29297] Fix | Delete
continue;
[29298] Fix | Delete
}
[29299] Fix | Delete
charCodeToGlyphId[charCode] = mapping.glyphId;
[29300] Fix | Delete
break;
[29301] Fix | Delete
}
[29302] Fix | Delete
}
[29303] Fix | Delete
} else if (cmapPlatformId === 0) {
[29304] Fix | Delete
for (const mapping of cmapMappings) {
[29305] Fix | Delete
charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
[29306] Fix | Delete
}
[29307] Fix | Delete
forcePostTable = true;
[29308] Fix | Delete
} else if (cmapPlatformId === 3 && cmapEncodingId === 0) {
[29309] Fix | Delete
for (const mapping of cmapMappings) {
[29310] Fix | Delete
let charCode = mapping.charCode;
[29311] Fix | Delete
if (charCode >= 0xf000 && charCode <= 0xf0ff) {
[29312] Fix | Delete
charCode &= 0xff;
[29313] Fix | Delete
}
[29314] Fix | Delete
charCodeToGlyphId[charCode] = mapping.glyphId;
[29315] Fix | Delete
}
[29316] Fix | Delete
} else {
[29317] Fix | Delete
for (const mapping of cmapMappings) {
[29318] Fix | Delete
charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
[29319] Fix | Delete
}
[29320] Fix | Delete
}
[29321] Fix | Delete
if (properties.glyphNames && (baseEncoding.length || this.differences.length)) {
[29322] Fix | Delete
for (let i = 0; i < 256; ++i) {
[29323] Fix | Delete
if (!forcePostTable && charCodeToGlyphId[i] !== undefined) {
[29324] Fix | Delete
continue;
[29325] Fix | Delete
}
[29326] Fix | Delete
const glyphName = this.differences[i] || baseEncoding[i];
[29327] Fix | Delete
if (!glyphName) {
[29328] Fix | Delete
continue;
[29329] Fix | Delete
}
[29330] Fix | Delete
const glyphId = properties.glyphNames.indexOf(glyphName);
[29331] Fix | Delete
if (glyphId > 0 && hasGlyph(glyphId)) {
[29332] Fix | Delete
charCodeToGlyphId[i] = glyphId;
[29333] Fix | Delete
}
[29334] Fix | Delete
}
[29335] Fix | Delete
}
[29336] Fix | Delete
}
[29337] Fix | Delete
if (charCodeToGlyphId.length === 0) {
[29338] Fix | Delete
charCodeToGlyphId[0] = 0;
[29339] Fix | Delete
}
[29340] Fix | Delete
let glyphZeroId = numGlyphsOut - 1;
[29341] Fix | Delete
if (!dupFirstEntry) {
[29342] Fix | Delete
glyphZeroId = 0;
[29343] Fix | Delete
}
[29344] Fix | Delete
if (!properties.cssFontInfo) {
[29345] Fix | Delete
const newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId, this.toUnicode);
[29346] Fix | Delete
this.toFontChar = newMapping.toFontChar;
[29347] Fix | Delete
tables.cmap = {
[29348] Fix | Delete
tag: "cmap",
[29349] Fix | Delete
data: createCmapTable(newMapping.charCodeToGlyphId, newMapping.toUnicodeExtraMap, numGlyphsOut)
[29350] Fix | Delete
};
[29351] Fix | Delete
if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
[29352] Fix | Delete
tables["OS/2"] = {
[29353] Fix | Delete
tag: "OS/2",
[29354] Fix | Delete
data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
[29355] Fix | Delete
};
[29356] Fix | Delete
}
[29357] Fix | Delete
}
[29358] Fix | Delete
if (!isTrueType) {
[29359] Fix | Delete
try {
[29360] Fix | Delete
cffFile = new Stream(tables["CFF "].data);
[29361] Fix | Delete
const parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
[29362] Fix | Delete
cff = parser.parse();
[29363] Fix | Delete
cff.duplicateFirstGlyph();
[29364] Fix | Delete
const compiler = new CFFCompiler(cff);
[29365] Fix | Delete
tables["CFF "].data = compiler.compile();
[29366] Fix | Delete
} catch {
[29367] Fix | Delete
warn("Failed to compile font " + properties.loadedName);
[29368] Fix | Delete
}
[29369] Fix | Delete
}
[29370] Fix | Delete
if (!tables.name) {
[29371] Fix | Delete
tables.name = {
[29372] Fix | Delete
tag: "name",
[29373] Fix | Delete
data: createNameTable(this.name)
[29374] Fix | Delete
};
[29375] Fix | Delete
} else {
[29376] Fix | Delete
const [namePrototype, nameRecords] = readNameTable(tables.name);
[29377] Fix | Delete
tables.name.data = createNameTable(name, namePrototype);
[29378] Fix | Delete
this.psName = namePrototype[0][6] || null;
[29379] Fix | Delete
if (!properties.composite) {
[29380] Fix | Delete
adjustTrueTypeToUnicode(properties, this.isSymbolicFont, nameRecords);
[29381] Fix | Delete
}
[29382] Fix | Delete
}
[29383] Fix | Delete
const builder = new OpenTypeFileBuilder(header.version);
[29384] Fix | Delete
for (const tableTag in tables) {
[29385] Fix | Delete
builder.addTable(tableTag, tables[tableTag].data);
[29386] Fix | Delete
}
[29387] Fix | Delete
return builder.toArray();
[29388] Fix | Delete
}
[29389] Fix | Delete
convert(fontName, font, properties) {
[29390] Fix | Delete
properties.fixedPitch = false;
[29391] Fix | Delete
if (properties.builtInEncoding) {
[29392] Fix | Delete
adjustType1ToUnicode(properties, properties.builtInEncoding);
[29393] Fix | Delete
}
[29394] Fix | Delete
let glyphZeroId = 1;
[29395] Fix | Delete
if (font instanceof CFFFont) {
[29396] Fix | Delete
glyphZeroId = font.numGlyphs - 1;
[29397] Fix | Delete
}
[29398] Fix | Delete
const mapping = font.getGlyphMapping(properties);
[29399] Fix | Delete
let newMapping = null;
[29400] Fix | Delete
let newCharCodeToGlyphId = mapping;
[29401] Fix | Delete
let toUnicodeExtraMap = null;
[29402] Fix | Delete
if (!properties.cssFontInfo) {
[29403] Fix | Delete
newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId, this.toUnicode);
[29404] Fix | Delete
this.toFontChar = newMapping.toFontChar;
[29405] Fix | Delete
newCharCodeToGlyphId = newMapping.charCodeToGlyphId;
[29406] Fix | Delete
toUnicodeExtraMap = newMapping.toUnicodeExtraMap;
[29407] Fix | Delete
}
[29408] Fix | Delete
const numGlyphs = font.numGlyphs;
[29409] Fix | Delete
function getCharCodes(charCodeToGlyphId, glyphId) {
[29410] Fix | Delete
let charCodes = null;
[29411] Fix | Delete
for (const charCode in charCodeToGlyphId) {
[29412] Fix | Delete
if (glyphId === charCodeToGlyphId[charCode]) {
[29413] Fix | Delete
(charCodes ||= []).push(charCode | 0);
[29414] Fix | Delete
}
[29415] Fix | Delete
}
[29416] Fix | Delete
return charCodes;
[29417] Fix | Delete
}
[29418] Fix | Delete
function createCharCode(charCodeToGlyphId, glyphId) {
[29419] Fix | Delete
for (const charCode in charCodeToGlyphId) {
[29420] Fix | Delete
if (glyphId === charCodeToGlyphId[charCode]) {
[29421] Fix | Delete
return charCode | 0;
[29422] Fix | Delete
}
[29423] Fix | Delete
}
[29424] Fix | Delete
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
[29425] Fix | Delete
return newMapping.nextAvailableFontCharCode++;
[29426] Fix | Delete
}
[29427] Fix | Delete
const seacs = font.seacs;
[29428] Fix | Delete
if (newMapping && SEAC_ANALYSIS_ENABLED && seacs?.length) {
[29429] Fix | Delete
const matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
[29430] Fix | Delete
const charset = font.getCharset();
[29431] Fix | Delete
const seacMap = Object.create(null);
[29432] Fix | Delete
for (let glyphId in seacs) {
[29433] Fix | Delete
glyphId |= 0;
[29434] Fix | Delete
const seac = seacs[glyphId];
[29435] Fix | Delete
const baseGlyphName = StandardEncoding[seac[2]];
[29436] Fix | Delete
const accentGlyphName = StandardEncoding[seac[3]];
[29437] Fix | Delete
const baseGlyphId = charset.indexOf(baseGlyphName);
[29438] Fix | Delete
const accentGlyphId = charset.indexOf(accentGlyphName);
[29439] Fix | Delete
if (baseGlyphId < 0 || accentGlyphId < 0) {
[29440] Fix | Delete
continue;
[29441] Fix | Delete
}
[29442] Fix | Delete
const accentOffset = {
[29443] Fix | Delete
x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
[29444] Fix | Delete
y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
[29445] Fix | Delete
};
[29446] Fix | Delete
const charCodes = getCharCodes(mapping, glyphId);
[29447] Fix | Delete
if (!charCodes) {
[29448] Fix | Delete
continue;
[29449] Fix | Delete
}
[29450] Fix | Delete
for (const charCode of charCodes) {
[29451] Fix | Delete
const charCodeToGlyphId = newMapping.charCodeToGlyphId;
[29452] Fix | Delete
const baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
[29453] Fix | Delete
const accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
[29454] Fix | Delete
seacMap[charCode] = {
[29455] Fix | Delete
baseFontCharCode,
[29456] Fix | Delete
accentFontCharCode,
[29457] Fix | Delete
accentOffset
[29458] Fix | Delete
};
[29459] Fix | Delete
}
[29460] Fix | Delete
}
[29461] Fix | Delete
properties.seacMap = seacMap;
[29462] Fix | Delete
}
[29463] Fix | Delete
const unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
[29464] Fix | Delete
const builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
[29465] Fix | Delete
builder.addTable("CFF ", font.data);
[29466] Fix | Delete
builder.addTable("OS/2", createOS2Table(properties, newCharCodeToGlyphId));
[29467] Fix | Delete
builder.addTable("cmap", createCmapTable(newCharCodeToGlyphId, toUnicodeExtraMap, numGlyphs));
[29468] Fix | Delete
builder.addTable("head", "\x00\x01\x00\x00" + "\x00\x00\x10\x00" + "\x00\x00\x00\x00" + "\x5F\x0F\x3C\xF5" + "\x00\x00" + safeString16(unitsPerEm) + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00" + safeString16(properties.descent) + "\x0F\xFF" + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + "\x00\x11" + "\x00\x00" + "\x00\x00" + "\x00\x00");
[29469] Fix | Delete
builder.addTable("hhea", "\x00\x01\x00\x00" + safeString16(properties.ascent) + safeString16(properties.descent) + "\x00\x00" + "\xFF\xFF" + "\x00\x00" + "\x00\x00" + "\x00\x00" + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + string16(numGlyphs));
[29470] Fix | Delete
builder.addTable("hmtx", function fontFieldsHmtx() {
[29471] Fix | Delete
const charstrings = font.charstrings;
[29472] Fix | Delete
const cffWidths = font.cff ? font.cff.widths : null;
[29473] Fix | Delete
let hmtx = "\x00\x00\x00\x00";
[29474] Fix | Delete
for (let i = 1, ii = numGlyphs; i < ii; i++) {
[29475] Fix | Delete
let width = 0;
[29476] Fix | Delete
if (charstrings) {
[29477] Fix | Delete
const charstring = charstrings[i - 1];
[29478] Fix | Delete
width = "width" in charstring ? charstring.width : 0;
[29479] Fix | Delete
} else if (cffWidths) {
[29480] Fix | Delete
width = Math.ceil(cffWidths[i] || 0);
[29481] Fix | Delete
}
[29482] Fix | Delete
hmtx += string16(width) + string16(0);
[29483] Fix | Delete
}
[29484] Fix | Delete
return hmtx;
[29485] Fix | Delete
}());
[29486] Fix | Delete
builder.addTable("maxp", "\x00\x00\x50\x00" + string16(numGlyphs));
[29487] Fix | Delete
builder.addTable("name", createNameTable(fontName));
[29488] Fix | Delete
builder.addTable("post", createPostTable(properties));
[29489] Fix | Delete
return builder.toArray();
[29490] Fix | Delete
}
[29491] Fix | Delete
_charToGlyph(charcode, isSpace = false) {
[29492] Fix | Delete
let glyph = this._glyphCache[charcode];
[29493] Fix | Delete
if (glyph?.isSpace === isSpace) {
[29494] Fix | Delete
return glyph;
[29495] Fix | Delete
}
[29496] Fix | Delete
let fontCharCode, width, operatorListId;
[29497] Fix | Delete
let widthCode = charcode;
[29498] Fix | Delete
if (this.cMap?.contains(charcode)) {
[29499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function