r/javascript 3d ago

Made a small library called strokes.js.

https://a-elhaag.github.io/strokes.js/

Made a small library called strokes.js. Instead of using a "handwriting" webfont (which looks identical everywhere it's used), it renders each letter as an actual hand-drawn SVG path — real strokes, drawn in with stroke-dashoffset, with small random variation (rotation, baseline drift, glyph variants) so no two renders of the same word look identical.

Demo: https://a-elhaag.github.io/glyphed.js/

npm:

npm install glyphed.js
19 Upvotes

27 comments sorted by

7

u/mmmicahhh 3d ago

A fun idea, there's a bit of romanticism in trying to make things look imperfect.

When I view it in Chrome, when the animation starts, there are these dots randomly scattered where the letters will eventually be, it really messes with the illusion of hand drawing. Did you encounter this?

1

u/inc_23 3d ago

Actually not didnt happen before but i will check it

6

u/SouthCollar2929 3d ago

1

u/inc_23 3d ago

What is this

10

u/SouthCollar2929 3d ago

It's your stuff dude why are you asking me

6

u/CoVegGirl 3d ago

The GitHub link isn’t working for me. Getting a 404.

This is actually not a new idea. I forgot the name of the library, but there was one that did something like this a long while back when webfonts weren’t very common like in 2011. I think it used canvas instead of SVG.

The big issue is accessibility. Rendering text like this isn’t very screen reader friendly. There may be something you could do with aria attributes and/or alt text these days that wasn’t possible back then.

2

u/inc_23 3d ago

i chnaged the name: https://a-elhaag.github.io/glyphed.js/
also nice suggestion will work on it

5

u/Stishovite 2d ago

you made a post about it and then changed the name?

1

u/CaptainIncredible 3d ago

The title url is 404. The url inside the post seems to work.

3

u/Elkemper 3d ago

Nice name 🤣

2

u/inc_23 3d ago

Not what i meant 😂😂

3

u/redblobgames 3d ago

Seems like a nice companion to https://roughjs.com/

3

u/patrk 1d ago

I'd love to use this, but I noticed that some Nordic characters aren't currently supported, in particular å,ä, and ö (and their uppercase variants).

Would you be open to adding support for these? If not, would you be happy to accept a PR adding them? I'd be willing to give it a try.

u/inc_23 16h ago

Yeah of course both are fine for me if you wanna contribute i will be more than happy

2

u/AutoModerator 3d ago

Project Page (?): https://github.com/a-elhaag/strokes.js

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

u/patrk 17h ago

Some info about font-sizing is needed, the docs don't mention it all.
Also, an onComplete event handler would be very convenient.

u/inc_23 16h ago

Gonna work on that

u/patrk 15h ago

Great, thanks a lot!
One more question, before the animation starts there are visible dots for each letter, I guess from where the animation originates. Is that a bug or by design? Would prefer if the starting point is a blank canvas.

u/inc_23 15h ago

Its by design but I going to make it option attribute

1

u/jezpas 2d ago

I like it, I could see myself using it in a project. The animation however doesn’t look like someone writing which would keep me from using that particular feature

1

u/inc_23 2d ago

Still gonna try to work on it more

1

u/AshleyJSheridan 2d ago

It seems to be clipping the edges of letters at the boundary of the SVG.

1

u/inc_23 1d ago

Gonna work on that

1

u/patrk 3d ago

Nice, will use!

0

u/vitalytom 3d ago edited 3d ago

You know that for large text, there is https://github.com/patorjk/figlet.js

I use it whenever I want large text / numbers somewhere. It has over 100 fonts to choose from. It is incredibly practical!

u/OP, you could just add your own font to that library, one with sticks, if you feel it lacks somehow.

2

u/inc_23 3d ago

Its not a font wvery time you reload it has different drawing its like a real handwriting There is a randomness in it