[HN Gopher] Show HN: Handwriter.ttf - Handwriting Synthesis with...
___________________________________________________________________
Show HN: Handwriter.ttf - Handwriting Synthesis with Harfbuzz WASM
During the hype of llama.ttf months ago, I was speculating the
potential of WASM shaper for even crazier purpose, one that fitter
to a font shaper's duty -- to synthesize font at runtime. This
project as proof-of-concept implements a synthesizer that generates
and rasterizes handwriting-style font, backed by a super-
lightweight RNN model (~14MiB).
Author : hsfzxjy
Score : 128 points
Date : 2024-08-21 07:47 UTC (15 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| kragen wrote:
| this is amazing! i'm guessing you can probably get it to
| antialias without much more work
|
| as the demo video shows, it's probably not something you want to
| have in between you and the ability to scroll a web page or close
| a tab. but i guess using harfbuzz now means we're buying into a
| turing-complete virtual machine running an arbitrary program in
| order to display a glyph. how seriously crippled are the
| harfbuzzless rendering paths? i'm assuming opting out of harfbuzz
| means opting out of arabic, devanagari and other indic scripts,
| etc.? is there a less out-of-control alternative that doesn't
| leave two billion people out in the cold?
| hsfzxjy wrote:
| This is just a project for fun, like llama.ttf.
|
| WASM shaper is still experimental and not yet shipped in and
| products, not before more limitation carried out as I think. So
| I'm not too worried about it.
| kragen wrote:
| it's super cool!
| jcelerier wrote:
| I wonder what makes SIMD an improvement here - in the end it all
| boils down to TTF bytecode and I don't think this comes with SIMD
| instructions, right?
| hsfzxjy wrote:
| wasm has SIMD extension
| https://github.com/WebAssembly/simd/blob/master/proposals/si...
| . You can use them even in browsers (e.g. Chrome >= 91)
| jsheard wrote:
| OP is asking how SIMD is beneficial to this specific
| application. If there's a small neural network involved then
| evaluating that is probably a good place to use SIMD.
| hsfzxjy wrote:
| Yes. The program actually includes an ONNX runtime, which
| uses SIMD to accelerate NN inference.
| jcelerier wrote:
| but... the program ends up entirely compiled and executed
| as TTF bytecode in the end right, since it's entirely
| contained in the TTF font ? And TTF bytecode is only the
| following instructions :
| https://developer.apple.com/fonts/TrueType-Reference-
| Manual/... and I don't see anything related to SIMD in
| there
| erk__ wrote:
| No that is not what is happening, HarfBuzz have a
| experimental Wasm shaper, so the font embeds some wasm
| code that tells Harfbuzz what to output.
|
| https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-
| sha...
| jcelerier wrote:
| oh ok, so it can't work in any system that doesn't use
| harfbuzz.. that's much less interesting than what I
| originally thought
| a1o wrote:
| I don't get it, why there's no link to a GitHub pages website to
| test the thing?
| hsfzxjy wrote:
| You can't test it in a browser, since no browser at present is
| linked against libharfbuzz with WASM shaper. Instead, one can
| test it with a modified local program such as gedit in the
| demo.
|
| As convenience, I built a Docker image that packs both the ttf
| file and the modified gedit together. You can try it out via
| `make run` as stated in the instructions.
| okcdz wrote:
| If you just want to run locally. Why not using the native
| libharfbuzz directly? What's the purpose of WASM here?
| bawolff wrote:
| WASM is to libharfbuzz (when experimental compile time
| option is enabled) what javascript is to HTML.
|
| So this is essentially native (albeit experimental)
| libharfbuzz. WASM is used because its how font files are
| scripted (when using this experimental version of
| lubharfbuzz)
|
| Its important to keep in mind that wasm is a general
| technology and is not just used by web browsers.
| 0x457 wrote:
| Font includes WASM code that harfbuzz executes for shaping:
| https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-
| sha...
|
| It's an experimental feature, so it's not available unless
| explicitly enabled during compilation.
| a1o wrote:
| Harfbuzz can be built easily to Wasm using Emscripten.
| einpoklum wrote:
| OP's repository has a Makefile which assumes a docker daemon is
| available.
| hsfzxjy wrote:
| The project must be tested in an application linked against
| libharfbuzz with WASM shaper enabled. Since it's not easy to
| build a library like this, I make a Docker image which contains
| both the ttf file and a modified gedit, so that anyone can test
| the project with a single command.
| cyberax wrote:
| Year 2045: fonts become self-aware and go on a strikethrough.
| noman-land wrote:
| I'm mad at you for forcing me to laugh at this.
| shove wrote:
| Best comment
| koolala wrote:
| :) I sware that smilely just winked at me
| dancemethis wrote:
| This is so cursed, there is so much that begs the question -
| "why?"...
|
| I love it.
|
| I can't wait for the next beautiful nightmare. Maybe someone
| should mix font rendering with PDF rendering. Of course, with a
| LLM doing something in the middle.
| hsfzxjy wrote:
| The answer is "no why", just for fun :) Though I learned a lot
| about how to stuff an NN model in a WASM binary and some tricks
| to optimize performance.
| calebj0seph wrote:
| Damn, this is impressive!
|
| We built a WebGL text renderer with full CJK support using
| Harfbuzz for our production whiteboard web app. I thought that
| was complicated until now.
| PhilipRoman wrote:
| I bet this is what people felt when JavaScript was first demoed
| on the web.
|
| In the year 2077, when each font will run it's own virtual
| machine on WASM containing a "minimal" Ubuntu image, some
| enlightened blogger will suggest server side rendered fonts as a
| performance improvement.
| petercooper wrote:
| JS felt less impressive to me when I first saw it, simply
| because it couldn't do much. However, I remember the showcase
| Microsoft put together to show off what _CSS_ could do in IE3
| and that was very cool at the time.
| pandeiro wrote:
| I remember that, too, and switched to IE for the next X years
| tombh wrote:
| I've read the README and watched the video, but I'm still not
| sure what this is doing? I know it can "synthesize [a] font at
| runtime", so does that mean it's creating a random handwritten
| font as you type? But it's not based on the user's handwriting?
| pjmlp wrote:
| Nice demo.
|
| Without trying to steal the thread, what I would care is actually
| the opposite direction.
|
| Neither in Swift Playgrounds, nor in any other programming
| development environment apps for both mobile OSes, have I found a
| good development experience using pen instead of keyboard.
|
| Given how many of us "program" in paper notebooks, it is quite
| incredible that besides a couple of research projects done by PhD
| students, no one cares to actually make it more widespread in a
| usable way.
| Unearned5161 wrote:
| I could see something like Apples new calculator drawing app
| taking this by storm. Writing out your code and getting syntax
| support and all the things in your ide but with your
| handwriting?
|
| In the same way that the calculator writes in the answers in
| your handwriting, it could write in snippets of code in your
| handwriting.
|
| If it's going to be made though, it has to be e-ink. Go big or
| go home!
| eigenvalue wrote:
| Fun hack. I bet Alex Graves never in a million years anticipated
| that his PhD thesis work would be encapsulated in a novelty font.
| gwern wrote:
| This looks like it'd be quite useful for faking documents more
| convincingly. Existing handwriting fonts always have tell-tale
| regularities and there's so few that forensics analysis exposes
| them easily.
| vintermann wrote:
| So you trained a THAT small RNN to make this good handwriting?
| I'm actually even more impressed at that than at the crazy
| pipeline turning it into a font in realtime.
___________________________________________________________________
(page generated 2024-08-21 23:00 UTC)