diff --git a/emptyfont.toml b/emptyfont.toml
index d242884..0abc432 100644
--- a/emptyfont.toml
+++ b/emptyfont.toml
@@ -108,5 +108,5 @@ maxMemType42 = 0
minMemType1 = 0
minMemType42 = 0
postoints = 65411
-underlinePosition = 50
-underlineThickness = 0
\ No newline at end of file
+underlinePosition = -50
+underlineThickness = 50
\ No newline at end of file
diff --git a/generator.js b/generator.js
index 3173334..2385eef 100644
--- a/generator.js
+++ b/generator.js
@@ -1,13 +1,13 @@
-var fs = require('fs');
-var path = require('path');
+var fs = require("fs");
+var path = require("path");
-//var TTFWriter = require('node-sfnt').TTFWriter;
-var argv = require('yargs').argv;
-var buildGlyphs = require('./buildglyphs.js');
-var parameters = require('./parameters');
-var toml = require('toml');
+// var TTFWriter = require('node-sfnt').TTFWriter;
+var argv = require("yargs").argv;
+var buildGlyphs = require("./buildglyphs.js");
+var parameters = require("./parameters");
+var toml = require("toml");
-var Glyph = require('./support/glyph');
+var Glyph = require("./support/glyph");
function hasv(obj) {
if (!obj) return false;
@@ -17,93 +17,99 @@ function hasv(obj) {
// Font building
var font = function () {
- var parametersData = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'parameters.toml'), 'utf-8'));
- var emptyFont = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'emptyfont.toml'), 'utf-8'));
+ var parametersData = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), "parameters.toml"), "utf-8"));
+ var emptyFont = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), "emptyfont.toml"), "utf-8"));
var para = parameters.build(parametersData, argv._);
- var fontUniqueName = para.family + ' ' + para.style + ' ' + para.version + ' (' + para.codename + ')'
+ var fontUniqueName = para.family + " " + para.style + " " + para.version + " (" + para.codename + ")";
- console.log(' Start building font ' + fontUniqueName);
+ console.log(" Start building font " + fontUniqueName);
var font = buildGlyphs.build.call(emptyFont, para);
- console.log(' ' + fontUniqueName + " Successfully built.");
+ console.log(" " + fontUniqueName + " Successfully built.");
font.parameters = para;
font.glyf = font.glyf.sort(function (a, b) {
var pri1 = a.cmpPriority || 0;
var pri2 = b.cmpPriority || 0;
return (pri2 !== pri1 ? pri2 - pri1 : a.contours.length !== b.contours.length ? a.contours.length - b.contours.length : (a.unicode && b.unicode && a.unicode[0] !== b.unicode[0]) ? a.unicode[0] - b.unicode[0] : (a.name < b.name) ? (-1) : (a.name > b.name) ? 1 : 0);
- })
+ });
return font;
-} ();
+}();
-if (argv.charmap) (function () {
- console.log(' Writing character map -> ' + argv.charmap);
- fs.writeFileSync(argv.charmap, JSON.stringify(font.glyf.map(function (glyph) {
- return [
- glyph.name,
- glyph.unicode,
- glyph.advanceWidth === 0 ? hasv(glyph.anchors) ? 1 : (glyph.contours && glyph.contours.length) ? 2 : 0 : 0
- ]
- })), 'utf8');
-})();
+if (argv.charmap) {
+ (function () {
+ console.log(" Writing character map -> " + argv.charmap);
+ fs.writeFileSync(argv.charmap, JSON.stringify(font.glyf.map(function (glyph) {
+ return [
+ glyph.name,
+ glyph.unicode,
+ glyph.advanceWidth === 0 ? hasv(glyph.anchors) ? 1 : (glyph.contours && glyph.contours.length) ? 2 : 0 : 0
+ ];
+ })), "utf8");
+ })();
+}
-if (argv.svg) (function () {
- console.log(' Writing outline as SVG -> ' + argv.svg);
+if (argv.svg) {
+ (function () {
+ console.log(" Writing outline as SVG -> " + argv.svg);
- var foundNaN = false;
- var glyfname = '';
- function mix(a, b, p) { return a + (b - a) * p };
+ var foundNaN = false;
+ var glyfname = "";
+ function mix(a, b, p) { return a + (b - a) * p; }
- function toSVGPath(glyph) {
- var buf = '';
- foundNaN = false;
- glyfname = glyph.name;
- if (glyph.contours) for (var j = 0; j < glyph.contours.length; j++) {
- buf += Glyph.contourToSVGPath(glyph.contours[j], false);
- }
- return buf;
- }
- var svg = ''
- + ''
- + '';
- fs.writeFileSync(argv.svg, svg, 'utf-8');
-})();
+ var svg = ''
+ + ''
+ + '";
+ fs.writeFileSync(argv.svg, svg, "utf-8");
+ })();
+}
+
+if (argv.meta) {
+ (function () {
+ console.log(" Writing metadata as JSON -> " + argv.meta);
+ if (argv.svg) {
+ font.glyf = null;
+ font.glyfMap = null;
+ }
+ fs.writeFileSync(argv.meta, JSON.stringify(font));
+ })();
+}