
Show HN: Handwritten.js – Convert typed text to realistic handwriting - alias-rahil
https://github.com/alias-rahil/handwritten.js#README.md
======
sjv
Non-statistical methods of imitating handwriting are always fairly easy to
identify as synthetic due to the uniformity of strokes and unnatural kerning
(among other things). Even methods which incorporate random variations don't
hide these artifacts sufficiently well. In my opinion, the only way to
generate synthetic handwriting which is convincingly real is to use
statistical methods (i.e. machine learning) to model all variation which is
present in real handwriting. I've implemented a neural network in javascript
which does exactly this - [https://seanvasquez.com/handwriting-
generation/](https://seanvasquez.com/handwriting-generation/). You can play
around with it and find a few weaknesses, but in general I find that it can
produce handwriting which is indistinguishable from real handwriting.

~~~
MikeTheGreat
This is really neat! I love how it looks, and the selection of styles.

A couple of times, using Style #2, it generated a bunch of loops at the end:

Text: "The quick brown fox, etc" Image:
[https://pasteboard.co/Jn0O17a.png](https://pasteboard.co/Jn0O17a.png)

Still - nifty, and fun to play with. Makes me want to find an application /
excuse to use it :)

~~~
sjv
The model was trained on a relatively small dataset which has few occurrences
of the letter x, almost none of which are in cursive. As you've found, asking
the model to write out an x in a cursive style can totally derail the
generation process.

~~~
fps_doug
Any ELI5 for people who know close to nothing about NN, AI, machine learning
etc?

Like, how does one letter it doesn't know how to write well make it skip/mess
up the following ones too? I mean, "derail" seems a fitting description to
what I'm seeing, but _how_?

~~~
alexanderskates
The "handwriting" data for this model is basically the coordinates of a pen.
The length of the string representation of the text is very different from the
length of the coordinate representation of the text, therefore the model
"learns" a window corresponding to when it is drawing the current letter, and
when to start the next letter. For these letters, as the model doesn't learn
how long this window should be, nor how to transition from it to the next
letter, it gets stuck and outputs nonsense.

------
sago
How realistic is it to have no joined letters? Do many people really write
large scale texts letter by letter with space between each?

Sadly, the screenshot looks obviously artificial to me. Like handwriting
fonts, I'd be very surprised if anybody thought it was really handwritten.

It's not open source (because it is my handwriting (because my progressive MS
means I can't do it manually)), but here's my hack:
[https://imgur.com/a/frqG0cu](https://imgur.com/a/frqG0cu)

As sjv says above, there are still plenty of tells in mine. So I think this
module is very unconvincing.

Maybe I've spent too much time being finicky or am just being braggy
(definitely not beyond me, sorry), but 'realistic'?

~~~
senko
> How realistic is it to have no joined letters? Do many people really write
> large scale texts letter by letter with space between each?

Most of the people I know do this. Myself, I have never ever written with
joined letters except when required to in school.

I consider it a leftover from the era of fountain pens (which are terrible UX
for me as a left-handed writing LTR languages).

Even my signature is based on separate letters (tho blurred together as sigs
usually do).

~~~
sago
Fascinating. Thanks for responding.

Can I ask what age-group you/they are? And it sounds like you had to write
joined-up at school. Why would you stop? Isn't it so much faster?

I went to a snooty high school where fountain pens were compulsory (this was
the 80s, not the 50s!). But writing was taught joined-up from pencils in
infant school, from when you knew your whole alphabet. It never occurred to me
to not join. It would have looked like a very small child's writing.
Interesting though that has changed.

My wife is a grade school teacher, and disagrees, but I totally think that
teaching handwriting is a waste of time. I wasn't anywhere near as fast
writing as typing. I would have been much more productive with a laptop in
school.

Anyway. I'm rambling now. Thanks for the response! I stand corrected.

~~~
senko
I'm 41 - yeah we had learned both joined and "printed" (as we'd call them)
letters, with the intention that for handwriting you'd use joined, but it was
only required, for a bit, in lower grades in Croatian classes (ie. that'd be
English classes in the US/UK/etc).

That was some 33 years ago but I have an 8yr old now and that part of the
curriculum is basically the same.

Both then and now kids only need use pencils for this, thankfully :)

For myself, written joined up is more effort and slower than just individual
letters. I don't know if that's due to less practice in it, or due to left
handed needing to push the pen(cil) more when writing in that style.

I'm way faster touch typing (tho not on a screen keyboard!). If it were up to
me, kids today would learn the easiest handwriting method (I believe that's
individual letters) and typing, instead of two ways of writing.

Thanks for sharing your thoughts! Always interesting to find how somr things I
take for granted are done/seem elsewhere!

------
alias-rahil
Many times I get university assignments that are compulsory to be submitted as
handwritten document. Most of the information needed for the assignment is
available on the internet so why not save time? Just make a text document and
let handwritten.js do the writing part! example:
[https://raw.githubusercontent.com/alias-
rahil/handwritten.js...](https://raw.githubusercontent.com/alias-
rahil/handwritten.js/master/screenshots/lorem-ipsum.jpeg)

~~~
galkk
This is insane busywork that I hated in college (xUSSR, 20+ years ago). I
would scrutinize the example, though. I don't know how "clean" the documents
are expected to be, but the picture is too uniform and too clean - no pen
marks, etc.

~~~
zxcvbn4038
That is pretty much the US experience also, most of grade and high school was
spent copying information from projector slides onto paper. Guess it is an
easy way to fill time, read everything off sentence by sentence, wait for
everyone to stop writing, cover the sentences not being read so people who
fall behind can’t catch up, and speed writers can’t get ahead.

I’m very envious of my son, in his classes they distribute the materials via
Google drive and spend the class time in discussion and working out problems.

~~~
_ZeD_
Writing things down is a known method of studying. I don't envy your son, he
should still write to effectively study

~~~
xmprt
Is it though? I've heard very often that lecturing in this fashion is the most
inefficient way of transmitting information from a slide onto a notebook
without being understood by anyone writing it. If you're processing what
you're seeing and summarizing then maybe that works but I think what worked
best for me was always asking questions about the material.

~~~
grayhatter
He says known method, not known _good_ method.

------
wonderlg
I don’t get this project. This is nothing special, you can very easily spot
that every T is identical. You might as well just use a handwritten font.

~~~
lixtra
It applies Cunningham's Law to find sjv‘s project above.

------
101008
Producing handwriting is a problem a group of people I belong to is facing. We
work (free, on our free time), detecting forgeried signatures of a celebrity
on eBay (forgeries that can go to thousdans of dollars).

Forgers are not good imitating signatures, but they discovered how to create
the celebrity handwriting using an autopen, which means is harder everyday to
distinguish real ones from fake ones. Collectors are used to them - and we
track eBay sellers, buyers, etc, so we have an idea of who is who, but people
who just want to buy a signed book for a birthday present, may end paying
thousdans of dollars but something fake that has no value.

I see the importance of projects like this, but in the other hand, I cant help
thinking that every piece of tech that imitates human behaviour can be used
for bad.

~~~
TT3351
Everything is worth what its purchaser will pay for it. I recommend the Orson
Welles film F is for Fake.

~~~
101008
But if you think you are buying X and receive Y, that's a scam.

------
montroser
You might consider turning this into an OpenType font including all the random
alternates:
[https://graphicdesign.stackexchange.com/questions/26833/hand...](https://graphicdesign.stackexchange.com/questions/26833/handwriting-
font-that-at-random-picks-characters#27456)

------
hombre_fatal
I like how trivial it is over the sort of machine-learning solutions I
envisioned when I clicked into it.

Does it not support a glyph? Just add it. Produces weird output? It's a bug,
not a black box issue, just read the code. Want to use it or port it? It's
just character substitution, go ahead.

A fun twist on the idea would be to generate an SVG path for each character
and then apply some morphing to the path so character strokes are unique.

------
porjo
Also
[https://news.ycombinator.com/item?id=24170366](https://news.ycombinator.com/item?id=24170366)

------
throwaway13337
I've noticed that I get junk mail now that appears hand written. They go so
far as to depress the paper as if with pen in a convincing way. They seem
indistinguishable except that they are marketing.

I'm left wondering if there is some new innovation here combined with
popularity in some marketing newsletter.

I went looking for the device that could do this and have come up empty-
handed. Does anyone know what could create such?

~~~
ziari
Bulk mail is often produced using a letterpress-style machine. Personalized
mail, on the other hand, is usually "handwritten" using a pen plotter (e.g.,
AxiDraw).

[https://axidraw.com/](https://axidraw.com/)

------
smabie
Is this different than a font?

~~~
hombre_fatal
Can a font pick randomly between different versions of the same glyph?

I know a font can define unique ligatures for every character combo, but that
would still mean the same combos like "fi" always look the same. Nice thing
about this low-tech solution is that it can be trivially scaled up to
introduce its own ligatures yet pick from them randomly, just at the expense
of chore work (making the images).

Of course, at that point, it would be tempting to start looking for a more
general solution.

~~~
zimpenfish
> Can a font pick randomly between different versions of the same glyph?

In theory, yes, OpenType Contextual Alternates can do this.

See "Introducing variety" on this page:
[https://www.typenetwork.com/news/article/opentype-at-work-
co...](https://www.typenetwork.com/news/article/opentype-at-work-contextual-
alternates)

------
elorm
Just tried it, font looks great on paper. I don’t have too many uses for this,
but I bet it’ll be pretty handy for people who are still addicted to reading
notes from printed sheets. Great job.

------
gibs0ns
It would be great if this could output a generated font file, which can then
be used on the web etc.

------
elietoubi
Love it! Kinda remind me of the old Hacker News. I wish there were most post
like this one.

------
zerop
Looks good. Where can I use it?

------
foobaw
how about being able to use OCR to read real handwriting :) that would be
truly amazing to accomplish with high precision

------
adamcccc
Feel free to checkout our super-realistic type to handwriting generation in
greetings cards here: [https://wuzci.com/product/we-make-a-great-
pear-3/](https://wuzci.com/product/we-make-a-great-pear-3/)

