: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
x = xb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
while (stack.length > 0) {
x = xb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
if (stack.length === 0) {
y = yb + (stack.length === 1 ? stack.shift() : 0);
bezierCurveTo(xa, ya, xb, yb, x, y);
throw new FormatError(`unknown operator: ${v}`);
stack.push((v - 247) * 256 + code[i++] + 108);
stack.push(-(v - 251) * 256 - code[i++] - 108);
stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
if (!isNumberArray(args, null)) {
warn(`Commands.add - "${cmd}" has at least one non-number arg: "${args}".`);
const newArgs = args.map(arg => typeof arg === "number" ? arg : 0);
this.cmds.push(cmd, ...newArgs);
this.cmds.push(cmd, ...args);
constructor(fontMatrix) {
if (this.constructor === CompiledFont) {
unreachable("Cannot initialize CompiledFont.");
this.fontMatrix = fontMatrix;
this.compiledGlyphs = Object.create(null);
this.compiledCharCodeToGlyphId = Object.create(null);
} = lookupCmap(this.cmap, unicode);
let fn = this.compiledGlyphs[glyphId],
fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
this.compiledGlyphs[glyphId] = fn;
this.compiledCharCodeToGlyphId[charCode] ??= glyphId;
compileGlyph(code, glyphId) {
if (!code || code.length === 0 || code[0] === 14) {
let fontMatrix = this.fontMatrix;
const fdIndex = this.fdSelect.getFDIndex(glyphId);
if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
const fontDict = this.fdArray[fdIndex];
fontMatrix = fontDict.getByName("FontMatrix") || FONT_IDENTITY_MATRIX;
warn("Invalid fd index for glyph index.");
const cmds = new Commands();
cmds.add(FontRenderOps.SAVE);
cmds.add(FontRenderOps.TRANSFORM, fontMatrix.slice());
cmds.add(FontRenderOps.SCALE);
this.compileGlyphImpl(code, cmds, glyphId);
cmds.add(FontRenderOps.RESTORE);
unreachable("Children classes should implement this.");
} = lookupCmap(this.cmap, unicode);
return this.compiledGlyphs[glyphId] !== undefined && this.compiledCharCodeToGlyphId[charCode] !== undefined;
class TrueTypeCompiled extends CompiledFont {
constructor(glyphs, cmap, fontMatrix) {
super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
compileGlyphImpl(code, cmds) {
compileGlyf(code, cmds, this);
class Type2Compiled extends CompiledFont {
constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
this.glyphs = cffInfo.glyphs;
this.gsubrs = cffInfo.gsubrs || [];
this.subrs = cffInfo.subrs || [];
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
this.gsubrsBias = getSubroutineBias(this.gsubrs);
this.subrsBias = getSubroutineBias(this.subrs);
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
this.fdSelect = cffInfo.fdSelect;
this.fdArray = cffInfo.fdArray;
compileGlyphImpl(code, cmds, glyphId) {
compileCharString(code, cmds, this, glyphId);
class FontRendererFactory {
static create(font, seacAnalysisEnabled) {
const data = new Uint8Array(font.data);
let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
const numTables = getUint16(data, 4);
for (let i = 0, p = 12; i < numTables; i++, p += 16) {
const tag = bytesToString(data.subarray(p, p + 4));
const offset = getUint32(data, p + 8);
const length = getUint32(data, p + 12);
cmap = parseCmap(data, offset, offset + length);
glyf = data.subarray(offset, offset + length);
loca = data.subarray(offset, offset + length);
unitsPerEm = getUint16(data, offset + 18);
indexToLocFormat = getUint16(data, offset + 50);
cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
const fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
;// CONCATENATED MODULE: ./src/core/metrics.js
const getMetrics = getLookupTableFactory(function (t) {
t["Courier-BoldOblique"] = 600;
t["Courier-Oblique"] = 600;
t.Helvetica = getLookupTableFactory(function (t) {