Litherum

litherum.blogspot.com · Personal blog · on HN since 2019

Litherum is a graphics and text-rendering engineer's blog covering fonts, WebKit text layout, and GPU programming models.

What HN saysHN commenters cite its Addition Font post as proof that OpenType shaping is Turing-complete, since contextual substitution lookups can recurse by referencing their own table.
17HN people shared it
11linked it in comments
6stories submitted
261story points
2 years agolast shared
2019people per year2026

Most-shared posts

  1. 1
    Addition Font
    13 people · 217 points · first shared 2019 · 18 comments on HN
  2. 2
    End-to-End Tour of Text Layout/Rendering (2015)
    1 people · 43 points · first shared 2024 · 4 comments on HN
  3. 3
    Implementing a GPU's Programming Model on a CPU
    1 people · 1 points · first shared 2023 · discussion on HN
  4. 4
    Complex text handling in webkit part 3
    1 people · first shared 2024
  5. 5
    Complex text handling in webkit part 3
    1 people · first shared 2024
  6. 6
    Complex text handling in webkit part 5
    1 people · first shared 2024
  7. 7
    Complex text handling in webkit part 7
    1 people · first shared 2024
  8. 8
    Knuth plass line breaking algorithm
    1 people · first shared 2022
  9. 9
    Complex text handling in webkit part 2
    1 people · first shared 2024
  10. 10
    Complex text handling in webkit part 1
    1 people · first shared 2024
  11. 11
    Complex text handling in webkit part 5 22
    1 people · first shared 2024

What HN people wrote when they linked it

mananaysiempre · 2022-11-15
(Not a language or Unicode expert, the following likely has important mistakes.) > Off the top of my head, I don't know of a terminal that actually implements the entire (very complex) set of Unicode text rendering behaviors There are at least two reasons for this: First, nobody actually seems to know how bidirectional text should interact with terminal control sequences, or indeed how it should be typeset on a terminal in the first place (what is the primary direction? where are the reordering boundaries?). There is the pre-Unicode bidirectional support mode (BDSM, I kid you not) in ECMA-48[1] and TR/53[2], which AFAIK nobody implements nor cares about; there are terminal emulators endorsed by bidi-language users[3], which AFAIK nobody has written down the behaviour of; there is the Freedesktop bidi terminal spec[4], which is a draft and AFAIK nobody implements yet either but at least some people care about; finally, there are bidi-language users who say that spec is a mistake[5]. Second, aside from bidi and a smattering of other things such as emoji, there is no detailed “Unicode text rendering behaviour”, only standards specific to font formats—the most recent among them being OpenType, which is dubiously compatible across implementations, decently documented only through painstaking reverse engineering (sometimes in words[6], sometimes only in Freetype library code), and generally full of snakes[7]. And it has no notion of a monospace font—only of a (proportional)…
layer8 · 2025-04-05
Given that the OpenType font format is Turing-complete [0], I would challenge the “without code” claim. ;) [0] https://litherum.blogspot.com/2019/03/addition-font.html
cmyr · 2023-07-10
Hinting might be a red herring here: these font formats are unsafe almost by design, since they consistently rely on a pattern of reading a value out of a chunk of memory and then treating that value as a pointer offset where additional values are read. The proposed WASM shaping implementation would be a replacement for traditional OpenType layout[1] which is already turing complete[2]), and in this sense using WASM is significantly safer than the alternative. Your comment suggests that "execution of arbitrary WASM code" is something that we should be scared of, but the entire point of WASM is that it allows for safe/isolated compilation of arbitrary code. [1] https://simoncozens.github.io/fonts-and-layout/features.html [2] https://litherum.blogspot.com/2019/03/addition-font.html
epilys · 2023-05-26
OpenType is basically turing-complete via glyph shaping. There's an explanation here: https://litherum.blogspot.com/2019/03/addition-font.html
CharlesW · 2022-09-14
https://litherum.blogspot.com/2019/03/addition-font.html "So this is pretty cool, but it turns out that the contextual substitution lookup type is really powerful. This is because the table that it references can be itself, which means it can be recursive." […] "So thats a pretty powerful virtual machine. I think the above is sufficient to prove Turing complete-ness."
gwern · 2022-05-09
You may not have an explicit rand(), but with the ligatures & substitution rules, you can add so much context sensitivity that no one will ever spot any duplications. That's how you can do things like https://litherum.blogspot.com/2019/03/addition-font.html https://pagedout.institute/download/PagedOut_002_beta2.pdf#page=42 https://aftertheflood.com/journal/the-worlds-first-code-free-sparkline… https://www.coderelay.io/fontemon.html (most of these will work in a browser). I've also suggested that you can create 'prank fonts' which add in subtle typos sporadically. Less evilly, this is what calligraphy handwriting fonts do to get convincing variation.
MikeDelta · 2022-04-29
I think that is thanks to the Knuth-Plass algorithm, with Knuth being the inventor of Tex, which powers Latex. The problem seems not trivial indeed. http://www.eprg.org/G53DOC/pdfs/knuth-plass-breaking.pdf https://tex.stackexchange.com/questions/230668/any-progress-on-knuth-p… http://litherum.blogspot.com/2015/07/knuth-plass-line-breaking-algorit…
zuminator · 2019-04-10
Fonts are not like photos, they have hinting and kerning and conditional code that distinguishes a high quality font from crap. The glyph substitution table in OpenType fonts is of such complexity that it's been shown to be Turing complete. [https://litherum.blogspot.com/2019/03/addition-font.html]
frivoal · 2021-03-16
I suspect the opposite situation is what you run into: it is possible to write programs that are valid and out to be accepted by the type system, but get rejected because you blew the stack of the type checker. Had the type checker been allocated more memory / time, it could have accepted the program, but it crashed before that. This reminds me of that: http://litherum.blogspot.com/2019/03/addition-font.html You can craft font files that perform arbitrary calculations… if you give the font shaping engine a (practically) unlimited stack, where it usually limits recursion to 6 levels. If you do so, you can make a font that does math (or whatever you want) as part of computing ligatures. But in practice, you hardly ever hit those kinds of limits unless you're trying to do something silly on purpose. Sure you cannot port Doom to font substitution lookup tables, despite them being Turing complete. But that doesn't make your font shaping engine useless, or even broken.
favorited · 2024-11-18
I really enjoyed this author's "Complex Text Handling in WebKit" series from a few years back. They're spread over several months on the blog, so here are the direct links to each part, if anyone is interested: Part 1: Encoding Systems, Code Points, and Code Units <https://litherum.blogspot.com/2013/11/complex-text-handling-in-webkit-… Part 2: Fonts <https://litherum.blogspot.com/2013/11/complex-text-handling-in-webkit-… Part 3: Codepoint to Glyph Mapping <https://litherum.blogspot.com/2014/02/complex-text-handling-in-webkit-… Part 4: Line Breaking <https://litherum.blogspot.com/2014/04/complex-text-handling-in-webkit-… Part 5: Bidirectional Processing <https://litherum.blogspot.com/2014/11/complex-text-handling-in-webkit-… Part 6: Run Layout <https://litherum.blogspot.com/2014/11/complex-text-handling-in-webkit-… Part 7: Width Calculations <https://litherum.blogspot.com/2014/11/complex-text-handling-in-webkit-…

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close