Zinewright

Blog

Why Our Phone Edition Is a Second Typeset, Not Responsive HTML

By Yuluo Han ·

A PDF magazine reads badly on a phone. Two A4 columns on a 6-inch screen mean zooming in, panning down one column, and panning back up to the next.

Zinewright turns manuscripts into page-through publications, so I had to fix this. The obvious answer was responsive HTML. I chose something that sounds worse: every issue is typeset twice, and phones get a stack of images.

This post explains why, how it works, and what it costs.

The options

Responsive HTML reader. Convert the manuscript to HTML and let the browser reflow it. Readers could choose font size and theme.

A button that makes a phone version. The author clicks it and spends one generation from their allowance.

A second typeset, made automatically. Run the same engine with a phone-sized page at publish time.

HTML is the right answer for most of the web, and it has real advantages here. I rejected it for two reasons.

First, it hands the layout to the reader's browser, and layout is what the product sells. An author's typeface, headings and footnote style disappear, and on a phone every issue starts to look like the same e-reader. Readers would get something closer to an e-book, while authors came for a publication.

Second, it means a second layout engine. Every setting added to the print templates would need an HTML twin, forever. For a one-person project, that alone is decisive.

I rejected the button because a phone edition shouldn't be something the author remembers to do. Most issues would never get one. Reader devices are the product's problem, not the author's.

One engine, one more page size

The phone edition is a branch in the same Typst template:

#let mobile = template == "mobile"
#let page-width = if mobile { 390pt } else if letter { 8.5in } else if magazine { 210mm } else { 148mm }
#let page-height = if mobile { 844pt } else if letter { 11in } else if magazine { 297mm } else { 210mm }

390×844 is a common iPhone viewport in CSS pixels. The exact points don't matter much, since every phone scales the page to its screen width. What matters is the ratio, and the measure it produces: about 45 Latin characters per line at the size below.

Type scales by a fixed factor of 1.55, rounded to half a point:

#let k(x) = if mobile { calc.round(x / 1pt * 3.1) / 2 * 1pt } else { x }

The default 11pt body becomes 17pt, roughly 17 CSS pixels on a 390-pixel-wide screen. Scaling from the author's chosen size means a larger-type issue stays larger on phones too.

The rest is a list of things that make sense on paper and not in a scroll:

On paper On a phone Why
Two columns One column The whole point
Running heads and page numbers None There are no pages to speak of while scrolling
Page numbers in the contents Titles only, as links Same reason
Each chapter opens on a new page Runs on after 1.5 lines of space A near-empty screen reads like a broken page
Footnotes at the bottom of the page Collected at the end of each chapter Narrow pages get cut up by notes

The footnote change is the only one with interesting code. Typst's footnote is replaced with a small state machine:

#let chapter-notes = state("chapter-notes", ())
#let note(body) = if mobile {
  chapter-notes.update(a => a + (body,))
  context super(str(chapter-notes.get().len()))
} else { footnote(body) }

At the end of each chapter, the template prints what's in the state and resets it. Desktop templates never take these branches, so their output doesn't change.

What happens at publish time

The phone edition isn't made for proofs. Proofing is a desktop job and would double the work on every small correction. It's made once, when the author publishes a version:

  1. The desktop edition goes live straight away. The link works.
  2. A background job runs the same pipeline with template: "mobile".
  3. When it finishes, the job adds an optional mobile field to the public manifest, with its pages and cover.
  4. The reader sees the field and uses it on phone-sized screens.

Until step 3, phone readers get the page-through view. If the job fails, the publication stays up, and the author can retry it. Authors never wait on it, and it doesn't count against their generation allowance.

Adding an optional field meant the manifest format didn't need a new version. Readers that don't know about it ignore it. Scroll view and page-through view share one URL, and a reader can switch between them.

What it costs

On a real Cloudflare container, with a manuscript of about 198,000 Chinese characters:

Edition Pages Time
Desktop 243 228 s
Phone 290 220 s

So phone generation takes about as long as the desktop run, and for long issues it's a few minutes of background work per published version. Phone pages render at 1080px wide, in a single WebP size.

Storage roughly doubles. A 1080px page at 2–3× device pixel ratio is sharp on a phone, and I wasn't willing to trade sharpness away. (Getting that sharpness right took a bug fix of its own.)

What I gave up

This design has real downsides.

Readers can't change the type size. With HTML they could. Pinch-zoom is the only option. For people with low vision, that's a meaningful loss.

Page images aren't text. A screen reader gets very little from them, and readers can't select or search the words. Typst has produced tagged PDFs by default since 0.14, and our exports carry those tags, but that only helps when an author offers the download. I consider this the weakest part of the design, and the first thing I'd revisit.

Finished PDFs don't get one. A second typeset needs the source text. An issue uploaded as a PDF keeps its original pages on phones, because Zinewright won't guess at the structure of someone else's layout.

Very image-led issues benefit less. The phone edition is good at running text. A full-bleed spread doesn't have a natural phone form.

If you were building a news site or documentation, I'd tell you to use HTML. The trade makes sense here because the thing being published is a designed object, and because one typesetting engine is all one developer can maintain.

You can open the sample's phone edition and compare it with the page-through version. If you've solved the accessibility half of this differently, I'd like to hear how: support@zinewright.com.