Last active
February 5, 2020 12:14
-
-
Save MZachmann/27f99d06d4e727af7eda29ccd5015ade to your computer and use it in GitHub Desktop.
A simple Node.js application to dump the icons of the Material Design Icons font
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http = require('http'); | |
var port = process.env.port || 1337 | |
// this just dumps characters 61400...65600 and 0xf0000...0xf0300 of the Material Design Icons font | |
// that's where the icons are stored. | |
var UseHex: boolean = true; // set to true for hexadecimal indices, false for decimal | |
// print a chunk of the dictionary into the server response | |
function PrintChunk(res: http.ServerResponse, start: number, length:number) | |
{ | |
var addon = UseHex ? 16 : 15; // easy counters for hex/decimal | |
var form = UseHex ? 16 : 10; | |
for (var i: number = 0; i < length; i += addon) { | |
// write the index using 20px font | |
var hd = '<p><span style="font-size: 20px;">' + (start + i).toString(form) + ": "; | |
res.write(hd); | |
// write the icons using 40px font | |
var sout = '<span style="font-family: Material Design Icons;font-size: 40px;">'; | |
res.write(sout); | |
// only 15 characters fit across if you want to print this to 8x11 paper | |
for (var j: number = 0; j < addon; j++) { | |
var sesc = "&#" + (start + j + i) + ";"; | |
res.write(sesc); | |
} | |
res.write('</span>'); | |
res.write('</span>'); | |
res.write('</p>'); | |
} | |
} | |
http.createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/html' }); | |
if (UseHex) { | |
PrintChunk(res, 0xefd0, 4150); | |
PrintChunk(res, 0xf0000, 750); | |
} | |
else { | |
PrintChunk(res, 61400, 4150); | |
PrintChunk(res, 0xf0000, 750); | |
} | |
res.end(); | |
}).listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment