return to table of content

Tetris as Font

erk__
8 replies
6h9m

I did kinda the opposite and instead of making a font out of tetris I made a font play Tetris.

I did it with the Harfbuzz shaper which now have experimental support for embedding WebAssembly programs to shape fonts.

Talk where I show it off: https://www.youtube.com/watch?v=Ms1Drb9Vw9M

Source code: https://github.com/Erk-/programmable-fonts

You can also see actual uses of this WebAssembly embedding to show that is not just for fun here: https://github.com/harfbuzz/harfbuzz-wasm-examples

sureglymop
1 replies
2h9m

Coolest thing I've seen so far this year. Demo starts at 22:55 but the whole presentation is worth watching.

Bluestein
0 replies
1h35m

I agree. Watched the whole thing and the entire video is worth it.-

(The "historical exploration" of type, and typesetting, even if an introduction, is great ...)

cs702
1 replies
6h1m

Awesome.

This is precisely the sort of beautiful thing I love finding on HN.[a]

Your work put a smile on my face.

Thank you for sharing it here!

---

[a] For those here who only want to see the demo, it starts at 22:50: https://youtu.be/Ms1Drb9Vw9M?t=1370

---

PS. I also submitted your demo to HN. I think it deserves its own post: https://news.ycombinator.com/item?id=40737961

redbell
0 replies
5h35m

I liked how you set your bio in the "About" section, kind of circular dependencies :)

quotemstr
0 replies
2h56m

Nice demo. Really kicks all the "bytecode can never be fast --- we have to AOT everything" people in the teeth, doesn't it?

RugnirViking
0 replies
3h45m

thats absolutely bananas, awesome job. The bad apple showcase is great too.

Bluestein
0 replies
5h23m

Incredible ...

(The Tetris pieces going up upon backspace are a riot :)

tobyhinloopen
6 replies
6h11m

Who would want to use the browser’s back button to undo a state change… I had to press back 20 times

xd1936
2 replies
6h0m

Right-click the back button?

TehCorwiz
1 replies
5h40m

Browsers only display the last 10 - 20 states, so if you've been clicking around it quickly fills up with just this page.

laszlokorte
0 replies
5h6m

Would be nice if browsers would group back button entries by: 1. same url except hash 2. same domain 3. rest

mvf4z7
0 replies
5h30m

Should be replacing state in the history stack rather than pushing a new state.

corytheboyd
0 replies
3h38m

Agreed, was very annoying, please don’t misuse history like that :(

Wowfunhappy
0 replies
5h57m

I don't think it's on purpose, just a naïve consequence of using the URL for state.

makach
4 replies
6h34m

Wow! But can you vary how you build each type - all letters seem to follow the same recipe

edemaine
1 replies
1h36m

Thanks for the feature suggestion! I've gone ahead and implemented random valid stacking order. So if you reload the page, and enter text that repeats the same letter more than once, you will hopefully get different build orders (depending on random choices). For example: https://erikdemaine.org/fonts/tetris/?text=aaaaa&rotate=0&sp...

Bluestein
0 replies
1h14m

Making a great thing even greater :)

Congrats on such a neat idea so nicely executed ...

jtxt
0 replies
1h37m

This is neat, but yeah, another fun challenge: have it build a letter/word/pixel art from random pieces, the best it can.

Bluestein
0 replies
6h29m

Yes. I think the "recipes" are hardcoded.-

mandibeet
0 replies
40m

Now I sing tha song for about 15 min already

froh
0 replies
3h34m

very neat text you've chosen there, too!

thank you :-)

Bluestein
0 replies
3h36m

Indeed.-

(And, incidentally, how the URL encodes the value used for text generation, so that you can share links to actual examples ...)

Pretty neat.-

PS. Nice Rickroll, BTW :)

ericfrederich
2 replies
2h53m

Would be nice if the "obscure in URL" feature wouldn't show the text in the textbox when you send it to someone.

edemaine
0 replies
1h24m

Good idea! I've gone ahead and implemented this feature: if "obscure in URL" is turned on, the text won't be visible unless you focus on the textbox (e.g. to edit it).

Bluestein
0 replies
2h46m

Well noticed. Good point ...

(Or an additional "Obscure in textbox" checkbox or something along those lines ...)

corytheboyd
2 replies
3h37m

I think there’s a small bug where the speed change isn’t reflected in the downloaded gif (it’s very slow by default)

edemaine
1 replies
1h32m

I couldn't reproduce this bug. Perhaps the program you're using to display the GIF doesn't support the GIF frame delay feature? (E.g., Chrome seems to display them fine.) Feel free to open an issue on the repo if I'm missing something: https://github.com/edemaine/font-tetris

corytheboyd
0 replies
37m

Ah, fwiw was using my iPhone for the test, so perhaps it’s just scoped to that. Not like that’s a use case you really need to support with this :)

pcloadletter_
0 replies
5h18m

LOL, completed PhD at 20

breck
0 replies
17m

Oh wow, quite a portfolio: https://github.com/edemaine

He is also the maintainer of KaTeX, which I depend on.

(Thanks Erik!)

zeitlupe
1 replies
4h53m

It reminds me of long-gone times where the web was about sharing easy fun like this instead of viral marketing and influencers.

Bluestein
0 replies
4h49m

(It indeed does :)

Same here)

joshmarinacci
1 replies
3h49m

I love little webtools like this that save state in the URL for easy sharing.

Bluestein
0 replies
3h32m

Indeed.-

(The URL as a tool. Such a great "innovation" too. URLs are wonderful ...)

fransjorden
1 replies
6h56m

This is really cool! As a big Tetris and typography fan this is such a novel combination, especially as they're all buildable in-game.

Bluestein
0 replies
6h52m

Quite the "rabbit hole", trying different texts, punctuation (sadly, none that I could produce, which - if you think about it, makes sense) ...

acidx
1 replies
3h29m

Reminds me of this sample from the Lwan project: https://time.lwan.ws/blocks -- where the clock is rendered on the server, and new frames are sent to the client using chunked encoding.

Bluestein
0 replies
1h25m

(Incidentally, great webserver ...)

PetitPrince
1 replies
4h26m

Related: One of the subniche in the Tetris communities is Tetris art / pattern creation, i.e. drawing predefined patterns while playing the game (almost) normally.

One of most practiced pattern is the chevron, where you draw a > shape with holes, but otherwise fill the whose board. This stemmed from the Japanese arcade version of Tetris by Sega (or Segatet for those in the known). This version was hugely popular in the arcade (it stayed for an incredibly 10 years in the top100 earner in some arcade magazine), and some player were destroying the game so much that they invented this challenge. This was recognized in Segatet successor Tetris the Grand Master (TGM3), and formally named "Secret Grade". One example here: https://www.youtube.com/watch?v=ZgzcAkjp0J8 , and another there with TGM3 signature speed https://www.youtube.com/watch?v=32wzKc0cHQU .

But in general, Shuey is the master of arbitrary making pattern. Look at him drawing a Luigi: https://www.youtube.com/watch?v=_tipJDjeKuY .

Note that since then, an algorithm for arbitrary pattern generation has been devised by Michael Birken: https://www.youtube.com/watch?v=PJkHwulsac4

(sort of related: the playing forever algorithm may be interpreted as a pattern creation https://tetris.wiki/Playing_forever )

mandibeet
0 replies
37m

It's so satisfying to watch...

throwitaway222
0 replies
3h36m

Perfect, maybe we can make HN use this font for a day exclusively.

thih9
0 replies
3h34m

I don't understand the limitation to use all of the pieces exactly once, I'd say the rule to keep valid Tetris moves only is enough. I'm curious what could be built with just that in place.

Right now I especially dislike letters: 'B', 'G', 'I', 'N'. For comparison, I like 'F' and '1', they both look very natural to me; 'A' and 'S' get a pass too. 'Q' gets a special mention for its long tail.

That being said, the project is super cool and looks great already.

tamimio
0 replies
2h58m

Cool, I wish there was a variations for the pieces for each letter though.

poopcat
0 replies
5h21m

I have to admit I did not know where it was going at first but was thoroughly delighted once it finished stacking up haha

nothingneko
0 replies
1h25m

i was interested to see how it would render kanji, probably is harder than i think

muth02446
0 replies
6h16m

I worked on a similar project here:

https://github.com/robertmuth/TetrisScroller

It has a pretty much complete ascii font but I am cheating in that I allow one non tetris piece with only 3 pixels arranged as an angle. There is also a simple tool that tries to find a covering of a given font.

mdrzn
0 replies
6h40m

Very cool!

legohead
0 replies
2h14m

Feels like there should be many ways to make a particular letter, and it'd be neat if it was random each time. I tried "Hello" and noticed the L's are the same. Considering it's just for fun I think it'd add a little more fun if it was actually unique letters.

Also, can we get a checkbox for "pause after animation"? I want to take a minute to check out the letters before it starts animating again. I know you can click off Animate after it finishes, but if I share this, others may not be so keen.

gnanasekaran08
0 replies
42m

Nice..

bpiroman
0 replies
5h50m

Excellent!!

andrei-akopian
0 replies
6h33m

From a programming perspective, it would have been cooler if the font generation was automatic at the cost of a bit of quality. This might have allowed for more interesting variation, lowercase, and support of other symbols.

There is nothing less anoying than seeing a really custom font repeat a letter.

Bluestein
0 replies
7h14m

The author explains:

"Each letter and digit in this typeface is made up of exactly one of each of the Tetris pieces: (I), (J), (L), (O), (S), (T), and (Z). Furthermore, the letter is designed so that it can actually be constructed by stacking these pieces one at a time and be supported by previous pieces, as in Tetris. These designs were found by hand, aided by the BurrTools software which enabled searching for whether the Tetris pieces could fit inside a candidate outline for a letter. The piece colors roughly follow The Tetris Company's standard colors, or you can switch to black pieces. The initial rotations follow the standard Super Rotation System."