Color glyphs (COLR/CBDT/SVG) go through cairo on a second FT_Face,
self->face_for_cairo, opened in ensure_cairo_resources. That face
never receives the FT_Set_Transform installed on self->face in
face_from_descriptor (#9990): cairo owns FT_Set_Transform on its own
face and derives it from the font matrix on every render
(_cairo_ft_unscaled_font_set_scale in cairo-ft-font.c). The only
channel that reaches color-glyph rasterization is the cairo font
matrix, not the FT face transform, so FC_MATRIX is silently dropped on
that path. Stock fontconfig rules do not apply FC_MATRIX to color
fonts, so this is a hand-built config edge case.
Factor the two cairo_set_font_size() call sites in set_cairo_font_size
and fit_cairo_glyph into apply_cairo_font_size(), which calls
cairo_set_font_matrix() with size * FC_MATRIX when has_matrix is set,
and falls through to cairo_set_font_size() otherwise. The non-matrix
path is bit-identical to before. For pure shears (xx=1, yy=1)
cairo_scaled_font_glyph_extents reads the post-shear bbox so the
shrink loop bounds the destination correctly; the user-visible effect
is that a sheared color glyph reports a wider bbox and shrinks more
aggressively to fit a cell than its upright sibling. Acceptable for
the hand-built edge case this PR scopes to.
FT_Matrix stores xx,xy,yx,yy in row-major order;
cairo_matrix_init takes xx,yx,xy,yy. Same matrix, transposed argument
order - pinned with a comment because it is easy to flip.
Refs: #9990
In highlight_mark(), mark_text was sliced using byte-based indexing
(mark_text[:len(hint)] and mark_text[len(hint):]). Since len(hint)
equals the rune count (hint is always ASCII), but len(mark_text) is a
byte count, this could slice in the middle of a multi-byte UTF-8
sequence (e.g. CJK characters), producing an invalid byte sequence
rendered as the Unicode replacement character (�).
Fix by converting mark_text to []rune first, then slicing at rune
boundaries. The hint is ASCII so len(hint) == rune count, requiring
no conversion on the hint side.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When kitten --help is run in a terminal and less is not available,
ShowHelpInPager silently discards the error from pager.Run(), resulting
in no output and a zero exit code. Fall back to writing help text
directly to stdout when the pager fails, matching the behavior of the
Python equivalent in kitty/cli.py which catches FileNotFoundError and
prints the text as a fallback.
Signed-off-by: Xuyiyang23333 <xuyiyang23333@gmail.com>
pattern_as_dict() in fontconfig.c never read FC_MATRIX, so any per-font
transform set by fontconfig was silently dropped. fontconfig ships a
default rule (90-synthetic.conf) that applies a slant matrix to any
roman-only font when italic is requested, which is why italic CJK has
been rendering upright in kitty.
Read the matrix, carry it on the descriptor as a 4-tuple of doubles,
apply it once in face_from_descriptor() via FT_Set_Transform, also
inform HarfBuzz via hb_font_set_synthetic_slant + hb_ft_font_changed
so shaping reflects the slanted rendering. Extend
face_equals_descriptor() to compare the matrix so the per-FontGroup
fallback cache returns the right face when upright and italic share a
font file.
The FT transform is sticky on the face, so subsequent FT_Load_Glyph
calls inherit it with no per-call overhead, and the per-Face glyph
atlas cache stays correct because the matrix is set at init and never
changes. Pure shears (xx=1, yy=1) preserve horizontal advance and do
not disturb monospace cell width.
The HB synthetic_slant call is gated on HB_VERSION_ATLEAST(4,0,0) since
setup.py allows down to 1.5.0. hb_ft_font_changed runs unconditionally
to invalidate any populated caches.
Refs #9857, #9700.