Skip to content

Commit

Permalink
Use unknown character character. Add test framework, test for unknown…
Browse files Browse the repository at this point in the history
… character character.
  • Loading branch information
alanshaw committed Jun 7, 2013
1 parent a070a2d commit 0124f94
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions figlet.js
Expand Up @@ -54,6 +54,12 @@ var Figlet = (typeof exports !== "undefined" ? exports : window).Figlet = {
start = (char - 32) * height,
charDefn = [],
i;

// Is char defined?
if (!fontDefn.defn[start]) {
start = (" ".charCodeAt(0) - 32) * height;
}

for (i = 0; i < height; i++) {
charDefn[i] = fontDefn.defn[start + i]
.replace(/@/g, "")
Expand Down
23 changes: 23 additions & 0 deletions package.json
@@ -0,0 +1,23 @@
{
"name": "figlet-js",
"version": "0.0.0",
"description": "Figlet is a program for making large letters out of ordinary text.",
"main": "figlet-node.js",
"scripts": {
"test": "nodeunit test"
},
"repository": {
"type": "git",
"url": "git://github.com/scottgonzalez/figlet-js.git"
},
"author": "Scott Gonzalez",
"license": "MIT",
"readmeFilename": "readme.md",
"bugs": {
"url": "https://github.com/scottgonzalez/figlet-js/issues"
},
"dependencies": {},
"devDependencies": {
"nodeunit": "~0.8.0"
}
}
2 changes: 2 additions & 0 deletions readme.md
Expand Up @@ -5,6 +5,8 @@
\___ / |___| \______ /|_______ \/_______ / |____| \________|/_______ /
\/ \/ \/ \/ \/

[![Build Status](https://travis-ci.org/olizilla/figlet-js.png?branch=master)](https://travis-ci.org/olizilla/figlet-js)

[Figlet](http://www.figlet.org/) is a program for making large letters out of ordinary text.

Figlet-JS is a JavaScript implementation of a FIGdriver and is available as a Node module and a jQuery plugin.
Expand Down
17 changes: 17 additions & 0 deletions test/figlet.js
@@ -0,0 +1,17 @@
var figlet = require("../figlet-node.js").Figlet;

module.exports = {

// Figlet should replace uknown characters in the font with an unknown character character - a space character
// TODO: Expose unknown character character as an option?
"Test render unknown characters": function (test) {

test.expect(2);

figlet.write("(ノಠ益ಠ)ノ彡", "graffiti", function (er, text) {
test.ifError(er);
test.equal(" ___ ___ \n / / \\ \\ \n / / \\ \\ \n ( ( ) ) \n \\ \\ / / \n \\__\\ /__/ \n", text);
test.done();
});
}
};

0 comments on commit 0124f94

Please sign in to comment.