Um nicht die Schriften von bösen externen Servern zu laden, musste ich mal wieder eine weile Suchen. Ist ja für einen guten Zweck. GDPR und so…

Hier nur die snippets. Alles Beispiel.

quarto.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
project:
  type: website
  ...
  resources:
    - assets/fonts/*
...
format:
  html:
    theme:
      light: [cosmo, styles.scss]
      dark: [darkly, styles.scss]

Die Schriften liegen in assets/fonts. Bitte selbst generieren im “google-webfonts-helper”. Hier “Source Sans”:

styles.scss

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

/*-- scss:defaults --*/

// custom fonts
$web-font-path: 'dummy.css';
$font-family-sans-serif: 'Source Sans 3', Helvetica, sans-serif;
$font-family-monospace: Menlo, monospace;


/*-- scss:rules --*/

/* FONTS */

/* source-sans-3-300 - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 300;
    src: url('assets/fonts/source-sans-3-v18-latin-300.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* source-sans-3-300italic - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: italic;
    font-weight: 300;
    src: url('assets/fonts/source-sans-3-v18-latin-300italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* source-sans-3-regular - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 400;
    src: url('assets/fonts/source-sans-3-v18-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* source-sans-3-italic - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: italic;
    font-weight: 400;
    src: url('assets/fonts/source-sans-3-v18-latin-italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* source-sans-3-700 - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 700;
    src: url('assets/fonts/source-sans-3-v18-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* source-sans-3-700italic - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Source Sans 3';
    font-style: italic;
    font-weight: 700;
    src: url('assets/fonts/source-sans-3-v18-latin-700italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

Quarto lädt immer die “$web-font-path”, und damit kein file-not-found in der Browser console erscheint, nun noch eine /dummy.css:

dummy.css

1
/* dummy */

Fertig.