feat(fonts): ship Barlow, Barlow Condensed and Orbitron in the repo so the app and overlays work offline (1.89.23)
This commit is contained in:
1 parent
80f8402971
commit
d74d8cf38f
25 files changed
+344
-11
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, existsSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
|
||||
// The app, overlays and OBS work offline. The public mobile profile keeps Google Fonts: it is
|
||||
// reached over the internet through a router allowlist of three paths (scripts/teltonika).
|
||||
test("the app loads its fonts from the repo, not from the internet", () => {
|
||||
for (const page of ["index.html"]) {
|
||||
const html = readFileSync(join(root, page), "utf8");
|
||||
assert.doesNotMatch(html, /fonts\.(googleapis|gstatic)\.com/, page);
|
||||
assert.match(html, /href="\/src\/fonts\/fonts\.css"/, page);
|
||||
}
|
||||
});
|
||||
|
||||
test("every font file fonts.css points at is in src/fonts, for every family the styles use", () => {
|
||||
const css = readFileSync(join(root, "src/fonts/fonts.css"), "utf8");
|
||||
const files = [...css.matchAll(/url\("\.\/([^"]+)"\)/g)].map((match) => match[1]);
|
||||
assert.ok(files.length >= 15);
|
||||
files.forEach((file) => assert.ok(existsSync(join(root, "src/fonts", file)), file));
|
||||
["Barlow", "Barlow Condensed", "Orbitron"].forEach((family) => assert.match(css, new RegExp(`font-family: "${family}";`), family));
|
||||
assert.ok(existsSync(join(root, "src/fonts/LICENSE")));
|
||||
});
|
||||
Reference in new issue
Block a user