Commit graph

111 commits

Author SHA1 Message Date
Strykar
fc23ef57ec
fonts: make the color emoji regression test environment-independent
The coverage threshold (0.5 in fbd4e5ad1, lowered to 0.3 in d4106ef2d to
get CI green) is environment-dependent: a correctly sized emoji covers
~0.84 of its cell on one box but ~0.39 in CI, while the buggy render is
~0.28, so the margin is thin and font/cell dependent.

Render the same font two ways at one size instead: via its fontconfig
descriptor (which carries the size-fixup matrix) and via its file path
(which does not). They must come out the same size; the bug shrinks the
descriptor one. Only the matrix differs, so the check no longer depends
on the environment or the emoji artwork.
2026-06-14 21:00:12 +05:30
Kovid Goyal
d4106ef2db
Lower threshold for color emoji shrinkage test as at least in CI the font results in a smaller emoji 2026-06-14 20:48:59 +05:30
Strykar
fbd4e5ad1f
freetype: do not apply the fontconfig size-fixup matrix to color glyphs
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
2026-06-14 15:14:04 +05:30
Strykar
8be2a10b29
fonts: attach synthetic-italic FC_MATRIX to found roman faces
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.
2026-06-11 00:57:59 +05:30
zhaolei
5c591d5355 Add tests for glyph_matches_dot_liga_final_component 2026-04-26 16:43:37 +08:00
Kovid Goyal
b67f479040
Remove leftover debug print 2026-04-26 12:54:29 +05:30
Kovid Goyal
2f81f9e43b
Cleanup previous PR 2026-04-26 12:19:01 +05:30
zhaolei
98c8357ebe Add shaping tests for ligature cases and bundle Comfy Code 2026-04-25 19:43:17 +08:00
copilot-swe-agent[bot]
74c3bbe06d
Implement software rendering for Unicode 16 legacy computing symbols
Add rendering for codepoints U+1FBCE-U+1FBEF, U+1CC1B-U+1CC3F,
and U+1CE16-U+1CE19 in decorations.c with registration in fonts.c
and test coverage in kitty_tests/fonts.py.

Characters implemented:
- U+1FBCE-1FBCF: Left two-thirds and one-third blocks
- U+1FBD0-1FBDF: 16 diagonal box drawing characters
- U+1FBE0-1FBE3: Justified half white circles (outlines)
- U+1FBE4-1FBE5: Upper/lower centre quarter blocks
- U+1FBE8-1FBEB: Justified half black circles (filled)
- U+1FBEC-1FBEF: Justified quarter black circles (filled)
- U+1CC1B-1CC1E: Box drawing variants with offset junctions
- U+1CC1F-1CC20: Double diagonal lines
- U+1CC30-1CC3F: Twelfth and quarter circle arcs
- U+1CE16-1CE19: Box drawings light vertical T-junctions

Fixes #9851
2026-04-11 14:17:21 +05:30
copilot-swe-agent[bot]
76c76381b8
Add missing block elements from Unicode Symbols for Legacy Computing Supplement
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/0e5a33d1-c34e-4e8a-b161-7469ab770c05

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-11 04:24:29 +00:00
Kovid Goyal
ced3a98aa8
Fix failing test
num_scaled_cells calculation was incorrect. Also optimize copying from
scratch when width is unchanged.
2026-02-24 09:53:06 +05:30
Kovid Goyal
2907999131
Use the same algorithm for rendering box cells and font based cells
Should make things easier to change in tandem in future.
2025-02-19 17:05:43 +05:30
Kovid Goyal
6f57537f30
Fix failing test 2025-02-18 18:44:57 +05:30
Kovid Goyal
5adc81e146
Skip colrv1 rendering on macOS 2025-02-03 11:06:41 +05:30
Kovid Goyal
d068a0a6de
Add basic colrv1 rendering test 2025-02-03 11:06:41 +05:30
Kovid Goyal
da1626090a
Update codebase to Python 3.10 using pyupgrade 2025-02-03 10:56:50 +05:30
Kovid Goyal
95fbc6e9ba
Forgot a couple of octants 2025-02-03 10:56:48 +05:30
Kovid Goyal
39dc31e021
Render the octant characters using box drawing 2025-02-03 10:56:48 +05:30
Kovid Goyal
c67475271f
Remove box drawing python code 2025-02-03 10:56:48 +05:30
Kovid Goyal
1707e603f3
Implement underline exclusion 2025-02-03 10:56:46 +05:30
Kovid Goyal
27c862970b
Simplify sprite management code
Now if decorations are needed they are created *before* the index for
the sprite is assigned.
2025-02-03 10:56:46 +05:30
Kovid Goyal
b2a4db2028
Revert metadata row for sprites
Store in a separate VAO instead more performant as it uses less VRAM and
allows shader lookup co-ords to be passed to fragment shaders without
calculation in the fragment shader.
2025-02-03 10:56:45 +05:30
Kovid Goyal
9e9ab3e6f9
pass decorations location as sprite metadata 2025-02-03 10:56:45 +05:30
Kovid Goyal
5d195bf50b
Give sprites a metadata row accessible in the shaders
Will allow sprites to point to where their decorations should be read
from, for instance. Needed for scaled text and also if we want to
implement decoration avoidance.
2025-02-03 10:56:45 +05:30
Kovid Goyal
0fb49f4139
Switch to using an index for sprite tracking
Frees up two bytes in GPUCell. Doesn't require a minimum texture row
size. Makes a bunch of code faster. Index uses 31 bits which gives us
2,147,483,647 aka ~ 2 billion sprites.
2025-02-03 10:56:45 +05:30
Kovid Goyal
1aec299ad8
... 2025-02-03 10:56:45 +05:30
Kovid Goyal
42e93d8caa
More work on scaled font rendering 2025-02-03 10:56:44 +05:30
Kovid Goyal
3dca2687d8
Make font rendering tests use a text font rather than system font 2025-02-03 10:56:44 +05:30
Kovid Goyal
850dcec4d7
Allow multiple box rendering chars per cell 2025-02-03 10:56:44 +05:30
Kovid Goyal
073d5c7340
Add test for quarter blocks 2025-02-03 10:56:44 +05:30
Kovid Goyal
8030cbd361
Allow more subscales 2025-02-03 10:56:44 +05:30
Kovid Goyal
79a062466c
Fix render_box_cell test with odd block height 2025-02-03 10:56:44 +05:30
Kovid Goyal
383e1f8f57
Work on scaled rendering for box drawing chars 2025-02-03 10:56:43 +05:30
Kovid Goyal
f8e9040d86
Port LastResort test 2024-07-02 19:36:53 +05:30
Kovid Goyal
3a8362ca2b
Accomodate the fact that arch linux fira code ttf package excludes the variable version. Sigh. 2024-06-24 21:03:29 +05:30
Kovid Goyal
20c919e16e
Skip DejaVu font test 2024-06-24 09:08:05 +05:30
Kovid Goyal
18ab18d090
Fix matching against style names in presence of elision 2024-06-24 07:54:19 +05:30
Kovid Goyal
67a9ee680b
Automatically propagate features from regular face to the other faces when they are set to auto 2024-06-24 07:54:19 +05:30
Kovid Goyal
a69d71d416
Render font feature list in UI 2024-06-24 07:54:18 +05:30
Kovid Goyal
57edb412e6
Add tests to validate feature-from-spec 2024-06-24 07:54:18 +05:30
Kovid Goyal
10cae2c557
more tests 2024-06-24 07:54:18 +05:30
Kovid Goyal
679abf0e84
Ensure bold face is at least as heavy as regular face when auto selecting 2024-06-24 07:54:17 +05:30
Kovid Goyal
d205b147eb
Improve auto selection of variable faces 2024-06-24 07:54:17 +05:30
Kovid Goyal
b017cc0c1e
Handle variable fonts like cascadia code that dont have a postfix variation prefix name for some of their faces 2024-06-24 07:54:17 +05:30
Kovid Goyal
28f2919753
Fix medium face selection when more than family specified 2024-06-24 07:54:17 +05:30
Kovid Goyal
8ba6d5a296
CoreText: When finding medium face for a family prefer variable font if available 2024-06-24 07:54:16 +05:30
Kovid Goyal
5d725c4883
Skip test o older freetype 2024-06-24 07:54:16 +05:30
Kovid Goyal
67d535a5db
Add a test for dejavu sans mono 2024-06-24 07:54:16 +05:30
Kovid Goyal
7fd9bca845
IBM Plex Mono workaround is needed only under fontconfig 2024-06-24 07:54:16 +05:30
Kovid Goyal
c27c731ffb
Get font selection for the cascadia code variable fonts working 2024-06-24 07:54:16 +05:30