Skip to content

Support font-style: oblique <angle> - #206

Merged
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/font-style-oblique-angle
Jul 23, 2026
Merged

Support font-style: oblique <angle>#206
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/font-style-oblique-angle

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Feature

font-style accepts an optional angle after oblique (CSS Fonts 4 §2.4):

font-style: oblique 14deg;
font-style: oblique -10deg;

FontStyleConverter accepted only the plain keywords (normal/italic/oblique), so any oblique <angle> was rejected.

Implementation

Compose the keyword map with a StartsWithValueConverter matching oblique followed by an <angle>.

The angle is deliberately not Option()-wrapped: StartsWithValueConverter treats a non-null wrapped result as "matched", and an Option() converter never returns null — so every other font-style value (plain keywords, absent) would then falsely reconstruct as oblique when the font shorthand is re-serialized from its longhands. A regression test pins this.

Dependency

Reconstructing an omitted font-style longhand (e.g. from font: bold 12px serif) runs this converter on empty input, which throws a NullReferenceException on master. This branch includes the one-line fix for that, also submitted standalone as "Return null from StartsWithValueConverter on empty input" (#196). If that merges first, this rebases cleanly; if not, it's self-contained.

Tests

  • 4 legal oblique <angle> values (deg, negative, zero, grad)
  • 3 illegal (oblique 14px, italic 14deg, bare 14deg)
  • a regression test that font: bold 12px serif re-serializes without throwing and without a spurious oblique

The full suite (1263 existing tests) stays green, and all seven target frameworks build with no new warnings.

font-style accepts an optional angle after oblique (CSS Fonts 4 2.4),
e.g. "oblique 14deg". FontStyleConverter only accepted the plain
keywords, so any oblique-with-angle value was rejected.

Compose the keyword map with a StartsWithValueConverter that matches
"oblique" followed by an <angle>. It is deliberately not Option()-wrapped
around the angle: StartsWithValueConverter treats a non-null wrapped
result as "matched", and an Option() converter never returns null, which
would make every other font-style value reconstruct as "oblique" when
the font shorthand is re-serialized from its longhands.

Includes the StartsWithValueConverter empty-input fix (also submitted
standalone as the "Return null from StartsWithValueConverter on empty
input" PR): reconstructing an omitted font-style longhand runs this
converter on empty input, which previously threw. If that PR merges
first, this rebases cleanly.
@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 22:44
@TylerBrinks
TylerBrinks merged commit de14d35 into TylerBrinks:master Jul 23, 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.

2 participants