* gui: choose installed interface and code fonts and styles Discover installed styles through DirectWrite, CoreText and Fontconfig. Keep choices per computer, apply them before paint and notify both desktop webviews after saving; defaults retain platform and Omarchy fallbacks. Verified seven focused Go tests, including real Windows discovery (90 families, 276 styles), 14 font browser cases in Chromium/WebKit, 68 settings/zoom/Omarchy/web cases, go vet, Windows amd64/arm64 and Linux nogui builds. Against the original assets, the new UI test fails with Settings must offer an interface font picker (0 != 1). Full Windows suites have separately reproduced upstream failures; macOS/Linux native discovery is covered by the added CI step. * gui: retain bundled Mac fonts and variable style precision Only filter an undownloaded CoreText face when it is explicitly downloadable; bundled fonts are installed without being downloaded. Use resolved font names when descriptors omit them. Preserve fractional weights and nonnegative CSS widths for named variable styles. * gui: restore the authored font cascade when returning to defaults Apply family-only trait overrides only while a custom face is active. The browser regression catches code under a bold parent becoming 700 instead of its original 400. Keep the compatibility shim first, and apply boot fonts before visible content. * gui: keep font picker review separate from CI integration Leave the native test sources and manual verification command with the feature. Move the added workflow step to a follow-up so the font picker can take the normal review path requested on PR #1007.
46 lines
2.8 KiB
JavaScript
46 lines
2.8 KiB
JavaScript
// Defaults keep the authored cascade, including a code span under bold UI.
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
const assets = path.resolve(__dirname, "../assets");
|
|
const choice = (family, weight, style) => ({ family, name: "Chosen", weight, style, stretch: 100 });
|
|
|
|
for (const [name, engine] of [["chromium", chromium], ["webkit", webkit]]) {
|
|
test(`${name}: font reset restores the original cascade and explicit emphasis`, async () => {
|
|
const css = (await Promise.all(["app.css", "library.css", "routing.css", "sessions.css", "plugins.css"].map(f => fs.readFile(path.join(assets, f), "utf8")))).join("\n");
|
|
const js = await fs.readFile(path.join(assets, "fonts.js"), "utf8");
|
|
const browser = await engine.launch();
|
|
try {
|
|
const page = await browser.newPage();
|
|
await page.setContent(`<style>${css}</style>
|
|
<div class="sess-line"><b><code id="code">model-id</code></b></div>
|
|
<b><span class="key none" id="ui">No key</span></b>
|
|
<div class="acc"><input id="emphasis" class="rename mono" value="Account"></div>
|
|
<span id="badge" class="mk-badge">Code badge</span>`);
|
|
await page.addScriptTag({ content: js });
|
|
const read = () => page.evaluate(() => ["code", "ui", "emphasis", "badge"].map(id => {
|
|
const s = getComputedStyle(document.getElementById(id));
|
|
return { weight: s.fontWeight, style: s.fontStyle, family: s.fontFamily };
|
|
}));
|
|
const defaults = await read();
|
|
assert.equal(defaults[0].weight, "400", "code's authored regular weight must not inherit its bold parent");
|
|
assert.equal(defaults[1].weight, "400", "a UI family override must not discard the key's authored weight");
|
|
assert.equal(defaults[2].weight, "450");
|
|
await page.evaluate(s => window.desktopFonts.apply(s), { uiFont: choice("Arial", 500, "normal"), codeFont: choice("Consolas", 700, "italic") });
|
|
const picked = await read();
|
|
assert.equal(picked[0].weight, "700");
|
|
assert.equal(picked[0].style, "italic");
|
|
assert.equal(picked[1].weight, "500");
|
|
assert.equal(picked[2].weight, "450", "component emphasis stays explicit");
|
|
await page.evaluate(() => window.desktopFonts.apply({}));
|
|
assert.deepEqual(await read(), defaults, "reset restores every original font trait");
|
|
await page.evaluate(s => window.desktopFonts.apply(s), { uiFont: choice("Arial", 600, "italic"), codeFont: choice("Consolas", 400, "normal") });
|
|
const independent = await read();
|
|
assert.equal(independent[3].weight, "400");
|
|
assert.equal(independent[3].style, "normal", "code badges don't inherit the chosen interface slope");
|
|
} finally { await browser.close(); }
|
|
});
|
|
}
|