Skip to content

Commit 5b46b50

Browse files
cscheidclaude
andcommitted
fix(revealjs): load default-theme Source Sans Pro via Google Fonts @import
The compiled Quarto reveal theme named `Source Sans Pro` in `--r-main-font` but loaded no font face, so `q2 render` fell back to Helvetica on any machine without Source Sans Pro installed — while `q2 preview` showed Source Sans Pro (reveal's vendored white.css embeds it as a base64 @font-face). Surfaced in end-to-end testing as "render points to the wrong fonts." Fix per user decision: load Source Sans Pro from the Google Fonts CDN with a foundry `@import` in the Quarto reveal layer's `scss:defaults`, mirroring the named themes (Lato/Ubuntu/…) and Quarto 1's `_brand.yml` font model — rather than bundling the font binaries. The render is intentionally not self-contained for fonts, matching Quarto 1's import-based approach. A theme or `_brand.yml` that sets a different `$font-family-sans-serif` supplies its own font and this import is then unused (harmless), exactly as in Quarto 1's quarto.scss. Sass hoists the CSS `@import url(...)` to the top of the compiled output (CSS requires `@import` first); a test asserts both the import's presence and that it precedes the first `.reveal` rule. E2E: `q2 render` + Chrome confirmed the Source Sans Pro 400 face loads and applies. Note: this fixes the render side only. The preview still shows reveal's stock white.css look (centered text, uppercase headings, its own SSP) because the q2-slides preview never applies the compiled Quarto reveal theme — full per-document preview parity is the larger follow-up (bd-y259zb57, Level 2). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ff31c8e commit 5b46b50

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

crates/quarto-sass/tests/integration/reveal_theme_test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ fn quarto_values_flow_into_custom_properties() {
8686
);
8787
}
8888

89+
#[test]
90+
fn default_theme_imports_source_sans_pro_from_google() {
91+
let css = compile(&assemble_reveal_scss(&[]).unwrap());
92+
// The default theme loads its named font (Source Sans Pro) via a Google
93+
// Fonts @import (Q1-style foundry import; no local bundling).
94+
assert!(
95+
css.contains("@import url(") && css.contains("Source+Sans+Pro"),
96+
"default theme should @import Source Sans Pro from Google Fonts\n{css}"
97+
);
98+
// CSS requires @import to precede normal rules — confirm it is hoisted
99+
// ahead of the first `.reveal` rule.
100+
let imp = css.find("@import").expect("@import present");
101+
if let Some(rule) = css.find(".reveal") {
102+
assert!(
103+
imp < rule,
104+
"@import must come before CSS rules (CSS requires @import first)"
105+
);
106+
}
107+
}
108+
89109
#[test]
90110
fn headings_are_not_uppercased() {
91111
let css = compile(&assemble_reveal_scss(&[]).unwrap());

resources/scss/revealjs/quarto-revealjs.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99

1010
/*-- scss:defaults --*/
1111

12+
// Default body/heading font. Quarto 1's default reveal theme ships Source Sans
13+
// Pro; we load it from the Google Fonts CDN (a foundry @import, like the named
14+
// themes and `_brand.yml` fonts) rather than bundling the binaries — so the
15+
// render is not self-contained for fonts by design, matching Quarto 1's
16+
// import-based font model. A theme or `_brand.yml` that sets a different
17+
// `$font-family-sans-serif` supplies (and loads) its own font; this import is
18+
// then unused (harmless), exactly as in Quarto 1's `quarto.scss`. Sass hoists
19+
// the CSS `@import url(...)` to the top of the compiled output (CSS requires it
20+
// first), so its placement here in `scss:defaults` is fine.
21+
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i);
22+
1223
// =============================================================================
1324
// Quarto's reveal.js layer (the Quarto-2 analogue of Quarto 1's quarto.scss).
1425
//

0 commit comments

Comments
 (0)