Skip to content

fix: unquote font family names in webfont provider URLs - #2749

Open
giaBaoJS wants to merge 1 commit into
slidevjs:mainfrom
giaBaoJS:fix/webfont-url-quoted-family
Open

giaBaoJS wants to merge 1 commit into
slidevjs:mainfrom
giaBaoJS:fix/webfont-url-quoted-family

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

A font family written with CSS-style quotes ends up in the webfont CDN URL as a bare quote character, so the stylesheet request fails.

generateFontParams (packages/slidev/node/utils.ts:78) runs i.replace(/^(['"])(.*)\1$/, '$1'). Group 1 is the quote, group 2 is the name. Replacing with $1 collapses the whole family down to a single ".

Repro headmatter:

fonts:
  sans: '"Helvetica Neue", Roboto'

resolveFonts keeps the token verbatim in webfonts, and the emitted link is https://fonts.googleapis.com/css2?family=":wght@200;400;600&family=Roboto:.... I ran both against the real API: that URL returns 400, family=Helvetica+Neue:wght@200;400;600&display=swap returns 200 with the @font-face block. The CSS2 API docs write the spec as family=<name> with + for spaces (family=Crimson+Pro); no quoting.

Quoting is an expected input shape here: resolveFonts.toQuoted (packages/parser/src/config.ts:174) tests the same pattern to avoid double-quoting a name in the CSS font-family. So the CSS side handles quoted names and the URL side destroys them.

One-character fix, plus a case in test/utils.test.ts covering both quote styles. Existing snapshots are unchanged, since unquoted names never matched the pattern.

Out of scope, same area: config.ts:171 filters webfonts with !local.includes(i) on raw strings, so sans: '"Fira Code"' with local: Fira Code still fetches from the CDN. That one changes the matching semantics of a documented option, so I left it alone.

generateFontParams replaced a quoted family name with capture group 1, the
quote character itself, so `fonts: { sans: '"Helvetica Neue", Roboto' }`
emitted `family="` and Google Fonts answered 400. Use group 2, the name.
@netlify

netlify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 6cfd9fe
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6ab10e3298aae300089b798e
😎 Deploy Preview https://deploy-preview-2749--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2749

create-slidev

npm i https://pkg.pr.new/create-slidev@2749

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2749

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2749

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2749

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2749

commit: 6cfd9fe

This branch has not been deployed

No deployments
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