Moved all chains to chain prefix modules
This commit is contained in:
parent
38d9a514c8
commit
26d33c1ec7
68 changed files with 96 additions and 105 deletions
47
gdxapp4d-chain-font-unicode4d/src/main/nodejs/conv-font.js
Normal file
47
gdxapp4d-chain-font-unicode4d/src/main/nodejs/conv-font.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
const opentype = require('opentype.js');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const font = opentype.loadSync(args[0]);
|
||||
|
||||
function formatUnicode(unicode) {
|
||||
unicode = unicode.toString(16);
|
||||
if (unicode.length > 4) {
|
||||
return ("000000" + unicode.toUpperCase()).substr(-6)
|
||||
} else {
|
||||
return ("0000" + unicode.toUpperCase()).substr(-4)
|
||||
}
|
||||
}
|
||||
|
||||
console.log("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
console.log("<opentype>");
|
||||
|
||||
let num = font.numGlyphs;
|
||||
for(let glyphIndex = 0; glyphIndex < num; glyphIndex++) {
|
||||
let glyph = font.glyphs.get(glyphIndex);
|
||||
|
||||
// JS NOTE: without calling xMin the getContours returns empty set.... :''(
|
||||
glyph.xMin;
|
||||
var contours = glyph.getContours();
|
||||
if (contours.length === 0) {
|
||||
continue; // TODO: add compound support
|
||||
}
|
||||
if (glyph.unicodes.length === 0) {
|
||||
continue; // with cmds, these are compound glyphs by index base only
|
||||
}
|
||||
let uni = glyph.unicodes.map(formatUnicode).join(', ');
|
||||
console.log("\t<glyph unicode=\""+uni+"\" name=\""+glyph.name+"\" advanceWidth=\""+glyph.advanceWidth+"\" "+
|
||||
"xMin=\""+glyph.xMin+"\" xMax=\""+glyph.xMax+"\" yMin=\""+glyph.yMin+"\" yMax=\""+glyph.yMax+"\" "+
|
||||
"leftSideBearing=\""+glyph.leftSideBearing+"\">");
|
||||
|
||||
for (let contourIndex = 0; contourIndex < contours.length; ++contourIndex) {
|
||||
const contour = contours[contourIndex];
|
||||
console.log("\t\t<contour>");
|
||||
for (let i = 0; i < contour.length; ++i) {
|
||||
let curr = contour[i];
|
||||
console.log("\t\t\t<point x=\""+curr.x+"\" y=\""+curr.y+"\" onCurve=\""+curr.onCurve+"\"/>");
|
||||
}
|
||||
console.log("\t\t</contour>");
|
||||
}
|
||||
console.log("\t</glyph>");
|
||||
}
|
||||
console.log("</opentype>");
|
||||
10
gdxapp4d-chain-font-unicode4d/src/main/nodejs/conv-font.sh
Executable file
10
gdxapp4d-chain-font-unicode4d/src/main/nodejs/conv-font.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p $2;
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
for FILE in `ls $1`
|
||||
do
|
||||
node $SCRIPT_DIR/conv-font.js $1/$FILE > $2/$FILE.xml
|
||||
done
|
||||
61
gdxapp4d-chain-font-unicode4d/src/main/nodejs/package-lock.json
generated
Normal file
61
gdxapp4d-chain-font-unicode4d/src/main/nodejs/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "conv-font",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "conv-font",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"opentype.js": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/opentype.js": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-1.3.4.tgz",
|
||||
"integrity": "sha512-d2JE9RP/6uagpQAVtJoF0pJJA/fgai89Cc50Yp0EJHk+eLp6QQ7gBoblsnubRULNY132I0J1QKMJ+JTbMqz4sw==",
|
||||
"dependencies": {
|
||||
"string.prototype.codepointat": "^0.2.1",
|
||||
"tiny-inflate": "^1.0.3"
|
||||
},
|
||||
"bin": {
|
||||
"ot": "bin/ot"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string.prototype.codepointat": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.1.tgz",
|
||||
"integrity": "sha512-2cBVCj6I4IOvEnjgO/hWqXjqBGsY+zwPmHl12Srk9IXSZ56Jwwmy+66XO5Iut/oQVR7t5ihYdLB0GMa4alEUcg=="
|
||||
},
|
||||
"node_modules/tiny-inflate": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
|
||||
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw=="
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"opentype.js": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-1.3.4.tgz",
|
||||
"integrity": "sha512-d2JE9RP/6uagpQAVtJoF0pJJA/fgai89Cc50Yp0EJHk+eLp6QQ7gBoblsnubRULNY132I0J1QKMJ+JTbMqz4sw==",
|
||||
"requires": {
|
||||
"string.prototype.codepointat": "^0.2.1",
|
||||
"tiny-inflate": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"string.prototype.codepointat": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.1.tgz",
|
||||
"integrity": "sha512-2cBVCj6I4IOvEnjgO/hWqXjqBGsY+zwPmHl12Srk9IXSZ56Jwwmy+66XO5Iut/oQVR7t5ihYdLB0GMa4alEUcg=="
|
||||
},
|
||||
"tiny-inflate": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
|
||||
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw=="
|
||||
}
|
||||
}
|
||||
}
|
||||
10
gdxapp4d-chain-font-unicode4d/src/main/nodejs/package.json
Normal file
10
gdxapp4d-chain-font-unicode4d/src/main/nodejs/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "conv-font",
|
||||
"version": "0.0.1",
|
||||
"description": "Convert font data to XML intermediate.",
|
||||
"private": true,
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"opentype.js": "1.3.4"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue