: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const getFontBasicMetrics = getLookupTableFactory(function (t) {
t["Courier-BoldOblique"] = {
t["Helvetica-Oblique"] = {
t["Helvetica-BoldOblique"] = {
t["Times-BoldItalic"] = {
;// CONCATENATED MODULE: ./src/core/glyf.js
const ON_CURVE_POINT = 1 << 0;
const X_SHORT_VECTOR = 1 << 1;
const Y_SHORT_VECTOR = 1 << 2;
const REPEAT_FLAG = 1 << 3;
const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
const OVERLAP_SIMPLE = 1 << 6;
const ARG_1_AND_2_ARE_WORDS = 1 << 0;
const ARGS_ARE_XY_VALUES = 1 << 1;
const WE_HAVE_A_SCALE = 1 << 3;
const MORE_COMPONENTS = 1 << 5;
const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
const WE_HAVE_INSTRUCTIONS = 1 << 8;
const loca = new DataView(locaTable.buffer, locaTable.byteOffset, locaTable.byteLength);
const glyf = new DataView(glyfTable.buffer, glyfTable.byteOffset, glyfTable.byteLength);
const offsetSize = isGlyphLocationsLong ? 4 : 2;
let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
for (let i = 0; i < numGlyphs; i++) {
const next = isGlyphLocationsLong ? loca.getUint32(pos) : 2 * loca.getUint16(pos);
this.glyphs.push(new Glyph({}));
const glyph = Glyph.parse(prev, glyf);
return this.glyphs.reduce((a, g) => {
const size = g.getSize();
return a + (size + 3 & ~3);
const totalSize = this.getSize();
const glyfTable = new DataView(new ArrayBuffer(totalSize));
const isLocationLong = totalSize > 0x1fffe;
const offsetSize = isLocationLong ? 4 : 2;
const locaTable = new DataView(new ArrayBuffer((this.glyphs.length + 1) * offsetSize));
locaTable.setUint32(0, 0);
locaTable.setUint16(0, 0);
for (const glyph of this.glyphs) {
pos += glyph.write(pos, glyfTable);
locaTable.setUint32(locaIndex, pos);
locaTable.setUint16(locaIndex, pos >> 1);
loca: new Uint8Array(locaTable.buffer),
glyf: new Uint8Array(glyfTable.buffer)
for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
this.glyphs[i].scale(factors[i]);
this.composites = composites;
static parse(pos, glyf) {
const [read, header] = GlyphHeader.parse(pos, glyf);
if (header.numberOfContours < 0) {
const [n, composite] = CompositeGlyph.parse(pos, glyf);
composites.push(composite);
if (!(composite.flags & MORE_COMPONENTS)) {
const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
const size = this.simple ? this.simple.getSize() : this.composites.reduce((a, c) => a + c.getSize(), 0);
return this.header.getSize() + size;
pos += this.header.write(pos, buf);
pos += this.simple.write(pos, buf);
for (const composite of this.composites) {
pos += composite.write(pos, buf);
const xMiddle = (this.header.xMin + this.header.xMax) / 2;
this.header.scale(xMiddle, factor);
this.simple.scale(xMiddle, factor);
for (const composite of this.composites) {
composite.scale(xMiddle, factor);
this.numberOfContours = numberOfContours;
static parse(pos, glyf) {
return [10, new GlyphHeader({
numberOfContours: glyf.getInt16(pos),
xMin: glyf.getInt16(pos + 2),
yMin: glyf.getInt16(pos + 4),
xMax: glyf.getInt16(pos + 6),
yMax: glyf.getInt16(pos + 8)
buf.setInt16(pos, this.numberOfContours);
buf.setInt16(pos + 2, this.xMin);
buf.setInt16(pos + 4, this.yMin);
buf.setInt16(pos + 6, this.xMax);
buf.setInt16(pos + 8, this.yMax);
this.xMin = Math.round(x + (this.xMin - x) * factor);
this.xMax = Math.round(x + (this.xMax - x) * factor);
this.xCoordinates = xCoordinates;
this.yCoordinates = yCoordinates;
this.contours = contours;
this.instructions = instructions;
static parse(pos, glyf, numberOfContours) {
const endPtsOfContours = [];
for (let i = 0; i < numberOfContours; i++) {
const endPt = glyf.getUint16(pos);
endPtsOfContours.push(endPt);
const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
const instructionLength = glyf.getUint16(pos);
const instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
pos += instructionLength;
for (let i = 0; i < numberOfPt; pos++, i++) {
let flag = glyf.getUint8(pos);
if (flag & REPEAT_FLAG) {
const count = glyf.getUint8(++pos);
for (let m = 0; m < count; m++) {
const allXCoordinates = [];
let endPtsOfContoursIndex = 0;
for (let i = 0; i < numberOfPt; i++) {
if (flag & X_SHORT_VECTOR) {
const x = glyf.getUint8(pos++);
lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
xCoordinates.push(lastCoordinate);
} else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
xCoordinates.push(lastCoordinate);
lastCoordinate += glyf.getInt16(pos);
xCoordinates.push(lastCoordinate);
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
allXCoordinates.push(xCoordinates);
endPtsOfContoursIndex = 0;
for (let i = 0; i < numberOfPt; i++) {