Srikanth Bandaru

Hunch

A font that guesses the rest of your word. No JavaScript.

Type in the box. The grey ending is the font’s guess. Copy your text and the guess stays behind.

Voice

Hunch is a font that guesses what you’ll type next. Type “I like choc” and a grey “olate” appears after it. There is no JavaScript behind it, no WebAssembly and no extension. A small n-gram model is compiled into ordinary OpenType substitution rules, and the text engine already in your browser runs them on every keystroke. The guess is drawn by the font, so it never enters your text. Copy what you typed and only your words come out.

How a font can guess

A font can’t run code, but it can swap glyphs for other glyphs when the glyphs around them match a pattern. One round of swapping is a pass, and Hunch chains 5 of them.

  1. Every glyph that has another glyph after it becomes its “not last” form, so the last thing you typed is the only glyph left in its plain form.
  2. Every letter that follows a letter becomes its “inside a word” form, so a word’s first letter is the only one without it. That anchors every rule at a word start.
  3. The last letter, or a final space, gets 2 empty, zero-width glyphs inserted after it.
  4. The rules: 20,000 patterns like “c-h-o-c at the end of the line”, longest first. A matching rule writes 2 digits, each from 0 to 255, into the 2 empty glyphs.
  5. A single ligature turns each pair of digits into a ghost glyph: zero width, its outline drawn to the right of where it sits, in a grey that lives in the font’s colour table.

Because the ghost has no width, the line, the caret and the selection all behave as if it isn’t there. It is just ink past the end of the text.

How good are the guesses?

The model is a table of word counts from 13 novels. After 3 letters the font finishes the word correctly about half the time. It gets the next word right 13.2% of the time, so most of what it suggests after a space is wrong. Some of its wrong guesses are funny: “the cat” becomes “the catherine”. Both numbers were measured on Great Expectations, a novel the model never saw. The compiled font also does exactly what the model says: all 986,942 positions in that novel agree (measured).

What it can’t do

  • The guess hangs off the end of each line, not your cursor. A font never knows where the cursor is.
  • You can’t accept a guess with Tab. A font can’t do that, and adding JavaScript would defeat the point.
  • Punctuation breaks a context: after “said, ” there’s no guess. Two spaces in a row break it too.
  • It speaks ASCII only, in one monospace face, Geist Mono.
  • Safari and macOS apps haven’t been tested yet. In Chrome 153 and Firefox 159 every check passes, with JavaScript on and off.