Skip to content

Commit 9f019bc

Browse files
claude: Fix remote fonts not recognised in brand extensions (#13685)
When a brand.yml file with remote font URLs (e.g., https://...) is located in a subfolder (like _extensions/my-brand/), the font URL was incorrectly joined with the path prefix, resulting in broken paths like "_extensions/my-brand/https:/...". Add isExternalPath helper to detect URLs and skip path joining for external font paths. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2327cec commit 9f019bc

6 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/core/sass/brand.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ const googleFontImportString = (description: BrandFontGoogle) => {
150150
}:${styleString}wght@${weights}&display=${display}');`;
151151
};
152152

153+
const isExternalPath = (path: string) => /^\w+:/.test(path);
154+
153155
const fileFontImportString = (brand: Brand, description: BrandFontFile) => {
154156
const pathPrefix = relative(brand.projectDir, brand.brandDir);
155157
const parts = [];
@@ -162,9 +164,12 @@ const fileFontImportString = (brand: Brand, description: BrandFontFile) => {
162164
weight = file.weight;
163165
style = file.style;
164166
}
167+
const fontUrl = isExternalPath(path)
168+
? path
169+
: join(pathPrefix, path).replace(/\\/g, "/");
165170
parts.push(`@font-face {
166171
font-family: '${description.family}';
167-
src: url('${join(pathPrefix, path).replace(/\\/g, "/")}');
172+
src: url('${fontUrl}');
168173
font-weight: ${weight || "normal"};
169174
font-style: ${style || "normal"};
170175
}\n`);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
**/*.quarto_ipynb
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: My Brand
2+
author: Quarto
3+
version: 1.0.0
4+
quarto-required: ">=99.9.0"
5+
contributes:
6+
metadata:
7+
project:
8+
brand: mybrand.yml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
typography:
2+
fonts:
3+
- family: Noto Sans
4+
source: file
5+
files:
6+
- path: https://notofonts.github.io/latin-greek-cyrillic/fonts/NotoSans/unhinted/ttf/NotoSans-Regular.ttf
7+
base:
8+
family: Noto Sans
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project:
2+
type: default
3+
format:
4+
html:
5+
theme: brand
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Remote Font Extension Test
3+
_quarto:
4+
tests:
5+
html:
6+
ensureCssRegexMatches:
7+
- ['src:url\("https://notofonts\.github\.io/']
8+
- ['_extensions/my-brand/https:']
9+
---
10+
11+
# Remote Font Test
12+
13+
This document tests that remote font URLs in brand extensions are handled correctly (issue #13685).
14+
15+
{{< lipsum 1 >}}

0 commit comments

Comments
 (0)