(function() {
'use strict';
function hashString(str) {
let hash = 5381;
for (let i = 0; i < str.length; i++) {
hash = ((hash << 5) + hash) + str.charCodeAt(i); hash = hash & hash; }
return Math.abs(hash);
}
function seededRandom(seed) {
let t = seed + 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
try {
if (typeof CanvasRenderingContext2D !== 'undefined' &&
CanvasRenderingContext2D.prototype.measureText) {
const originalMeasureText = CanvasRenderingContext2D.prototype.measureText;
CanvasRenderingContext2D.prototype.measureText = function(text) {
const result = originalMeasureText.apply(this, arguments);
try {
const contextSignature = [
this.font || '',
text || '',
this.textAlign || '',
this.textBaseline || '',
this.direction || ''
].join('|');
const seed = hashString(contextSignature);
const noise = (seededRandom(seed) * 0.1) - 0.05;
result.width += noise;
if (result.actualBoundingBoxLeft !== undefined) {
const seed2 = hashString(contextSignature + 'left');
result.actualBoundingBoxLeft += (seededRandom(seed2) * 0.05) - 0.025;
}
if (result.actualBoundingBoxRight !== undefined) {
const seed3 = hashString(contextSignature + 'right');
result.actualBoundingBoxRight += (seededRandom(seed3) * 0.05) - 0.025;
}
} catch (e) {
}
return result;
};
}
} catch (e) {
}
try {
if (typeof document !== 'undefined' && !document.fonts) {
const commonFonts = [
'Arial',
'Arial Black',
'Comic Sans MS',
'Courier New',
'Georgia',
'Impact',
'Times New Roman',
'Trebuchet MS',
'Verdana',
'Helvetica',
'Tahoma',
'Palatino',
'Garamond',
'Bookman',
'Calibri',
'Segoe UI'
];
const mockFontFaceSet = {
check: function(font, text) {
if (!font) return false;
const fontFamily = font.match(/['"]?([^'"]+)['"]?/)?.[1] || font;
return commonFonts.some(f =>
fontFamily.toLowerCase().includes(f.toLowerCase())
);
},
load: function(font, text) {
return Promise.resolve([]);
},
ready: Promise.resolve(mockFontFaceSet),
status: 'loaded',
size: commonFonts.length,
add: function() { return this; },
delete: function() { return false; },
clear: function() {},
entries: function() { return [][Symbol.iterator](); },
forEach: function() {},
has: function() { return false; },
keys: function() { return [][Symbol.iterator](); },
values: function() { return [][Symbol.iterator](); }
};
Object.defineProperty(document, 'fonts', {
get: function() { return mockFontFaceSet; },
enumerable: true,
configurable: true
});
}
} catch (e) {
}
try {
if (typeof FontFace !== 'undefined') {
const OriginalFontFace = FontFace;
window.FontFace = function(family, source, descriptors) {
const normalizedFamily = family || 'Arial';
return new OriginalFontFace(normalizedFamily, source, descriptors);
};
window.FontFace.prototype = OriginalFontFace.prototype;
Object.setPrototypeOf(window.FontFace, OriginalFontFace);
}
} catch (e) {
}
})();