Skip to content

Type mode: style picker that sets weight class and italic flags - #24

Merged
srivtx merged 2 commits into
mainfrom
type-style-picker
Oct 24, 2026
Merged

srivtx merged 2 commits into
mainfrom
type-style-picker

Conversation

@srivtx

@srivtx srivtx commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Glitch or intentional?

A bit of both. Free text was on purpose: OpenType lets a style be called anything ("Display", "Condensed Bold"), and the field has been a plain input since 0.2. The gap was that nothing showed which styles exist, and the name was never checked or used for the font's flags:

  • Name table. The text went into the name table as given: name ID 2 for Regular, Bold, Italic and Bold Italic, otherwise IDs 16/17 with ID 2 forced to "Regular".
  • Weight and italic. usWeightClass came only from the look's Weight modifiers (400 when there were none). The bold and italic bits in fsSelection and macStyle came only from Weight and Slant.

So a font named "Bold" exported as weight 400, and one named "Italic" was flagged upright unless it slanted. Apps then grouped and style-linked it wrongly. The web kit's @font-face guessed the weight with a regex, so ExtraLight came out as 300 and ExtraBold as 700.

What changed

  • Style picker (Font tab → Base). It lists the nine standard weights, Thin 100 to Black 900, in an Upright column and an Italic column. "Custom name…" opens a text field for any other name. The current style shows its weight number, and the base font's own style is tagged "base".
  • The style drives the export. A standard style sends weightClass and the new italic flag to the engine, which sets usWeightClass, fsSelection, macStyle and STAT from them. An upright italic gets the italic bits too, and for an italic style that isn't Regular, Bold, Italic or Bold Italic, name ID 2 is now "Italic" instead of "Regular". A name the picker can't read, such as "Display", works as before: weight and slope come from the look.
  • Defaults and hints. A new font starts with its base font's style. Switching the base carries the style across if you hadn't changed it. When a Weight modifier makes the look a different weight from the chosen style, a hint suggests the closer style.
  • @font-face now uses the same mapping. The "Use font" dialog suggests the standard names.
  • Older projects open as before. Their style string is unchanged, and a custom name shows in the custom field. One behaviour change: a project named "Regular" whose look adds weight now exports as weight 400 to match its name. Before, it exported as 700 with the bold bit set while its name still said Regular.

Style picker: weights 100–900 in Upright and Italic columns, SemiBold Italic checked, Regular marked as the base

The app is dark-only (color-scheme: dark), so emulating a light scheme changes nothing. I checked it in dark.

Tests

  • fontStyles.test.ts: every standard style maps to its weight and italic flag and back; spellings like "Semi Bold", "Demibold", "Heavy Oblique" and "Hairline" are read; the look's weight; the specOf fields; @font-face.
  • Rust style_sets_weight_and_italic_flags: writes a Light Italic that doesn't slant and a Bold, then reads back the weight, fsSelection, macStyle and name IDs 1, 2 and 17.
  • npx tsc --noEmit -p ui, npx vitest run (134), npx vite build and cargo test all pass.

The screenshot is stored on the pr-assets/type-style-picker branch and can be deleted after review.

🤖 Generated with Claude Code

The font's Style was a bare text box: nothing listed the styles that
exist, and the name never reached usWeightClass, fsSelection or macStyle
(those came only from the look's Weight and Slant modifiers), so a font
named "Bold" exported as weight 400 and "Italic" as upright unless it
leaned.

- Style is now a picker: Thin to Black (100-900), upright and italic,
  plus "Custom name…" for anything else. The base font's own style is the
  default for a new font and is marked "base".
- A standard style sends its weight class and italic flag to the export;
  a custom name keeps the old behaviour (weight and slope from the look).
- The engine takes an optional italic flag, so an upright italic gets
  ITALIC in fsSelection/macStyle, and a non-RIBBI italic names ID 2
  "Italic" instead of "Regular".
- @font-face weight now reads ExtraLight as 200 and ExtraBold as 800.
- The Use font dialog suggests the standard names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
morphotype Ready Ready Preview Oct 24, 2026 11:08am UTC

@srivtx
srivtx merged commit 9ac3552 into main Oct 24, 2026
7 checks passed
@srivtx srivtx mentioned this pull request Oct 24, 2026
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