Skip to content

fix: handle font-stretch returned by font providers#345

Open
florian-lefebvre wants to merge 4 commits intomainfrom
fix/font-stretch
Open

fix: handle font-stretch returned by font providers#345
florian-lefebvre wants to merge 4 commits intomainfrom
fix/font-stretch

Conversation

@florian-lefebvre
Copy link
Collaborator

@florian-lefebvre florian-lefebvre commented Mar 13, 2026

It was reported on Astro's discord that the following would not have impact on the font stretch when it should:

{
  name: 'Archivo',
  cssVariable: '--font-archivo',
  provider: fontProviders.google(),
  weights: ["100 900"],
  styles: ["normal"],
  options: {
    experimental: {
      variableAxis: {
        wdth: ["110"]
      }
    }
  }
}

Turns out font-stretch wasn't covered

Summary by CodeRabbit

  • New Features

    • Added support for the CSS font-stretch property, including percentage values (e.g., "110%"), exposed in parsed font metadata.
  • Tests

    • Added/updated tests and provider snapshots to cover font-stretch parsing and ensure serialized font data includes the new stretch field.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd09ca7a-564c-41f1-8289-6ab7c9e6e85d

📥 Commits

Reviewing files that changed from the base of the PR and between fefa69f and 81bd3d1.

📒 Files selected for processing (2)
  • src/css/parse.ts
  • test/extract.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/css/parse.ts
  • test/extract.test.ts

📝 Walkthrough

Walkthrough

Added parsing support for CSS font-stretch (including percentage values) into FontFaceData.stretch. Parser extraction now maps font-stretch to stretch and preserves Percentage nodes; tests and provider snapshots updated accordingly.

Changes

Cohort / File(s) Summary
Parser & Types
src/css/parse.ts, src/types
Added 'font-stretch': 'stretch' to extraction map and extended value extraction to include Percentage nodes; FontFaceData gained stretch property.
Unit Tests
test/extract.test.ts
Added tests asserting percentage font-stretch values (e.g., "110%") are parsed into stretch.
Provider Snapshot
test/providers/adobe.test.ts
Updated snapshots to include stretch: "normal" in Adobe provider font metadata entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • danielroe

Poem

🐰 I nibble code and sniff the rest,
A tiny percent within my chest.
font-stretch now hops into the light,
Parsed and neat — a rabbit's delight! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for handling font-stretch values returned by font providers, which is the core objective of this PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/font-stretch
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/css/parse.ts`:
- Around line 134-136: The Percentage branch is pushing percents directly into
values causing arrays like ["50%","200%"] instead of a space-joined string;
update the Percentage handling in the same function (the child.type ===
'Percentage' case) to append the formatted percent (e.g. `${child.value}%`) into
the existing buffer (the same pattern used for Dimension handling) rather than
calling values.push, so that subsequent buffer flushing produces a single
space-separated string (matching the stretch?: string type in src/types.ts).

In `@test/extract.test.ts`:
- Around line 208-230: The test uses a quoted percentage which css-tree parses
as a String, so the new Percentage handling path in parse.ts isn't exercised;
update the test in extract.test.ts to use an unquoted percentage (e.g.,
font-stretch: 110%) so that extractFontFaceData(...) triggers the Percentage
node branch in parse.ts (the code handling Percentage values) and the snapshot
reflects the parsed "110%" stretch value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 401aa789-cb90-4b10-ba9a-0a4787b86110

📥 Commits

Reviewing files that changed from the base of the PR and between 8f7c1ee and fefa69f.

📒 Files selected for processing (3)
  • src/css/parse.ts
  • test/extract.test.ts
  • test/providers/adobe.test.ts

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (8f7c1ee) to head (37352f1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #345   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files          12       12           
  Lines         660      662    +2     
  Branches      172      173    +1     
=======================================
+ Hits          649      651    +2     
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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