Skip to content

Fix swapped larger/smaller entries in Map.FontSizes - #194

Merged
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:bugfix/font-size-larger-smaller-swap
Jul 23, 2026
Merged

Fix swapped larger/smaller entries in Map.FontSizes#194
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:bugfix/font-size-larger-smaller-swap

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Problem

Map.FontSizes has the two relative keywords crossed:

{Keywords.Larger, FontSize.Smaller},
{Keywords.Smaller, FontSize.Larger}

ValueExtensions.ToLength resolves FontSize.Larger to 120% and FontSize.Smaller to 80%, so larger resolves to the shrink factor and smaller to the grow factor — the opposite of CSS 2.1 §15.7 / CSS Fonts 3 §3.5.

Scope

The defect is latent today. DictionaryValueConverter looks the identifier up with TryGetValue(identifier, out _) and keeps only the key, discarding the mapped FontSize entirely, and Map.FontSizes has no other consumer. So nothing currently reads these values — but the table is wrong, and it becomes live the moment anything does.

Because of that, the fix is not observable through the property API. The tests therefore assert the mapping directly (the test assembly already has InternalsVisibleTo), which is what actually pins the intent:

Assert.Equal(FontSize.Larger, Map.FontSizes["larger"]);

var length = Map.FontSizes["larger"].ToLength();
Assert.Equal(Length.Unit.Percent, length.Type);
Assert.Equal(120f, length.Value);

Plus two round-trip tests confirming both keywords still parse as font-size values, so the table change doesn't disturb the converter path.

2 of the 4 fail on master. The full suite (1263 existing tests) stays green, and all seven target frameworks build with no new warnings.

Map.FontSizes mapped the keyword "larger" to FontSize.Smaller and
"smaller" to FontSize.Larger. ValueExtensions.ToLength resolves
FontSize.Larger to 120% and FontSize.Smaller to 80%, so the two relative
font-size keywords resolved to each other's scale factor.

The defect is currently latent: DictionaryValueConverter looks the
identifier up with "TryGetValue(identifier, out _)" and keeps only the
key, so nothing reads these values today. It becomes live the moment
anything does.

Tests assert the keyword-to-enum mapping and its composition with
ToLength directly, plus that both keywords still parse and round-trip
through font-size.
@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 21:26
@jhaygood86
jhaygood86 marked this pull request as draft July 22, 2026 21:40
@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 21:44
@TylerBrinks
TylerBrinks merged commit fa99b3b 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