Use my fork of hersheytextjs with experimental multiline support
This commit is contained in:
parent
50f515f49f
commit
d40edeff47
|
@ -1 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
|
test.svg
|
|
@ -10,7 +10,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"hersheytext": "^2.0.0"
|
"hersheytext": "github:mattmcw/hersheytextjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/argparse": {
|
"node_modules/argparse": {
|
||||||
|
@ -133,8 +133,8 @@
|
||||||
},
|
},
|
||||||
"node_modules/hersheytext": {
|
"node_modules/hersheytext": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/hersheytext/-/hersheytext-2.0.0.tgz",
|
"resolved": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#5aab4b86180419170157d36f14571605c587cb06",
|
||||||
"integrity": "sha512-t8UPIWKpPKffT7QcGG8AWXen4zVpfMdlO5uq3cE8aNQGFxSEV/HoGAIFki6lioNi35WG73gaeW4VY3avxsJIrA==",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^0.22.0"
|
"cheerio": "^0.22.0"
|
||||||
},
|
},
|
||||||
|
@ -253,7 +253,21 @@
|
||||||
"node_modules/safe-buffer": {
|
"node_modules/safe-buffer": {
|
||||||
"version": "5.2.1",
|
"version": "5.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"node_modules/string_decoder": {
|
"node_modules/string_decoder": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
|
@ -385,9 +399,8 @@
|
||||||
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
|
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
|
||||||
},
|
},
|
||||||
"hersheytext": {
|
"hersheytext": {
|
||||||
"version": "2.0.0",
|
"version": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#5aab4b86180419170157d36f14571605c587cb06",
|
||||||
"resolved": "https://registry.npmjs.org/hersheytext/-/hersheytext-2.0.0.tgz",
|
"from": "hersheytext@github:mattmcw/hersheytextjs",
|
||||||
"integrity": "sha512-t8UPIWKpPKffT7QcGG8AWXen4zVpfMdlO5uq3cE8aNQGFxSEV/HoGAIFki6lioNi35WG73gaeW4VY3avxsJIrA==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"cheerio": "^0.22.0"
|
"cheerio": "^0.22.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"hersheytext": "^2.0.0"
|
"hersheytext": "github:mattmcw/hersheytextjs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,16 +40,6 @@ async function loadFont (fontPath) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function textPos (str) {
|
|
||||||
const len = str.length;
|
|
||||||
const w = len * W;
|
|
||||||
const h = H;
|
|
||||||
const x = (75.0 - w) / 2.0;
|
|
||||||
const y = (75.0 - h) / 2.0;
|
|
||||||
|
|
||||||
return { x : x * UNIT, y : y * UNIT };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const fontPath = args.font;
|
const fontPath = args.font;
|
||||||
const text = args.text;
|
const text = args.text;
|
||||||
|
@ -66,8 +56,8 @@ async function main () {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
//options.pos = { x: 0, y: 0 };
|
options.pos = { x: 10, y: 10 };
|
||||||
options.pos = textPos(text);
|
//options.pos = textPos(text);
|
||||||
data = hershey.renderTextSVG(text, options);
|
data = hershey.renderTextSVG(text, options);
|
||||||
//console.log(`${header}\n${data}\n${footer}`)
|
//console.log(`${header}\n${data}\n${footer}`)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
const hershey = require('hersheytext');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
font: 'ems_nixish',
|
||||||
|
scale: 0.05,
|
||||||
|
pos : { x: 0, y: 0 },
|
||||||
|
lineHeight: 1000
|
||||||
|
};
|
||||||
|
|
||||||
|
const header = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="305mm" width="229mm" version="1.1">';
|
||||||
|
const data = hershey.renderTextSVG('Take a Look, if you Will.\nNew line', options);
|
||||||
|
const footer = '</svg>';
|
||||||
|
|
||||||
|
fs.writeFileSync('test.svg', `${header}\n${data}\n${footer}`);
|
Loading…
Reference in New Issue