Pxxl.js icon indicating copy to clipboard operation
Pxxl.js copied to clipboard

Node.js support

Open remcoder opened this issue 12 years ago • 8 comments

add a util function to load an font file on the server-side

remcoder avatar May 15 '13 08:05 remcoder

can it support nodejs now ?

switer avatar Jan 22 '14 09:01 switer

Thanks for pinging me. This was long overdue.

There's some preliminary node support now in the new node-version branch. See this example: test.js. You'll need to cd into the js directory or otherwise it cannot find the font files.

For now, the node js support is pretty basic. I haven't looked into creating an actual npm package for example.

I hope you find it useful. Suggestions and/or PR's are always welcome ;-)

remcoder avatar Jan 22 '14 21:01 remcoder

Thanks, I thank it's usefull for me. When I cd into test/ and run node test, it catch "Unable to parse font!" error. What's the problem.

switer avatar Jan 23 '14 02:01 switer

You should be cd'ing into js not test. What platform are you on? I have only tested on OSX. Also, can you give me a stracktrace?

remcoder avatar Jan 23 '14 20:01 remcoder

I try cd into js and node test, it also catch that error, running on node 0.10.13 win7 64. I have try it on OSX, it runs fine. @remcoder can your make it support for windows ?

switer avatar Jan 24 '14 02:01 switer

@remcoder , i have found the problem that cause the error, in windows bdf file is in windows line ending, save bdf file with unix line ending, it runs file.

switer avatar Jan 24 '14 02:01 switer

Thx for reporting back. I appreciate it ;-)

remcoder avatar Jan 24 '14 10:01 remcoder

FWIW adding node support was stupid easy - nice job @remcoder. It was just a matter of changing the loadFont function to use fs.readFile() and then exporting the Pxxl function.

For some reason, the small font doesn't work for me but the others do. Nice :)

Qix- avatar Jan 07 '19 14:01 Qix-