@gjsify/gtk-host 0.50.0 → 0.51.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/lib/esm/font-dir.js +1 -1
- package/lib/esm/font-families.js +1 -1
- package/lib/esm/fonts.js +1 -1
- package/lib/esm/ui-font.js +1 -0
- package/lib/types/font-dir.d.ts +30 -0
- package/lib/types/fonts.d.ts +95 -4
- package/lib/types/ui-font.d.ts +87 -0
- package/lib/types/ui-font.spec.d.ts +2 -0
- package/package.json +4 -4
package/lib/esm/font-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const e=[`.ttf`,`.otf`,`.ttc`,`.otc`];function resolveFontDir(e={}){return nonEmpty(e.fontDir)??nonEmpty(e.env?.GJSIFY_FONT_DIR)}function isFontFace(t){let n=t.toLowerCase();return e.some(e=>n.endsWith(e))}function nonEmpty(e){if(e===void 0)return;let t=e.trim();return t===``?void 0:t}export{e as FONT_FACE_EXTENSIONS,isFontFace,resolveFontDir};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=[`.ttf`,`.otf`,`.ttc`,`.otc`];function resolveFontSources(e={}){let t=nonEmpty(e.runtimeFontDir)??nonEmpty(e.env?.GJSIFY_GTK_RUNTIME_FONT_DIR),n=resolveFontDir(e),r=[];return t!==void 0&&r.push({dir:t,origin:`runtime`}),n!==void 0&&n!==t&&r.push({dir:n,origin:`app`}),r}function resolveFontDir(e={}){return nonEmpty(e.fontDir)??nonEmpty(e.env?.GJSIFY_FONT_DIR)}function isFontFace(t){let n=t.toLowerCase();return e.some(e=>n.endsWith(e))}function nonEmpty(e){if(e===void 0)return;let t=e.trim();return t===``?void 0:t}export{e as FONT_FACE_EXTENSIONS,isFontFace,resolveFontDir,resolveFontSources};
|
package/lib/esm/font-families.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const e=/^(.*\S)\s
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=/^(.*\S)\s(?:\d+pt|Text|Caption|Subhead|Banner)$/i,fold=e=>e.trim().toLowerCase();function matchFontFamily(t,n){let r=fold(t),i=n.find(e=>fold(e)===r);if(i!==void 0)return{declared:t,family:i,kind:`exact`,candidates:[i]};let a=n.filter(t=>{let n=e.exec(t);return n!==null&&fold(n[1])===r});if(a.length===1)return{declared:t,family:a[0],kind:`optical`,candidates:a};if(a.length>1)return{declared:t,family:void 0,kind:`ambiguous`,candidates:a};let o=e.exec(t.trim());if(o!==null){let e=n.find(e=>fold(e)===fold(o[1]));if(e!==void 0)return{declared:t,family:e,kind:`optical`,candidates:[e]}}return{declared:t,family:void 0,kind:`absent`,candidates:[]}}function matchFontFamilies(e,t){return e.map(e=>matchFontFamily(e,t))}function describeFontFamilyMatch(e){switch(e.kind){case`exact`:return`${e.declared}: on the font map under that name`;case`optical`:return`${e.declared}: on the font map as "${e.family}" — this font stack keeps the optical-size axis in the family name, so the declared name resolves to nothing and Pango substitutes the default sans without a word. Ask for the name on the right.`;case`ambiguous`:return`${e.declared}: the font map carries ${e.candidates.length} optical sizes of it (${e.candidates.join(`, `)}) and no family under the declared name. Which one to use at which point size is a design decision, so nothing here picks for you.`;case`absent`:return`${e.declared}: NOT on the font map. Text asking for it renders in a substituted family — Pango does not report a missing family, so nothing else will say so.`}}export{describeFontFamilyMatch,matchFontFamilies,matchFontFamily};
|
package/lib/esm/fonts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{isFontFace as e,
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{isFontFace as e,resolveFontSources as t}from"./font-dir.js";import{describeFontFamilyMatch as n,matchFontFamilies as r,matchFontFamily as i}from"./font-families.js";import{ADWAITA_UI_FONT_FAMILY as a,GNOME_UI_FONT_POINT_SIZE as o,UI_FONT_POLICIES as s,planUiFont as c,planUiFontPolicy as l}from"./ui-font.js";import u from"gi://Gtk?version=4.0";import d from"gi://Gio?version=2.0";import f from"gi://GLib?version=2.0";import p from"gi://PangoCairo?version=1.0";function isUnsupportedByFontMap(e){return e instanceof f.Error&&e.matches(d.io_error_quark(),d.IOErrorEnum.NOT_SUPPORTED)}function initFonts(e={}){let i=t({...e,env:{GJSIFY_FONT_DIR:f.getenv(`GJSIFY_FONT_DIR`)??void 0,GJSIFY_GTK_RUNTIME_FONT_DIR:f.getenv(`GJSIFY_GTK_RUNTIME_FONT_DIR`)??void 0}}),a=i.find(e=>e.origin===`app`)?.dir,o=[],s=[],c=[],l=e.expectedFamilies??[];if(i.length===0&&l.length===0)return{dir:a,sources:i,uiFont:void 0,registered:o,declined:s,failed:c,families:[],matches:[]};let u=p.FontMap.get_default(),m=i.length===0?[]:familyNames(u);for(let e of i){let t=[];collectFaces(d.File.new_for_path(e.dir),t,c);for(let e of t.sort())try{u.add_font_file(e),o.push(e)}catch(t){if(isUnsupportedByFontMap(t)){s.push(e);continue}c.push({path:e,message:messageOf(t)})}}let h=familyNames(u),g=i.length===0?[]:h.filter(e=>!m.includes(e)).sort(),_=r(l,h);captureUiFontBaseline();let v=e.uiFont===void 0?void 0:applyUiFontPolicy(e.uiFont);for(let e of c)console.warn(`initFonts: ${e.path} could not be read as an application font (${e.message}). Text asking for a family this application ships will render in a substituted one.`);for(let e of _)e.kind!==`exact`&&console.warn(`initFonts: ${n(e)}`);return{dir:a,sources:i,uiFont:v,registered:o,declined:s,failed:c,families:g,matches:_}}let m=!1,h;function captureUiFontBaseline(){if(m)return h;let e=u.Settings.get_default();if(e!==null)return h=e.gtk_font_name??void 0,m=!0,h}function uiFontBaseline(){return captureUiFontBaseline()}function applyUiFontPolicy(e){let t=typeof e==`string`?{policy:e}:e,n=u.Settings.get_default();if(n===null)return{next:void 0,kind:`unparsed`,family:void 0,size:void 0};let r=captureUiFontBaseline(),i=l({...t,family:t.family??resolvedAdwaitaFamily(t.policy),current:n.gtk_font_name??void 0,baseline:r});return i.next===void 0||(n.gtk_font_name=i.next),i}function resolvedAdwaitaFamily(e){if(e!==`adwaita`)return;let t=adwaitaUiFontAvailability();if(t.match.family!==void 0)return t.match.family;console.warn(`applyUiFontPolicy: "${t.family}" is ${t.match.kind} on this font map, so asking for it will render in a substituted family. Register the runtime bundle's faces with initFonts() first, and check adwaitaUiFontAvailability() before offering this policy.`)}function adwaitaUiFontAvailability(e=a){let t=i(e,familyNames(p.FontMap.get_default()));return{family:e,match:t,available:t.kind!==`absent`}}function familyNames(e){return e.list_families().map(e=>e.get_name())}function collectFaces(t,n,r){try{let i=t.enumerate_children(`standard::name,standard::type`,d.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);for(let t=i.next_file(null);t!==null;t=i.next_file(null)){let a=i.get_child(t),o=a.get_path();o!==null&&(t.get_file_type()===d.FileType.DIRECTORY?collectFaces(a,n,r):e(t.get_name())&&n.push(o))}}catch(e){r.push({path:t.get_path()??``,message:messageOf(e)})}}function messageOf(e){return e instanceof f.Error||e instanceof Error?e.message:String(e)}export{a as ADWAITA_UI_FONT_FAMILY,o as GNOME_UI_FONT_POINT_SIZE,s as UI_FONT_POLICIES,adwaitaUiFontAvailability,applyUiFontPolicy,n as describeFontFamilyMatch,initFonts,isUnsupportedByFontMap,r as matchFontFamilies,i as matchFontFamily,c as planUiFont,l as planUiFontPolicy,t as resolveFontSources,uiFontBaseline};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=11,t=`Adwaita Sans`,n=[`system`,`size`,`adwaita`];function planUiFont(e,t={}){let n=t.size??11,r=(e??``).trim(),i=/^(.*\S)\s+(\d+(?:\.\d+)?)$/.exec(r);if(i===null)return{next:void 0,kind:`unparsed`,family:r===``?void 0:r,size:void 0};let a=i[1],o=Number.parseFloat(i[2]),s=t.family??a,c=o<n?n:o;return s===a&&c===o?{next:void 0,kind:`kept`,family:a,size:o}:{next:`${s} ${String(c)}`,kind:t.family!==void 0&&t.family!==a?`family`:`raised`,family:s,size:c}}function planUiFontPolicy(e){let{policy:t,current:n,baseline:r}=e;if(t===`system`)return r===void 0?{next:void 0,kind:`kept`,family:void 0,size:void 0}:r===n?describe(r,`kept`):describe(r,`restored`);if(t===`size`)return planUiFont(n,{size:e.size,family:e.family});let i=e.family??`Adwaita Sans`,a=e.size??11,o=`${i} ${String(a)}`;return o===(n??``).trim()?{next:void 0,kind:`kept`,family:i,size:a}:{next:o,kind:`family`,family:i,size:a}}function describe(e,t){let n=/^(.*\S)\s+(\d+(?:\.\d+)?)$/.exec(e.trim());return{next:t===`kept`?void 0:e,kind:t,family:n?n[1]:e.trim()||void 0,size:n?Number.parseFloat(n[2]):void 0}}export{t as ADWAITA_UI_FONT_FAMILY,e as GNOME_UI_FONT_POINT_SIZE,n as UI_FONT_POLICIES,planUiFont,planUiFontPolicy};
|
package/lib/types/font-dir.d.ts
CHANGED
|
@@ -17,6 +17,36 @@ export interface ResolveFontDirOptions {
|
|
|
17
17
|
/** Environment to read `GJSIFY_FONT_DIR` from. */
|
|
18
18
|
env?: Record<string, string | undefined>;
|
|
19
19
|
}
|
|
20
|
+
/** A directory of faces, and who put it there. */
|
|
21
|
+
export interface FontSource {
|
|
22
|
+
readonly dir: string;
|
|
23
|
+
/**
|
|
24
|
+
* `runtime` = the GTK runtime bundle's own faces (the GNOME UI typeface, shipped by
|
|
25
|
+
* `@gjsify/gtk-runtime-<target>` and named by `@gjsify/node-gi`'s loader);
|
|
26
|
+
* `app` = the faces THIS application staged with `gjsify ship`.
|
|
27
|
+
*/
|
|
28
|
+
readonly origin: 'runtime' | 'app';
|
|
29
|
+
}
|
|
30
|
+
export interface ResolveFontSourcesOptions extends ResolveFontDirOptions {
|
|
31
|
+
/** Wins over `GJSIFY_GTK_RUNTIME_FONT_DIR` — a bundle checkout, or a test fixture. */
|
|
32
|
+
runtimeFontDir?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every directory of faces this process should register, RUNTIME first.
|
|
36
|
+
*
|
|
37
|
+
* TWO SOURCES, NOT ONE, and they answer different questions. `GJSIFY_FONT_DIR` is the
|
|
38
|
+
* application's own brand face, staged by `gjsify ship` (ADR 0038).
|
|
39
|
+
* `GJSIFY_GTK_RUNTIME_FONT_DIR` is the GNOME UI typeface the GTK runtime bundle carries,
|
|
40
|
+
* because off Linux nothing installs it: measured on Windows 11 against the published 0.50.0
|
|
41
|
+
* bundle, `Adwaita Sans 11` and `Cantarell 11` both resolve to Tahoma, and Pango reports that
|
|
42
|
+
* substitution by rendering it. An application must never have to choose between its own face
|
|
43
|
+
* and the platform's, which is why this is a second variable rather than a contested one.
|
|
44
|
+
*
|
|
45
|
+
* RUNTIME FIRST, so the platform faces are on the map before an application's — the order the
|
|
46
|
+
* two were designed in. Duplicates collapse: pointing both variables at one directory
|
|
47
|
+
* registers it once instead of handing every face to `add_font_file` twice.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveFontSources(options?: ResolveFontSourcesOptions): FontSource[];
|
|
20
50
|
/**
|
|
21
51
|
* Resolve the directory holding the application's shipped faces, or `undefined` when none is named.
|
|
22
52
|
*
|
package/lib/types/fonts.d.ts
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { type FontFamilyMatch } from './font-families.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type FontSource, type ResolveFontSourcesOptions } from './font-dir.js';
|
|
3
|
+
import { type PlanUiFontOptions, type UiFontPlan, type UiFontPolicy } from './ui-font.js';
|
|
3
4
|
export { describeFontFamilyMatch, matchFontFamilies, matchFontFamily, type FontFamilyMatch, type FontFamilyMatchKind, } from './font-families.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
5
|
+
export { ADWAITA_UI_FONT_FAMILY, GNOME_UI_FONT_POINT_SIZE, UI_FONT_POLICIES, planUiFont, planUiFontPolicy, type PlanUiFontOptions, type PlanUiFontPolicyOptions, type UiFontPlan, type UiFontPlanKind, type UiFontPolicy, } from './ui-font.js';
|
|
6
|
+
export { resolveFontSources, type FontSource, type ResolveFontSourcesOptions } from './font-dir.js';
|
|
7
|
+
/**
|
|
8
|
+
* Everything {@link resolveFontSources} takes except the environment, which {@link initFonts}
|
|
9
|
+
* reads.
|
|
10
|
+
*/
|
|
11
|
+
export interface InitFontsOptions extends Omit<ResolveFontSourcesOptions, 'env'> {
|
|
12
|
+
/**
|
|
13
|
+
* Which {@link UiFontPolicy} to apply to `gtk-font-name`, or nothing at all.
|
|
14
|
+
*
|
|
15
|
+
* DEFAULT: NOTHING. Registering faces and rewriting the user's font setting are two different
|
|
16
|
+
* acts, and only the first is unambiguously this call's business — a runtime that changes a
|
|
17
|
+
* font setting nobody asked it to change is a surprise, and it would also make `system`
|
|
18
|
+
* unreachable in practice, because the host's own value would already have been overwritten
|
|
19
|
+
* before a consumer could choose to keep it. `size` is the RECOMMENDED value for an app
|
|
20
|
+
* shipping a bundled GTK; it is a recommendation in the documentation, not a default here.
|
|
21
|
+
*
|
|
22
|
+
* Passing a policy still captures the baseline first, so switching back to `system` later
|
|
23
|
+
* works. See {@link applyUiFontPolicy}, which is also callable on its own at any time.
|
|
24
|
+
*/
|
|
25
|
+
readonly uiFont?: UiFontPolicy | ApplyUiFontPolicyOptions;
|
|
6
26
|
/**
|
|
7
27
|
* The family names this application will ASK FOR — checked against the map once registration
|
|
8
28
|
* is done, and reported in {@link InitFontsResult.matches}.
|
|
@@ -22,8 +42,23 @@ export interface FontFaceFailure {
|
|
|
22
42
|
}
|
|
23
43
|
/** What {@link initFonts} did, so a caller that cares can assert on it. */
|
|
24
44
|
export interface InitFontsResult {
|
|
25
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The APPLICATION's font directory that was read, or `undefined` when nothing named one.
|
|
47
|
+
*
|
|
48
|
+
* Unchanged in meaning since before the runtime bundle had faces of its own, which is why
|
|
49
|
+
* it is still singular: a caller asserting "my staged face was found" must not start
|
|
50
|
+
* answering `true` because the platform's were. {@link sources} is the full list.
|
|
51
|
+
*/
|
|
26
52
|
readonly dir: string | undefined;
|
|
53
|
+
/** Every directory registered, runtime first. See {@link FontSource}. */
|
|
54
|
+
readonly sources: readonly FontSource[];
|
|
55
|
+
/**
|
|
56
|
+
* What the UI-font-size policy did, or `undefined` when it did not run.
|
|
57
|
+
*
|
|
58
|
+
* `undefined` is the ordinary answer on Linux: no runtime bundle names a font directory
|
|
59
|
+
* there, so the default leaves `gtk-font-name` alone entirely.
|
|
60
|
+
*/
|
|
61
|
+
readonly uiFont: UiFontPlan | undefined;
|
|
27
62
|
/** Faces now on the default font map. */
|
|
28
63
|
readonly registered: readonly string[];
|
|
29
64
|
/** Faces the font map declined as unsupported — see {@link isUnsupportedByFontMap}. */
|
|
@@ -106,3 +141,59 @@ export declare function isUnsupportedByFontMap(error: unknown): boolean;
|
|
|
106
141
|
* `gjsify ship` staged one, so an unset variable is the ordinary case and does nothing quietly.
|
|
107
142
|
*/
|
|
108
143
|
export declare function initFonts(options?: InitFontsOptions): InitFontsResult;
|
|
144
|
+
/** Everything {@link planUiFontPolicy} takes except what this module supplies itself. */
|
|
145
|
+
export interface ApplyUiFontPolicyOptions extends PlanUiFontOptions {
|
|
146
|
+
readonly policy: UiFontPolicy;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* `gtk-font-name` as this process first found it — what the `system` policy restores.
|
|
150
|
+
*
|
|
151
|
+
* READING IT CAPTURES IT, which is the point: the value is only correct if it is taken before
|
|
152
|
+
* anything writes. A consumer that wants to show the host's own font in a preferences dialog
|
|
153
|
+
* therefore gets the right answer by asking early, and `initFonts()` asks at startup.
|
|
154
|
+
*
|
|
155
|
+
* `undefined` means either "not captured yet, and the toolkit is not initialised" or "this host's
|
|
156
|
+
* `gtk-font-name` is genuinely unset". Both lead to the same correct behaviour under `system`:
|
|
157
|
+
* leave the setting alone.
|
|
158
|
+
*/
|
|
159
|
+
export declare function uiFontBaseline(): string | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Apply one of the three {@link UiFontPolicy} states to `gtk-font-name`.
|
|
162
|
+
*
|
|
163
|
+
* The writing half of `ui-font.ts`, and the function a preferences dialog calls when the user
|
|
164
|
+
* changes the setting — including the way BACK: `system` restores the baseline this module
|
|
165
|
+
* captured before the first write, which is why switching `adwaita` → `system` at runtime
|
|
166
|
+
* returns the host's own `Segoe UI 9` rather than an approximation of it.
|
|
167
|
+
*
|
|
168
|
+
* `Gtk.Settings.get_default()` answers null before `Gtk.init()`, and that is a legitimate state
|
|
169
|
+
* rather than an error: a program may register its faces before it initialises the toolkit. It
|
|
170
|
+
* reports `unparsed` — the arm that already means "nothing to act on, so nothing changed" —
|
|
171
|
+
* instead of throwing a caller out of a font call over a setting.
|
|
172
|
+
*/
|
|
173
|
+
export declare function applyUiFontPolicy(request: UiFontPolicy | ApplyUiFontPolicyOptions): UiFontPlan;
|
|
174
|
+
/**
|
|
175
|
+
* Can this process offer the `adwaita` policy at all — is the GNOME face on the font map?
|
|
176
|
+
*
|
|
177
|
+
* THE QUESTION A PREFERENCES DIALOG HAS TO ASK BEFORE IT OFFERS THE OPTION. Forcing
|
|
178
|
+
* `Adwaita Sans 11` on a host where that family never arrived — an old bundle, a system GTK with
|
|
179
|
+
* no adwaita-fonts package — does not fail: Pango substitutes, and the user who picked "use the
|
|
180
|
+
* Adwaita font" gets Tahoma. That is one substitution traded for another, with a setting that
|
|
181
|
+
* now lies about what it did.
|
|
182
|
+
*
|
|
183
|
+
* Answered as a {@link FontFamilyMatch} rather than a boolean because `optical` is a real third
|
|
184
|
+
* state, measured on Windows: a family can be on the map under a decorated name (`Merriweather
|
|
185
|
+
* 18pt`), in which case the honest thing is to ask for THAT name — `match.family` — rather than
|
|
186
|
+
* to report the face as missing. `available` is the convenience for the common case.
|
|
187
|
+
*
|
|
188
|
+
* Call it AFTER `initFonts()`, which is what puts the bundled faces on the map.
|
|
189
|
+
*/
|
|
190
|
+
export declare function adwaitaUiFontAvailability(family?: string): UiFontAvailability;
|
|
191
|
+
/** What {@link adwaitaUiFontAvailability} answers. */
|
|
192
|
+
export interface UiFontAvailability {
|
|
193
|
+
/** The family that was asked about. */
|
|
194
|
+
readonly family: string;
|
|
195
|
+
/** How it resolves on the font map as it now stands. */
|
|
196
|
+
readonly match: FontFamilyMatch;
|
|
197
|
+
/** `false` when the family is absent, i.e. the `adwaita` policy would substitute. */
|
|
198
|
+
readonly available: boolean;
|
|
199
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The point size GNOME's interface is designed at — `org.gnome.desktop.interface font-name`'s
|
|
3
|
+
* default has been `Cantarell 11` and is now `Adwaita Sans 11`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const GNOME_UI_FONT_POINT_SIZE = 11;
|
|
6
|
+
/**
|
|
7
|
+
* The GNOME UI face, and the family `@gjsify/gtk-runtime-<target>` bundles.
|
|
8
|
+
*
|
|
9
|
+
* `Adwaita Sans` rather than `Cantarell`, which it succeeded: adwaita-fonts ships no Cantarell,
|
|
10
|
+
* so naming it here would ask for a family no bundle carries.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ADWAITA_UI_FONT_FAMILY = "Adwaita Sans";
|
|
13
|
+
/** Which of the three states an application wants. See the note at the top of this file. */
|
|
14
|
+
export type UiFontPolicy = 'system' | 'size' | 'adwaita';
|
|
15
|
+
/**
|
|
16
|
+
* The three states, in the order a preferences dialog should offer them.
|
|
17
|
+
*
|
|
18
|
+
* Exported so a consumer building that dialog enumerates them instead of hard-coding three
|
|
19
|
+
* strings that then drift from this type — the settings UI and the policy are two copies of one
|
|
20
|
+
* list otherwise, and only one of them is checked by the compiler.
|
|
21
|
+
*/
|
|
22
|
+
export declare const UI_FONT_POLICIES: readonly UiFontPolicy[];
|
|
23
|
+
/** The reasons a plan gives. See {@link UiFontPlan.kind}. */
|
|
24
|
+
export type UiFontPlanKind = 'raised' | 'family' | 'restored' | 'kept' | 'unparsed';
|
|
25
|
+
/** What {@link planUiFont} or {@link planUiFontPolicy} decided, and why. */
|
|
26
|
+
export interface UiFontPlan {
|
|
27
|
+
/** The `gtk-font-name` to set, or `undefined` when nothing should change. */
|
|
28
|
+
readonly next: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* `raised` — the host's size was below GNOME's and is corrected;
|
|
31
|
+
* `family` — a family override was asked for and applied;
|
|
32
|
+
* `restored` — the host's ORIGINAL value is being put back (the `system` policy);
|
|
33
|
+
* `kept` — nothing to do: the setting already says what the policy wants;
|
|
34
|
+
* `unparsed` — the current value carries no point size this can reason about.
|
|
35
|
+
*/
|
|
36
|
+
readonly kind: UiFontPlanKind;
|
|
37
|
+
/** The family in effect after the plan, for reporting. */
|
|
38
|
+
readonly family: string | undefined;
|
|
39
|
+
/** The point size in effect after the plan, for reporting. */
|
|
40
|
+
readonly size: number | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface PlanUiFontOptions {
|
|
43
|
+
/** Target point size. Defaults to {@link GNOME_UI_FONT_POINT_SIZE}. */
|
|
44
|
+
readonly size?: number;
|
|
45
|
+
/** Force this family too. Off by default — see the policy note at the top of this file. */
|
|
46
|
+
readonly family?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Decide the `gtk-font-name` for a host whose current one is `current`.
|
|
50
|
+
*
|
|
51
|
+
* PARSED HERE RATHER THAN THROUGH `Pango.FontDescription.from_string`, which is the obvious
|
|
52
|
+
* tool and the wrong one for this job: that parser NEVER fails — an unparsable tail becomes part
|
|
53
|
+
* of the family — so every malformed value would come back as a description with size 0, and
|
|
54
|
+
* "this host has no size I can read" would be indistinguishable from "this host asked for 0 pt".
|
|
55
|
+
* The distinction is the whole point of the `unparsed` arm: a value this cannot read is left
|
|
56
|
+
* exactly as it is, because silently rewriting a setting one does not understand is worse than
|
|
57
|
+
* a font that is 2 pt small.
|
|
58
|
+
*
|
|
59
|
+
* The grammar accepted is the one `gtk-font-name` actually carries: a family, optional style
|
|
60
|
+
* words, then a trailing size — `Segoe UI 9`, `Cantarell Bold 11`, `Adwaita Sans 11.5`. A
|
|
61
|
+
* fractional size is kept fractional; Pango's own `to_string` emits those.
|
|
62
|
+
*/
|
|
63
|
+
export declare function planUiFont(current: string | undefined, options?: PlanUiFontOptions): UiFontPlan;
|
|
64
|
+
export interface PlanUiFontPolicyOptions extends PlanUiFontOptions {
|
|
65
|
+
/** Which of the three states to plan for. */
|
|
66
|
+
readonly policy: UiFontPolicy;
|
|
67
|
+
/** `gtk-font-name` as it stands right now. */
|
|
68
|
+
readonly current: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* `gtk-font-name` as this PROCESS first found it, before anything wrote to it.
|
|
71
|
+
*
|
|
72
|
+
* Only the `system` policy reads it, and without it that policy cannot exist: once a value
|
|
73
|
+
* has been overwritten the host's own is not recoverable — not from GTK, not from the
|
|
74
|
+
* display, not from GSettings (Windows has none, and on Linux the setting a user actually
|
|
75
|
+
* chose may itself have been a session-level override). `fonts.ts` captures it on first
|
|
76
|
+
* contact; `uiFontBaseline()` is the reader.
|
|
77
|
+
*/
|
|
78
|
+
readonly baseline?: string | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Decide `gtk-font-name` for one of the three {@link UiFontPolicy} states.
|
|
82
|
+
*
|
|
83
|
+
* Pure, like {@link planUiFont} it builds on, so all three states and the way back are exercised
|
|
84
|
+
* as unit tests on node with no display and no `Gtk.Settings`. {@link applyUiFontPolicy} in
|
|
85
|
+
* `fonts.ts` is the half that writes.
|
|
86
|
+
*/
|
|
87
|
+
export declare function planUiFontPolicy(options: PlanUiFontPolicyOptions): UiFontPlan;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/gtk-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Framework-agnostic GTK4/Adwaita host: the element model UI-framework renderers bind to",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@girs/gtk-4.0": "5.0.0",
|
|
102
102
|
"@girs/pango-1.0": "5.0.0",
|
|
103
103
|
"@girs/pangocairo-1.0": "5.0.0",
|
|
104
|
-
"@gjsify/adwaita-core": "^0.
|
|
104
|
+
"@gjsify/adwaita-core": "^0.51.0"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"@vue/runtime-core": "^3.5.0",
|
|
@@ -124,10 +124,10 @@
|
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@gjsify/cli": "^0.
|
|
127
|
+
"@gjsify/cli": "^0.51.0",
|
|
128
128
|
"@vue/runtime-core": "^3.5.0",
|
|
129
129
|
"solid-js": "^1.9.0",
|
|
130
|
-
"@gjsify/unit": "^0.
|
|
130
|
+
"@gjsify/unit": "^0.51.0",
|
|
131
131
|
"@types/node": "^25.9.2",
|
|
132
132
|
"typescript": "^6.0.3",
|
|
133
133
|
"@gjsify/node-gi": "file:../../node-gi/node-gi",
|