ee937bdd1b routed FC_MATRIX through the cairo font matrix so synthetic
slant reaches color glyphs. But FC_MATRIX is also how fontconfig encodes
the pixel-size fixup of fixed-size faces. Noto Color Emoji is a ~109px
bitmap strike and fontconfig hands consumers a matrix scaling it to the
requested size (factor = requested_px / strike_px). cairo_set_font_size()
already brings the strike to the requested size, so feeding that matrix
into cairo_set_font_matrix() in apply_cairo_font_size() scales it down
again by the fixup factor. At terminal cell sizes that is a large shrink,
up to ~9x for small cells (easing to 1x as the cell nears the strike), so
color emoji render as a dot; fit_cairo_glyph() only shrinks, so it never
grows them back.
Only the shear carries synthetic slant; the diagonal is the size, which
cairo_set_font_size() and fit_cairo_glyph() already handle. Apply only
the shear and fall through to cairo_set_font_size() when there is no
shear. Pure-slant matrices are unchanged. This carries only the shear to
color glyphs, so a non-uniform diagonal scale from a hand-built FC_MATRIX
is dropped on that path; the stock fixup is uniform, so dropping it is
the intended behaviour.
Add a regression test that renders a color emoji and checks it fills its
cells, skipped unless a fixed-size color font with a fontconfig fixup
matrix is present.
Fixes#10144
No significant feedback received post release of protocol in 0.47.0
almost a month ago.
Protocol can now only change in backward compatible ways, barring
security issues.
Fixes#9984
fontconfig's FcFontList omits FC_MATRIX from its object set
(kitty/fontconfig.c), so a roman font that find_best_match finds there
(e.g. Fira Code, which ships no italic, in both its static and variable
builds) carries no synthetic-italic shear and its "italic" renders upright.
A family that is not found is substituted, and when the substitute
resolves through the listed faces those descriptors are equally
matrix-less, so this attach covers them too. Only raw fc_match
descriptors (runtime glyph-fallback faces via create_fallback_face, and
find_best_match's last-resort return) already carry the matrix from
substitution.
The italic intent for the configured faces exists only during selection,
not at face construction, so attach the matrix at the end of
get_font_files: for an italic slot whose chosen face is upright and has no
matrix, ask fc_match what fontconfig would do. fc_match returns a synthetic
matrix only when there is no real italic to use (no italic face and no
slanted named instance or variable slant axis), so a font that is already
italic, static or variable, is never double-slanted. Face construction
applies the matrix via FT_Set_Transform; the previous commit makes it
survive the size specialization step the render path builds faces from.
Only the matrix is taken, so selection is unchanged.
FontConfigPattern declared matrix as a required key, but pattern_as_dict
sets it only when the pattern has one, so declare it NotRequired. With
that and narrowing on descriptor_type the attach needs no cast.
Add a regression test (test_synthetic_italic_matrix): a roman no-italic
font gets a non-identity matrix on its italic slot while a real-italic
control does not, and the matrix survives specialize_font_descriptor. It
asserts the invariant rather than the exact shear (the value is
fontconfig's, version-dependent) and skips when the synthetic rule is
inactive.
Covers the four configured faces. Limitation: fc_match re-matches by family
name, so under an uncommon config (a multi-face family key plus a user
per-font FC_MATRIX rule keyed on width/style) it can attach a matrix
computed for a different face; the 90-synthetic shear this targets is
weight-independent and unaffected. A production version should re-match the
selected face by path+index+slant.
The choose-fonts kitten queries the terminal for the user's foreground and
background colors at startup by sending a DCS request. The terminal responds
with separate DCS response strings — one per field — which arrive
asynchronously through on_query_response.
The background handler unconditionally called draw_screen() after storing its
value. If the terminal's DCS response for "background" arrived before the
response for "foreground", draw_screen() fired with text_style.Foreground
still at its Go zero value ("").
The font list preview (list.go) only guarded against empty Background, not
empty Foreground, so it passed the check and sent a render_family_samples
command to the Python backend with foreground="". The backend's to_color('')
raised ValueError: Invalid color name: '', crashing the kitten.
The faces pane (faces.go) launched a render_family_samples goroutine
unconditionally when its preview cache was empty, with no guard at all.
Fix
---
1. ui.go — Only trigger draw_screen() from the foreground or background
handler when the counterpart field is already populated, so the UI
never renders with a partial TextStyle.
2. list.go — Require both Foreground and Background to be non-empty
before rendering the font preview, not just Background alone.
3. faces.go — Skip the render_family_samples goroutine if either color
field is still empty. The preview cache stays empty, so the next
redraw (triggered when the counterpart query response arrives, or
by on_wakeup) retries with full colors.
specialize_font_descriptor() re-resolves a descriptor by file, index,
size and dpi to pick up size dependent fields. The re-match carries no
slant request, so fontconfig cannot re-derive a synthetic italic matrix,
and only index, named_style and axes were copied back from the base
descriptor. Any FC_MATRIX on the descriptor was therefore lost on every
sized face build, so the face was constructed without it and
FT_Set_Transform was never called, rendering the glyphs upright.
Descriptors can carry FC_MATRIX since b3e7c3e ("Read FC_MATRIX from
fontconfig"). Copy the matrix back like the other selection derived
fields the re-match cannot reproduce.
A quick click-and-flick on a tab could leave all of kitty with mouse
input permanently redirected to the tab bar, making every window
unclickable and text selection impossible.
Starting a tab drag is asynchronous: the drag thumbnail is rendered on
the next frame before glfwStartDrag is called. If the button is
released in that window, wl_data_device_start_drag is sent with a stale
serial that no longer matches an active pointer implicit grab, so the
compositor silently ignores it. The wl_data_source then never receives
any event, on_drag_source_finished never runs, and the
tab_being_dragged state is stuck forever, hijacking all mouse events.
Fix in layers:
- glfw/Wayland: track the implicit grab (serial of the first button
press and pressed-button count), use that serial for start_drag and
refuse with EAGAIN when there is no active implicit grab instead of
letting the compositor silently drop the request
- mouse.c: a left button release arriving while a tab drag is marked
started but no system DND is active means the drag never launched
(an active DND consumes the release on all platforms), so clear the
drag state instead of waiting for DND events that will never come
- tabs.py: handle OSError from start_drag_with_data for tab drags the
same way window drags already do; clear the potential-drag state when
the release lands on the new-tab button or empty tab bar area
- tabs.py/boss.py: clear drag state on drag finish/drop even when the
dragged tab has already been closed
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When focus_follows_mouse is enabled, returning to a desktop/space fired an
enter event that switched the active window to whichever one was under the
cursor, even though the mouse had not crossed a window boundary.
Distinguish genuine mouse motion into a window from a window reappearing
under a stationary cursor by checking, in cursor_enter_callback, whether the
cursor position actually changed. focus_follows_mouse now switches focus only
when the cursor moved, so motion into a window still switches focus while a
stationary reappearance does not.