summaryrefslogtreecommitdiffstats
path: root/web/api/ilove/measure-text.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:19:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:53:24 +0000
commitb5f8ee61a7f7e9bd291dd26b0585d03eb686c941 (patch)
treed4d31289c39fc00da064a825df13a0b98ce95b10 /web/api/ilove/measure-text.js
parentAdding upstream version 1.44.3. (diff)
downloadnetdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.tar.xz
netdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.zip
Adding upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/api/ilove/measure-text.js')
-rw-r--r--web/api/ilove/measure-text.js73
1 files changed, 0 insertions, 73 deletions
diff --git a/web/api/ilove/measure-text.js b/web/api/ilove/measure-text.js
deleted file mode 100644
index e2a2a6e94..000000000
--- a/web/api/ilove/measure-text.js
+++ /dev/null
@@ -1,73 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-'use strict';
-
-var path = require('path');
-var fs = require('fs');
-var PDFDocument = require('pdfkit');
-var doc = new PDFDocument({size:'A4', layout:'landscape'});
-
-function loadFont(fontPaths, callback) {
- for (let fontPath of fontPaths) {
- try {
- doc = doc.font(fontPath);
- if (callback) { callback(null); }
- return; // Exit once a font is loaded successfully
- } catch(err) {
- // Log error but continue to next font path
- console.error(`Failed to load font from path: ${fontPath}. Error: ${err.message}`);
- }
- }
-
- // If we reached here, none of the fonts were loaded successfully.
- console.error('All font paths failed. Stopping execution.');
- process.exit(1); // Exit with an error code
-}
-
-loadFont(['IBMPlexSans-Bold.ttf'], function(err) {
- if (err) {
- console.error('Could not load any of the specified fonts.');
- }
-});
-
-doc = doc.fontSize(250);
-
-function measureCombination(charA, charB) {
- return doc.widthOfString(charA + charB);
-}
-
-function getCharRepresentation(charCode) {
- return (charCode >= 32 && charCode <= 126) ? String.fromCharCode(charCode) : '';
-}
-
-function generateCombinationArray() {
- let output = "static const unsigned short int ibm_plex_sans_bold_250[128][128] = {\n";
-
- for (let i = 0; i <= 126; i++) {
- output += " {"; // Start of inner array
- for (let j = 0; j <= 126; j++) {
- let charA = getCharRepresentation(i);
- let charB = getCharRepresentation(j);
- let width = measureCombination(charA, charB) - doc.widthOfString(charB);
- let encodedWidth = Math.round(width * 100); // Multiply by 100 and round
-
- if(charA === '*' && charB == '/')
- charB = '\\/';
-
- if(charA === '/' && charB == '*')
- charB = '\\*';
-
- output += `${encodedWidth} /* ${charA}${charB} */`;
- if (j < 126) {
- output += ", ";
- }
- }
- output += "},\n"; // End of inner array
- }
- output += "};\n"; // End of 2D array
-
- return output;
-}
-
-console.log(generateCombinationArray());
-console.log('static const unsigned short int ibm_plex_sans_bold_250_em_size = ' + Math.round(doc.widthOfString('M') * 100) + ';');