diff options
Diffstat (limited to 'desktop/modules/fonts/Fonts.js')
| -rw-r--r-- | desktop/modules/fonts/Fonts.js | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/desktop/modules/fonts/Fonts.js b/desktop/modules/fonts/Fonts.js index 5b7d303..d42c784 100644 --- a/desktop/modules/fonts/Fonts.js +++ b/desktop/modules/fonts/Fonts.js @@ -12,9 +12,10 @@ // Pure helpers for the fonts page, tested by test_fonts.js under node. // -// The model is fonts.json: {base, override}. base is one pixel size for the -// whole desktop; override maps a system ("qt") or one entry of a section -// ("rofi:kf-launcher-entry") to its own pixel size. Everything is stored in +// The model is fonts.json: {base, override, family}. base is one pixel size +// for the whole desktop; override maps a system ("qt") or one entry of a +// section ("rofi:kf-launcher-entry") to its own pixel size; family maps a +// font slot no other config holds (FAMILIES) to an installed family. Everything is stored in // px and converted where a system wants points: at scale 1 Wayland's logical // DPI is 96 (gtk-xft-dpi reads 98304, 96 * 1024), so px = pt * 96 / 72. @@ -30,6 +31,14 @@ const SYSTEMS = [ { id: "gtk", label: "GTK", unit: "pt", where: "gtk-3.0 and gtk-4.0 settings.ini, .gtkrc-2.0, gsettings", when: "at once for GTK 3 and 4" }, { id: "kitty", label: "kitty", unit: "pt", where: "kitty.conf, through an include", when: "at once" }, { id: "groupbar", label: "Hyprland groupbar", unit: "px", where: "keystone.lua, group:groupbar:font_size", when: "at once" }, + { id: "deckit", label: "deck-it", unit: "px", where: "deck-it's theme.css, from fonts.json", when: "on the tablet within 5 s" }, +]; + +// deck-it's dim cover clock, sized from deck-it's text as deck.css designs +// it (8rem, 1.6rem); an override is "deckit:clock" or "deckit:date". +const DECKIT_CLOCK = [ + { id: "clock", label: "Clock time", ratio: 8 }, + { id: "date", label: "Clock date", ratio: 1.6 }, ]; // A section is a set of designed sizes that scale together: rofi's fonts, @@ -40,6 +49,12 @@ const SECTIONS = [ { id: "hyprlock", label: "hyprlock", unit: "pt", when: "next lock" }, ]; +// Font families set here, read by their program from fonts.json itself. +const FAMILIES = [ + { id: "deckit-clock", label: "deck-it clock", where: "the time on the tablet's dim cover" }, + { id: "deckit-date", label: "deck-it date", where: "the date under it" }, +]; + // A system's or a section's size in px. function size(m, id) { const o = m.override[id]; @@ -62,13 +77,21 @@ function withOverride(m, id, px) { const o = {}; for (const k in m.override) if (k !== id) o[k] = m.override[k]; if (px !== null) o[id] = px; - return { base: m.base, override: o }; + return { base: m.base, override: o, family: m.family }; +} + +// The model with family id set to name, or unset when name is empty. +function withFamily(m, id, name) { + const f = {}; + for (const k in m.family) if (k !== id) f[k] = m.family[k]; + if (name.trim() !== "") f[id] = name.trim(); + return { base: m.base, override: m.override, family: f }; } function parseModel(text) { try { const j = JSON.parse(text); - if (typeof j.base === "number") return { base: j.base, override: j.override || {} }; + if (typeof j.base === "number") return { base: j.base, override: j.override || {}, family: j.family || {} }; } catch (e) {} return null; } @@ -78,7 +101,7 @@ function parseModel(text) { // from it is an override at its current size. Kept to 0.01px: at 0.1, an // 11pt body stored as 14.7px scaled rofi's 72pt glyph to 72.2. function seed(now) { - const m = { base: 16, override: {} }; + const m = { base: 16, override: {}, family: {} }; for (const id in now) if (now[id] !== null && Math.abs(now[id] - 16) > 0.05) m.override[id] = Math.round(now[id] * 100) / 100; return m; } |
