Skip to content

themes: support packaged fonts via validated font slots #48

Open

Description

@DarkLabsStudio

Summary

Themes can change fonts, but only to fonts already installed on the user's machine. A .theme package cannot ship a font: the sanitizer removes url() and @font-face, and quoted font names are stripped. This makes themes non-portable across systems.

Current behavior

  • pkg/theme/protected.go:70, :242-246 removes any url().
  • pkg/theme/protected.go:122-147 drops quoted strings, so font-family: "Inter" breaks; unquoted font-family: Inter works only if the font is installed.
  • pkg/theme/protected.go:322-339 only preserves @media and @supports at-rules, so @font-face does not survive.
  • docs/THEMES.md now documents the limitation (PR docs: correct stale server, permission, and theme documentation #44).

Proposed feature

Add a whitelisted font-slot system, modeled on the existing PNG asset overrides:

  • package.json:
    "fonts": {
      "ui": "fonts/Inter.woff2",
      "display": "fonts/Bahnschrift.woff2",
      "mono": "fonts/JetBrainsMono.woff2"
    },
    "fontLicense": "OFL-1.1"
  • Installer validation:
    • path contained in the package
    • magic bytes: wOF2, wOFF, OTTO, TrueType
    • 5 MiB per file / 20 MiB total
    • no remote or data: URLs
    • license required for Gallery submission
  • Runtime:
    • serve fonts through the existing local asset server
    • launcher generates @font-face rules and sets --font-ui / --font-display / --font-mono
    • url() remains banned in theme.css; only launcher-generated CSS contains URLs

Why this is safe

The theme never supplies a URL. The launcher generates a 127.0.0.1 URL for a validated, size-capped file inside the package. This keeps the #36 fix intact while making themes portable.

Related

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