Two corrections to my earlier comment #2 — the second one matters for
the fix:

1. The locale/alias explanation for the failed reproduction was wrong. It
reproduces on a stock configuration with no locale change, as you found.
Sorry for the noise.

2. Upstream 2.18.2 did NOT change mode="prepend" to mode="append". MR 532
keeps mode="prepend" and moves the value to the `genericfamily` pattern
object:

    <edit name="genericfamily" mode="prepend">
      <const>monospace</const>
    </edit>

Keeping the injected name out of the `family` list is what makes the fix
work, not the ordering. Switching `family` to append fixes the reported
case but is not an equivalent — it also lets the aliased generics win:

    $ fc-match 'sans-serif:spacing=100'
    2.17.1 as shipped     -> DejaVu Sans Mono
    with prepend->append  -> a proportional font (Noto Sans CJK SC here)
    2.18.2                -> monospace (test/test-issue-539.json)

Both verified on 26.04.1 with fontconfig 2.17.1-3ubuntu1, stock
configuration.

The append change does fix the reported request
(`JetBrainsMono Nerd Font:spacing=100` now returns the requested family,
also with a Ghostty-style `<alias binding="strong">`), so it is a usable
workaround for 2.17.1 — it just shouldn't be described as the exact
equivalent of the upstream fix, and the sans-serif/serif delta is worth
a line in the DEP-3 description. If parity matters, keeping the prepend
for the generic families while appending otherwise reproduces 2.18.2's
answers on all the cases I tested; happy to send that patch.


** Description changed:

  Package: fontconfig 2.17.1-3ubuntu1 (Ubuntu 26.04 "resolute")
  
  Any application that requests a specific family together with spacing=100
  (terminal emulators such as Ghostty do) silently gets DejaVu Sans Mono
  instead of the configured font.
  
  Minimal reproduction:
-   $ fc-match 'JetBrainsMono NFM:spacing=100'
-   DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"          # wrong
-   $ fc-match 'JetBrainsMono NFM'
-   JetBrainsMonoNerdFontMono-Regular.ttf: "JetBrainsMono Nerd Font Mono" 
"Regular"
+   $ fc-match 'JetBrainsMono NFM:spacing=100'
+   DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"          # wrong
+   $ fc-match 'JetBrainsMono NFM'
+   JetBrainsMonoNerdFontMono-Regular.ttf: "JetBrainsMono Nerd Font Mono" 
"Regular"
  
  Cause: /etc/fonts/conf.d/48-spacing.conf prepends the literal `monospace`
  to the query's `family` list when spacing=100 is requested:
-   <edit name="family" mode="prepend"><string>monospace</string></edit>
+   <edit name="family" mode="prepend"><string>monospace</string></edit>
  fontconfig family matching is positional, so the injected generic name
  outranks the family the application actually asked for.
  
  Fixed upstream in fontconfig 2.18.2:
-   https://gitlab.freedesktop.org/fontconfig/fontconfig/-/work_items/539
-   https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/532
- The upstream fix uses the `genericfamily` pattern object that only exists
- since 2.18.0, so it cannot be applied verbatim to 2.17.1; the equivalent
- change for 2.17.1 is mode="prepend" -> mode="append" in 48-spacing.conf.
+   https://gitlab.freedesktop.org/fontconfig/fontconfig/-/work_items/539
+   https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/532
+ The upstream fix keeps mode="prepend" but moves the value to the
+ `genericfamily` pattern object (which only exists since 2.18.0), so the
+ injected name never enters the `family` list. mode="append" on `family`
+ is a 2.17.1 workaround that fixes the reported case but is not an exact
+ equivalent: generic-family queries such as 'sans-serif:spacing=100'
+ resolve to a proportional font instead of monospace (see comment #4).
  
  Request: update fontconfig to >= 2.18.2 (or apply the 2.17-compatible
  equivalent).

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169400

Title:
  fontconfig 2.17.1: 48-spacing.conf overrides the application-selected
  font family

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/2169400/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to