Skip to content

Recipe font weights (font-semibold, font-bold, …) all render the same: only Inter Regular is registered #91

Open

Description

@jhuesos

What I was trying to do

Use different Inter weights in a recipe, e.g. font-inter font-semibold for headings and font-inter font-bold for numbers.

What I expected

Distinct weights in the rendered PNG (Medium 500, SemiBold 600, Bold 700, …).

What actually happened

Every weight above Regular gives the same synthesized ("fake") bold. With Takumi 1.8.7, rendering the same text at fontWeight 500, 600 and 700 gives byte-identical PNGs (same hash). After registering a real file for each Inter weight, 100–900 give 9 distinct outputs. Lighter weights (font-thin, font-light) can't render at all, so they fall back to Regular.

Steps to reproduce

  1. Create a recipe with three lines: <p className="font-inter">Regular</p>, <p className="font-inter font-semibold">SemiBold</p>, <p className="font-inter font-bold">Bold</p>.
  2. Render it: /api/bitmap/<slug>.png?width=800&height=480.
  3. The SemiBold and Bold lines are identical, both synthesized bold.

Environment

  • byos_next main @ 2511a20, Docker dev (Node 22.22.3), Linux
  • @takumi-rs/core 1.8.7
  • Devices: Seeed reTerminal E1001 (mono) and E1002 (Spectra 6)

Root cause

  • public/fonts/ contains only Inter_18pt-Regular.ttf.
  • lib/fonts.ts → getTakumiFonts() registers every font with const weight = 400, so Takumi and Satori have no real face for other weights and synthesize them.
  • The inter localFont(...) export only declares weight 400, so the browser preview fakes the weights too.

The Tailwind side already works: PreSatori passes the classes to Takumi's tw prop, which turns font-semibold into fontWeight: 600. Only the font files and their registration are missing.

Suggested fix

  • Add the static Inter files Inter_18pt-{Thin,ExtraLight,Light,Medium,SemiBold,Bold,ExtraBold,Black}.ttf. They come from the same Google Fonts "Inter" v4.001 download as the existing Regular, whose sha256 matches. Add the Inter OFL licence next to them.
  • Register each file under the name inter with its own weight. Takumi accepts several entries with the same name and different weights.
  • Declare the same files in localFont({ src: [{ path, weight, style }, …] }) so the preview matches the PNG.

I'm running this as a local override and it works on both devices. Open PR #80 reworks lib/fonts.ts into lib/font-sources.json, so this probably fits best there or right after it: one source entry per Inter weight. I'm happy to send a PR once it's clear which base you'd prefer.

Side note: extractFontFamily takes the first font-* class as the family, so font-semibold font-inter picks the wrong family. Recipes have to write font-inter font-semibold.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions