Skip to content

Add CSS font-palette longhand and @font-palette-values at-rule#220

Open
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/font-palette
Open

Add CSS font-palette longhand and @font-palette-values at-rule#220
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/font-palette

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Summary

Adds parsing for CSS font-palette and the @font-palette-values at-rule (CSS Fonts 4):

  • font-palette longhand (inherited), accepting normal | light | dark | <dashed-ident>.
  • @font-palette-values --name { … } at-rule (FontPaletteValuesRule / public IFontPaletteValuesRule), modeled on the existing @property rule, capturing the font-family, base-palette, and override-colors descriptors (stored raw).

Adds the FontPalette/BasePalette/OverrideColors property names, the FontPaletteValues rule name/type, factory registration, and a StylesheetComposer.CreateFontPaletteValues dispatch.

Scope note: palette-mix() is intentionally not included — it depends on the CSS Color 4/5 <color-interpolation-method> grammar (a separate PR); the font-palette converter accepts only keyword/<dashed-ident> values here. It can be added as a follow-up once the color-4/5 grammar lands.

Tests

FontPaletteTests — 15 cases: keyword/dashed-ident acceptance, invalid-value dropping, round-trips, @font-palette-values name + descriptor capture, light/dark base-palette, exposure via the interface, and among-other-rules. Full suite green across all target frameworks.

Ported from PeachPDF, which vendors ExCSS.

Implements the parser/object-model half of CSS Fonts Module Level 4
font palette selection (https://www.w3.org/TR/css-fonts-4/#font-palette-values):

- font-palette longhand (inherited), validated as normal | light | dark |
  <dashed-ident>; the authored text is preserved verbatim.
- @font-palette-values at-rule, a named DeclarationRule modelled on @Property,
  capturing font-family / base-palette / override-colors descriptors raw.

palette-mix() is intentionally deferred: it depends on color-space grammar
not yet available in ExCSS, so the font-palette grammar accepts only the
keyword and dashed-ident forms for now.
@jhaygood86
jhaygood86 marked this pull request as ready for review July 24, 2026 20:01
@jhaygood86
jhaygood86 marked this pull request as draft July 24, 2026 20:35
@jhaygood86
jhaygood86 marked this pull request as ready for review July 24, 2026 20:35
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