Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/invoice_pdf/node_modules/@jimp/plugin-print/src/ drwxr-xr-x | |
| Viewing file: Select action/file-type: export function measureText(font, text) {
let x = 0;
for (let i = 0; i < text.length; i++) {
if (font.chars[text[i]]) {
const kerning =
font.kernings[text[i]] && font.kernings[text[i]][text[i + 1]]
? font.kernings[text[i]][text[i + 1]]
: 0;
x += (font.chars[text[i]].xadvance || 0) + kerning;
}
}
return x;
}
export function splitLines(font, text, maxWidth) {
const words = text.replace(/[\r\n]+/g, " \n").split(" ");
const lines = [];
let currentLine = [];
let longestLine = 0;
words.forEach((word) => {
const line = [...currentLine, word].join(" ");
const length = measureText(font, line);
if (length <= maxWidth && !word.includes("\n")) {
if (length > longestLine) {
longestLine = length;
}
currentLine.push(word);
} else {
lines.push(currentLine);
currentLine = [word.replace("\n", "")];
}
});
lines.push(currentLine);
return {
lines,
longestLine,
};
}
export function measureTextHeight(font, text, maxWidth) {
const { lines } = splitLines(font, text, maxWidth);
return lines.length * font.common.lineHeight;
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0053 ]-- |