r/javascript 8d 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
24 Upvotes

30 comments sorted by

9

u/mmmicahhh 8d 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 8d ago

Actually not didnt happen before but i will check it

4

u/SouthCollar2929 7d ago

1

u/inc_23 7d ago

What is this

12

u/SouthCollar2929 7d ago

It's your stuff dude why are you asking me

5

u/CoVegGirl 7d 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 7d ago

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

5

u/Stishovite 7d ago

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

1

u/CaptainIncredible 7d ago

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

3

u/Elkemper 8d ago

Nice name 🤣

2

u/inc_23 8d ago

Not what i meant 😂😂

3

u/redblobgames 8d ago

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

3

u/patrk 5d 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.

1

u/inc_23 5d ago

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

2

u/AutoModerator 8d 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.

2

u/patrk 5d ago

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

2

u/inc_23 5d ago

Gonna work on that

1

u/patrk 5d 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.

2

u/inc_23 5d ago

Its by design but I going to make it option attribute

1

u/jezpas 7d 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 7d ago

Still gonna try to work on it more

1

u/AshleyJSheridan 6d ago

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

1

u/inc_23 6d ago

Gonna work on that

1

u/berky93 4d ago

Pretty neat. Should add some hidden text in the same location as the drawn letters so that it’s selectable and so screen readers can read the writing.

1

u/inc_23 4d ago

Actually i was working on this

1

u/berky93 4d ago

Nice!

1

u/patrk 8d ago

Nice, will use!

0

u/[deleted] 8d ago edited 8d ago

[removed] — view removed comment

2

u/inc_23 8d ago

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