Skip to content

Support locked named variable-font instances - #300

Draft
kavya-oai wants to merge 1 commit into
samizdatco:mainfrom
kavya-oai:codex/locked-named-font-instances
Draft

Support locked named variable-font instances#300
kavya-oai wants to merge 1 commit into
samizdatco:mainfrom
kavya-oai:codex/locked-named-font-instances

Conversation

@kavya-oai

Copy link
Copy Markdown

What changed

  • allow FontLibrary.use() sources to select a one-based OpenType fvar named instance
  • pass that selection through Skia's collection-index convention
  • keep explicitly selected instances locked instead of re-instancing them from later CSS weight requests
  • report only the selected instance's actual weight from FontLibrary.family()

Why

Some variable fonts use multiple axes for a named face, such as optical size plus weight. Registering the variable file and later selecting only wght loses the named instance's other coordinates. This makes it impossible to register a face such as { opsz: 14, wght: 300 } faithfully.

The new API is additive:

FontLibrary.use("Example Light", {
  path: "/path/to/variable-font.ttf",
  namedInstance: 3,
})

Existing string-path registration is unchanged.

Validation

  • npm test — 142 tests passed
  • added coverage comparing a locked Raleway Light named instance with its static Light face across requested weights 300, 400, and 700
  • manually verified a two-axis { opsz: 14, wght: 300 } named instance retains identical metrics when the caller requests other CSS weights

@kavya-oai
kavya-oai force-pushed the codex/locked-named-font-instances branch from cdfe38d to b172b49 Compare August 17, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant