← All devlogs

How do you fit a 180,000-word book into ten pages?

A devlog about Witch's Binder

Every book in Witch’s Binder is a real book. The pages you pick up off the witch’s floor come from old books that are now in the public domain: grimoires, herbals, dream dictionaries, books on tea-leaf reading, palmistry, the language of flowers… Most of them come from Project Gutenberg, and some from the Internet Archive. (They’re the heroes who make our cultural heritage accessible to all of us, and I really admire their labour of love.)

The trouble is that a real book is huge. The History of Magic by Éliphas Lévi, for example, is 180,000 words long. A book in the game is a front cover, a title page, nine pages of text and a back cover. So for every book I have to pick a piece of it that’s short enough to fit, still reads as part of a real book, and is nice to read when you zoom in on a page.

Doing that by hand for 40 books was going to be painful, especially since each book has its own font, and so a different word limit per page. So I used Claude to make a small Unity tool for it. It is called the Page Splitter, and looks like this:

The Page Splitter tool: a list of books on the left, The History of Magic split into coloured pages in the middle, and the book’s settings and page previews on the right

How it works

On the left is the list of books, Book001 to Book041. I download each one as a text file and keep its illustrations in a zip next to it.

In the middle is the whole book, paragraph by paragraph. I read and read until I find a good starting point, usually somewhere that doesn’t open in the middle of a thought, and press the ▶ next to that paragraph. From there the tool splits the text into pages and colours each page differently, so I can see exactly where page 2 ends and page 3 begins.

On the right are the settings for the book: title, author, category, font, ink colour, how the page numbers look and where they go, difficulty, and whether the book is damaged. These matter more than they look. In the game, the pages of one book all share the same paper, size, border, ink and font, and that’s how you tell which pages belong together. So these settings are the puzzle.

Under the settings there’s a word count for every page, with buttons to move a page’s end by a word or a sentence. When a page is too full the tool warns me that the text won’t fit. At the bottom are small previews of how the pages will actually look in the game.

Illustrations

If one of the book’s illustrations falls onto a page, I can tick “use this image” and it goes onto that page. In the screenshot, the pentagram from The History of Magic lands on page 6. Pages with pictures turned out to be some of the most fun to find on the floor, because you can spot them from across the room but usually don’t associate them with the rest of the book if the other pages are just text.

How do I choose?

What I look for in a passage is whether it gives a glimpse into the essence of the book. More than half the time, I pick passages from the introduction, because that’s usually where the author explains what they’re about to tell us. But sometimes I keep reading and find a part that’s a perfect example of the rest of the book.

The truth of the matter is that I wanted to make you wonder. These books aren’t very popular anymore and only a few people read them, but they’re weird and beautiful. So if I can make you want to peek into this bizarre corner of history, that feels like a little win to me :)