: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (flag & Y_SHORT_VECTOR) {
const y = glyf.getUint8(pos++);
lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
yCoordinates.push(lastCoordinate);
} else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
yCoordinates.push(lastCoordinate);
lastCoordinate += glyf.getInt16(pos);
yCoordinates.push(lastCoordinate);
pointFlags.push(flag & ON_CURVE_POINT | flag & OVERLAP_SIMPLE);
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
xCoordinates = allXCoordinates[endPtsOfContoursIndex];
contours.push(new Contour({
let size = this.contours.length * 2 + 2 + this.instructions.length;
for (const contour of this.contours) {
size += contour.flags.length;
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
const x = contour.xCoordinates[i];
const y = contour.yCoordinates[i];
let abs = Math.abs(x - lastX);
abs = Math.abs(y - lastY);
for (const contour of this.contours) {
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
let flag = contour.flags[i];
const x = contour.xCoordinates[i];
flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
const abs = Math.abs(delta);
flag |= delta >= 0 ? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR : X_SHORT_VECTOR;
xCoordinates.push(delta);
const y = contour.yCoordinates[i];
flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
const abs = Math.abs(delta);
flag |= delta >= 0 ? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR : Y_SHORT_VECTOR;
yCoordinates.push(delta);
buf.setUint16(pos, xCoordinates.length - 1);
buf.setUint16(pos, this.instructions.length);
if (this.instructions.length) {
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
pos += this.instructions.length;
for (const flag of flags) {
buf.setUint8(pos++, flag);
for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
const x = xCoordinates[i];
if (flag & X_SHORT_VECTOR) {
} else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
const y = yCoordinates[i];
if (flag & Y_SHORT_VECTOR) {
} else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
for (const contour of this.contours) {
if (contour.xCoordinates.length === 0) {
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
contour.xCoordinates[i] = Math.round(x + (contour.xCoordinates[i] - x) * factor);
this.glyphIndex = glyphIndex;
this.argument1 = argument1;
this.argument2 = argument2;
this.instructions = instructions;
static parse(pos, glyf) {
let flags = glyf.getUint16(pos);
const glyphIndex = glyf.getUint16(pos + 2);
let argument1, argument2;
if (flags & ARG_1_AND_2_ARE_WORDS) {
if (flags & ARGS_ARE_XY_VALUES) {
argument1 = glyf.getInt16(pos);
argument2 = glyf.getInt16(pos + 2);
argument1 = glyf.getUint16(pos);
argument2 = glyf.getUint16(pos + 2);
flags ^= ARG_1_AND_2_ARE_WORDS;
if (flags & ARGS_ARE_XY_VALUES) {
argument1 = glyf.getInt8(pos);
argument2 = glyf.getInt8(pos + 1);
argument1 = glyf.getUint8(pos);
argument2 = glyf.getUint8(pos + 1);
if (flags & WE_HAVE_A_SCALE) {
transf.push(glyf.getUint16(pos));
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2), glyf.getUint16(pos + 4), glyf.getUint16(pos + 6));
if (flags & WE_HAVE_INSTRUCTIONS) {
const instructionLength = glyf.getUint16(pos);
instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
pos += instructionLength;
return [pos - spos, new CompositeGlyph({
let size = 2 + 2 + this.transf.length * 2;
if (this.flags & WE_HAVE_INSTRUCTIONS) {
size += 2 + this.instructions.length;
if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
} else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
if (this.flags & ARGS_ARE_XY_VALUES) {
if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
} else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
buf.setUint16(pos, this.flags);
buf.setUint16(pos + 2, this.glyphIndex);
if (this.flags & ARG_1_AND_2_ARE_WORDS) {
if (this.flags & ARGS_ARE_XY_VALUES) {
buf.setInt16(pos, this.argument1);
buf.setInt16(pos + 2, this.argument2);
buf.setUint16(pos, this.argument1);
buf.setUint16(pos + 2, this.argument2);
buf.setUint8(pos, this.argument1);
buf.setUint8(pos + 1, this.argument2);
if (this.flags & WE_HAVE_INSTRUCTIONS) {
buf.setUint16(pos, this.instructions.length);
if (this.instructions.length) {
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
pos += this.instructions.length;
;// CONCATENATED MODULE: ./src/core/opentype_file_builder.js
function writeInt16(dest, offset, num) {
dest[offset] = num >> 8 & 0xff;
dest[offset + 1] = num & 0xff;
function writeInt32(dest, offset, num) {
dest[offset] = num >> 24 & 0xff;
dest[offset + 1] = num >> 16 & 0xff;
dest[offset + 2] = num >> 8 & 0xff;
dest[offset + 3] = num & 0xff;
function writeData(dest, offset, data) {
if (data instanceof Uint8Array) {
} else if (typeof data === "string") {
for (let i = 0, ii = data.length; i < ii; i++) {
dest[offset++] = data.charCodeAt(i) & 0xff;
for (const num of data) {
dest[offset++] = num & 0xff;
const OTF_HEADER_SIZE = 12;
const OTF_TABLE_ENTRY_SIZE = 16;
class OpenTypeFileBuilder {
this.tables = Object.create(null);
static getSearchParams(entriesCount, entrySize) {
while ((maxPower2 ^ entriesCount) > maxPower2) {
const searchRange = maxPower2 * entrySize;
rangeShift: entrySize * entriesCount - searchRange
const tables = this.tables;
const tablesNames = Object.keys(tables);
const numTables = tablesNames.length;
let i, j, jj, table, tableName;
let offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
const tableOffsets = [offset];
for (i = 0; i < numTables; i++) {
table = tables[tablesNames[i]];
const paddedLength = (table.length + 3 & ~3) >>> 0;
tableOffsets.push(offset);
const file = new Uint8Array(offset);
for (i = 0; i < numTables; i++) {
table = tables[tablesNames[i]];
writeData(file, tableOffsets[i], table);
sfnt = string32(0x00010000);
file[0] = sfnt.charCodeAt(0) & 0xff;
file[1] = sfnt.charCodeAt(1) & 0xff;
file[2] = sfnt.charCodeAt(2) & 0xff;
file[3] = sfnt.charCodeAt(3) & 0xff;
writeInt16(file, 4, numTables);
const searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
writeInt16(file, 6, searchParams.range);
writeInt16(file, 8, searchParams.entry);
writeInt16(file, 10, searchParams.rangeShift);
offset = OTF_HEADER_SIZE;
for (i = 0; i < numTables; i++) {
tableName = tablesNames[i];
file[offset] = tableName.charCodeAt(0) & 0xff;
file[offset + 1] = tableName.charCodeAt(1) & 0xff;
file[offset + 2] = tableName.charCodeAt(2) & 0xff;
file[offset + 3] = tableName.charCodeAt(3) & 0xff;
for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
const quad = readUint32(file, j);
checksum = checksum + quad >>> 0;
writeInt32(file, offset + 4, checksum);
writeInt32(file, offset + 8, tableOffsets[i]);
writeInt32(file, offset + 12, tables[tableName].length);
offset += OTF_TABLE_ENTRY_SIZE;
if (tag in this.tables) {
throw new Error("Table " + tag + " already exists");
;// CONCATENATED MODULE: ./src/core/type1_parser.js
const HINTING_ENABLED = false;
convert(encoded, subrs, seacAnalysisEnabled) {
const count = encoded.length;
for (let i = 0; i < count; i++) {
value = (value << 8) + encoded[++i];
error = this.executeCommand(2, COMMAND_MAP.hstem);
error = this.executeCommand(2, COMMAND_MAP.vstem);
if (this.stack.length < 1) {
const dy = this.stack.pop();
error = this.executeCommand(1, COMMAND_MAP.vmoveto);
error = this.executeCommand(2, COMMAND_MAP.rlineto);
error = this.executeCommand(1, COMMAND_MAP.hlineto);
error = this.executeCommand(1, COMMAND_MAP.vlineto);
error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
if (this.stack.length < 1) {
subrNumber = this.stack.pop();
if (!subrs[subrNumber]) {
error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
if (this.stack.length < 2) {
this.stack.push(wx, sbx);
error = this.executeCommand(2, COMMAND_MAP.hmoveto);
this.output.push(COMMAND_MAP.endchar[0]);