sevaht_gui.fonts

Default fonts for sevaht-gui windows on X11, and a check for a Tk without Xft.

On X11 a Tk built with Xft (every distro’s) draws fontconfig fonts – the ones installed on the system, antialiased. A Tk built without it (notably the one bundled by python-build-standalone, which is what uv downloads) can only use the legacy X core fonts, which a modern desktop hardly has: every request then falls back to the X server’s fixed and the window looks wrong whatever font is asked for. Nothing at run time can change that, so tk_lacks_xft() lets an application say so (TkApp logs a warning), and the cure is a Python whose Tk has Xft (a distro’s).

With Xft, Tk’s default fonts follow fontconfig’s default sans, which is usually fine. apply_default_font() instead picks the first of a list of preferred families that is installed, for a consistent look across systems, and leaves Tk alone when none is.

sevaht_gui.fonts.choose_family(available: Iterable[str], preferred: Sequence[str]) → str | None[source]

The first of preferred that is in available (as written there).

sevaht_gui.fonts.tk_lacks_xft(root: Misc) → bool[source]

True if this is an X11 Tk that cannot draw fontconfig (Xft) fonts.

sevaht_gui.fonts.warn_if_no_xft(root: Misc) → bool[source]

Log a warning and return True if the Tk cannot draw fontconfig fonts.

sevaht_gui.fonts.apply_default_font(root: tk.Misc, families: Sequence[str] = ('Noto Sans', 'DejaVu Sans', 'Liberation Sans', 'Cantarell')) → str | None[source]

Use the first installed of families for Tk’s text fonts (X11).

Sizes and weights are kept; only the family changes. Returns the family used, or None when nothing was changed: not X11 (Windows and macOS have their own system fonts), no Xft, none of the families installed.