@gjsify/adwaita-fonts 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/400-italic.css +6 -2
- package/400.css +6 -2
- package/README.md +32 -7
- package/index.css +6 -0
- package/index.d.ts +7 -2
- package/lib/esm/embedded.js +34 -0
- package/lib/types/embedded.d.ts +23 -0
- package/package.json +12 -2
package/400-italic.css
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
/* Adwaita Sans —
|
|
1
|
+
/* Adwaita Sans — italic. Named `400` for the fontsource-style layout and because
|
|
2
|
+
that is the upstream file name; the TTF is a VARIABLE font (`fvar`: wght
|
|
3
|
+
100-900, opsz 14-32), so the face is declared over the whole range. Pinning
|
|
4
|
+
`font-weight: 400` here makes the engine synthesise every bolder weight —
|
|
5
|
+
measured, 700 and 800 came out pixel-identical. */
|
|
2
6
|
/* Source: refs/adwaita-fonts (SIL OFL 1.1, GNOME contributors) */
|
|
3
7
|
@font-face {
|
|
4
8
|
font-family: 'Adwaita Sans';
|
|
5
9
|
font-style: italic;
|
|
6
10
|
font-display: swap;
|
|
7
|
-
font-weight:
|
|
11
|
+
font-weight: 100 900;
|
|
8
12
|
src: url('./files/adwaita-sans-400-italic.ttf') format('truetype');
|
|
9
13
|
}
|
package/400.css
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
/* Adwaita Sans —
|
|
1
|
+
/* Adwaita Sans — normal. Named `400` for the fontsource-style layout and because
|
|
2
|
+
that is the upstream file name; the TTF is a VARIABLE font (`fvar`: wght
|
|
3
|
+
100-900, opsz 14-32), so the face is declared over the whole range. Pinning
|
|
4
|
+
`font-weight: 400` here makes the engine synthesise every bolder weight —
|
|
5
|
+
measured, 700 and 800 came out pixel-identical. */
|
|
2
6
|
/* Source: refs/adwaita-fonts (SIL OFL 1.1, GNOME contributors) */
|
|
3
7
|
@font-face {
|
|
4
8
|
font-family: 'Adwaita Sans';
|
|
5
9
|
font-style: normal;
|
|
6
10
|
font-display: swap;
|
|
7
|
-
font-weight:
|
|
11
|
+
font-weight: 100 900;
|
|
8
12
|
src: url('./files/adwaita-sans-400.ttf') format('truetype');
|
|
9
13
|
}
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @gjsify/adwaita-fonts
|
|
2
2
|
|
|
3
|
-
Adwaita Sans TTF font files plus `@font-face` CSS (fontsource-style) for browser builds. Carries the GNOME/Libadwaita typographic identity to the web, sourced from the upstream Adwaita fonts project.
|
|
3
|
+
Adwaita **Sans** TTF font files plus `@font-face` CSS (fontsource-style) for browser builds. Carries the GNOME/Libadwaita typographic identity to the web, sourced from the upstream Adwaita fonts project.
|
|
4
|
+
|
|
5
|
+
Two faces ship: `adwaita-sans-400.ttf` (normal) and `adwaita-sans-400-italic.ttf` (italic). **No Adwaita Mono** — the upstream mono faces are 1.4–1.5 MB each and are not vendored here, so a `font-family: 'Adwaita Mono', …` stack resolves through this package only on a host where the typeface is installed system-wide (GNOME desktops, `adwaita-mono-fonts` on Fedora).
|
|
4
6
|
|
|
5
7
|
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
8
|
|
|
@@ -17,22 +19,45 @@ yarn add @gjsify/adwaita-fonts
|
|
|
17
19
|
## Usage
|
|
18
20
|
|
|
19
21
|
```css
|
|
20
|
-
/*
|
|
22
|
+
/* Both faces — the same two `./embedded` carries */
|
|
21
23
|
@import '@gjsify/adwaita-fonts';
|
|
22
24
|
|
|
23
|
-
/* Or
|
|
25
|
+
/* Or one face at a time */
|
|
24
26
|
@import '@gjsify/adwaita-fonts/400.css';
|
|
25
27
|
@import '@gjsify/adwaita-fonts/400-italic.css';
|
|
26
28
|
```
|
|
27
29
|
|
|
30
|
+
Both TTFs are **variable** fonts (`fvar`: `wght 100-900`, `opsz 14-32`) despite
|
|
31
|
+
the `400` in their upstream names, so each `@font-face` declares
|
|
32
|
+
`font-weight: 100 900`. Pinning a single weight makes the browser synthesise
|
|
33
|
+
every bolder one — measured in Firefox, 700 and 800 then render pixel-identical.
|
|
34
|
+
|
|
35
|
+
Both forms above resolve `src: url('./files/adwaita-sans-400.ttf')` through the consuming CSS pipeline, which emits the TTF as an asset and serves it. That is the default and it is correct wherever such a pipeline exists — Vite, webpack, a plain `<link>`.
|
|
36
|
+
|
|
37
|
+
### From JavaScript — use `./embedded`, never a side-effect import
|
|
38
|
+
|
|
28
39
|
```typescript
|
|
29
|
-
|
|
30
|
-
import '@gjsify/adwaita-fonts';
|
|
40
|
+
import { applyAdwaitaFonts } from '@gjsify/adwaita-fonts/embedded';
|
|
31
41
|
|
|
32
|
-
//
|
|
33
|
-
// font-family: 'Adwaita Sans', sans-serif;
|
|
42
|
+
applyAdwaitaFonts(); // idempotent; injects a <style> with both faces
|
|
34
43
|
```
|
|
35
44
|
|
|
45
|
+
**`import '@gjsify/adwaita-fonts';` from JavaScript does not register anything under a bundler that turns CSS into a string** — which includes `gjsify build --app browser` and `--app gjs`. The module it produces is `export default "<css>"`; a side-effect import of a module with no side effect is tree-shaken, and the build exits 0. Measured on 0.41.0: a probe entry whose only statement is that import builds to a **0-byte bundle with zero `@font-face`**. And even when the string is kept (`import css from …`), its relative `url()` resolves against the document, while a `--app browser` build emits one file and no assets — so the rule parses and the face 404s.
|
|
46
|
+
|
|
47
|
+
`./embedded` is the form that survives both: every `src:` is a `data:` URI, and it is a **value** import, which a bundler cannot silently discard.
|
|
48
|
+
|
|
49
|
+
### The cost, and why it is opt-in
|
|
50
|
+
|
|
51
|
+
These are unsubsetted desktop TTFs, not web fonts. Base64 is 4/3 of the payload:
|
|
52
|
+
|
|
53
|
+
| | bytes | gzip -9 |
|
|
54
|
+
|---|---:|---:|
|
|
55
|
+
| `@gjsify/adwaita-web` stylesheet | 190 731 | 25 891 |
|
|
56
|
+
| `+` sans 400 inlined | 1 363 795 | 594 177 |
|
|
57
|
+
| `+` sans 400 + italic inlined | 2 577 599 | 1 205 683 |
|
|
58
|
+
|
|
59
|
+
So `@gjsify/adwaita-web` does **not** import `./embedded` from its root entry — ~600 KB gzip for a typeface that is installed system-wide on the platform it targets is the wrong default. Opt in per app, with the one line above. Importing only `ADWAITA_SANS_400_CSS` (and injecting it yourself) leaves the italic face tree-shakeable.
|
|
60
|
+
|
|
36
61
|
## License
|
|
37
62
|
|
|
38
63
|
OFL-1.1
|
package/index.css
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/* Both faces this package ships, so the `.` export and `./embedded` agree on what
|
|
2
|
+
"Adwaita Sans" means. It used to be `400.css` alone: a CSS-pipeline consumer
|
|
3
|
+
following the documented route got no italic and no diagnostic, while
|
|
4
|
+
`applyAdwaitaFonts()` registered two — an asymmetry nothing stated. Import
|
|
5
|
+
`./400.css` directly for the normal face only. */
|
|
1
6
|
@import './400.css';
|
|
7
|
+
@import './400-italic.css';
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// The `.` export of this package is a STYLESHEET (`index.css`), for a CSS
|
|
2
|
+
// pipeline that resolves `url('./files/*.ttf')` — Vite, webpack, a `<link>`,
|
|
3
|
+
// Astro's `customCss`. Importing it from JavaScript registers nothing: under
|
|
4
|
+
// `gjsify build --app browser|gjs` the css-as-string plugin turns it into
|
|
5
|
+
// `export default "<css>"`, and a side-effect import of a module with no side
|
|
6
|
+
// effect is tree-shaken away at exit 0. From JS use `./embedded`, whose faces
|
|
7
|
+
// are `data:` URIs behind a VALUE import (`applyAdwaitaFonts()`).
|
|
3
8
|
export {};
|