#!/usr/bin/env node

/**
 * index.js
 *
 * for `character-map` command
 */

var opts = require('minimist')(process.argv.slice(2));
var opentype = require('opentype.js');

if (!opts.f || typeof opts.f !== 'string') {
	console.log('use -f to specify your font path, TrueType and OpenType supported');
	return;
}

opentype.load(opts.f, function(err, font) {
	if (err) {
		console.log(err);
		return;
	}

	if (!font.glyphs || font.glyphs.length === 0) {
		console.log('no glyphs found in this font');
		return;
	}

	var table = '';
	font.glyphs.forEach(function(glyph) {
		if (!glyph.unicode) {
			return;
		}

		table += String.fromCharCode(glyph.unicode);
	});

	console.log(table);
});

@@ -399,33 +399,57 @@
 %7D%0A%0A%09
-if (!font.glyphs %7C%7C font.
+var glyphs = font.glyphs.glyphs;%0A%09if (!glyphs %7C%7C 
 glyp
@@ -546,27 +546,35 @@
  = '';%0A%09
-font.
+Object.keys(
 glyphs
+)
 .forEach
@@ -587,16 +587,41 @@
 ion(
-glyph) %7B
+key) %7B%0A%09%09var glyph = glyphs%5Bkey%5D;
 %0A%09%09i
@@ -656,16 +656,18 @@
 rn;%0A%09%09%7D%0A
+%09%09
 %0A%09%09table

Fix broken iteration of items in Opentype.js slyphs object